### LuminareTextField Full Initializer Example Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/components.md Example of using the full initializer for LuminareTextField with a custom format and prompt. ```swift @State var text: String? var body: some View { LuminareTextField( value: $text, format: StringFormatStyle(), prompt: Text("Enter text"), label: { Text("Name") } ) } ``` -------------------------------- ### LuminareFormLayout Usage Example Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/types.md Example of applying a stacked layout to a LuminareForm using environment values. ```swift LuminareForm { // form content } .environment(\.luminareFormLayout, .stacked) ``` -------------------------------- ### LuminareForm Example with Stacked Layout Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/components.md An example demonstrating how to use LuminareForm with a stacked layout. It includes sections with text fields and a toggle, and sets the layout environment value. ```swift LuminareForm { LuminareSection { LuminareTextField("Name", text: $name) LuminareTextField("Email", text: $email) } LuminareSection { LuminareToggle(isOn: $subscribe) { Text("Subscribe to newsletter") } } } .environment(\.luminareFormLayout, .stacked) ``` -------------------------------- ### LuminarePicker Full Grid Example Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/components.md Example demonstrating how to use the LuminarePicker with a full grid layout. It binds the selection to a @State variable and configures the number of columns. ```swift @State var selected: Int = 5 var body: some View { LuminarePicker( elements: Array(1...12), selection: $selected, columns: 3 ) { number in Text("\(number)") .frame(height: 40) } } ``` -------------------------------- ### Standard SwiftUI Animation Example Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/types.md Illustrates applying a standard SwiftUI animation to a view transition. This example uses a custom duration for the animation. ```swift var body: some View { Text("Content") .transition(.opacity) .animation(.easeInOut(duration: 0.3), value: isVisible) } ``` -------------------------------- ### Create LuminareTitleBarButtonConfiguration Instance Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/types.md Example of creating an instance of LuminareTitleBarButtonConfiguration with specific padding, spacing, and hidden properties. ```swift let config = LuminareTitleBarButtonConfiguration( padding: NSEdgeInsets(top: 8, left: 8, bottom: 0, right: 8), spacing: 8, hidden: false ) ``` -------------------------------- ### LuminareButton Initializers Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/components.md Documentation for the various initializers available for the LuminareButton component, including parameters and usage examples. ```APIDOC ## LuminareButton A stylized button component that displays a label alongside content. ### Initializers #### Full Builder Initializer ```swift public init( role: ButtonRole? = nil, @ViewBuilder label: @escaping () -> Label, @ViewBuilder content: @escaping () -> Content, action: @escaping () -> () ) where Label: View, Content: View ``` **Parameters:** - **role** (ButtonRole?) - Optional - nil - Optional button role for semantic meaning (e.g., .destructive) - **label** (ViewBuilder) - Required - — - The label view displayed alongside the button - **content** (ViewBuilder) - Required - — - The content view displayed in the button - **action** (() -> ()) - Required - — - Closure invoked when button is tapped **Returns:** A view conforming to `View` protocol **Example:** ```swift LuminareButton(role: .destructive) { Label("Delete", systemImage: "trash") } content: { Text("Confirm deletion") } action: { deleteItem() } ``` #### String Title with Content ```swift public init( _ title: some StringProtocol, role: ButtonRole? = nil, @ViewBuilder content: @escaping () -> Content, action: @escaping () -> () ) where Label == Text ``` **Parameters:** - **title** (StringProtocol) - Required - — - Button label text - **role** (ButtonRole?) - Optional - nil - Optional button role - **content** (ViewBuilder) - Required - — - The content view - **action** (() -> ()) - Required - — - Action closure **Example:** ```swift LuminareButton("Settings") { Text("Configure options") } action: { openSettings() } ``` #### Localized String Key with Content ```swift public init( _ titleKey: LocalizedStringKey, role: ButtonRole? = nil, @ViewBuilder content: @escaping () -> Content, action: @escaping () -> () ) where Label == Text ``` Similar to string title initializer but uses `LocalizedStringKey` for localization support. #### String Title and Content ```swift public init( _ title: some StringProtocol, _ content: some StringProtocol, role: ButtonRole? = nil, action: @escaping () -> () ) where Label == Text, Content == Text ``` **Parameters:** - **title** (StringProtocol) - Required - — - Button label text - **content** (StringProtocol) - Required - — - Button content text - **role** (ButtonRole?) - Optional - nil - Optional button role - **action** (() -> ()) - Required - — - Action closure **Example:** ```swift LuminareButton("Action", "Click me!") { print("Clicked") } ``` ### Styling and Modifiers The button automatically applies: - `.buttonStyle(.luminare)` - Luminare button styling - Appropriate rounding behavior - Content size fitting - Horizontal padding from environment ``` -------------------------------- ### LuminareWindow Example Usage Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/window-management.md Demonstrates how to create and configure a LuminareWindow with custom properties and set its initial position. The `onClose` callback is also shown. ```swift let window = LuminareWindow( titleBarButtonConfiguration: .default, cornerRadius: 12, canBecomeMain: true, onClose: { print("Window closed") } ) { VStack { Text("Window Content") } } window.setFrameOrigin(NSPoint(x: 100, y: 100)) ``` -------------------------------- ### LuminareList Initializer Example Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/components.md This example demonstrates how to instantiate LuminareList with specific items, an empty selection, and custom content views for both list items and the empty state. Ensure your item type conforms to Hashable. ```swift @State var items: [String] = ["Item 1", "Item 2"] @State var selection: Set = [] var body: some View { LuminareList( items: $items, selection: $selection, id: \.self ) { item in Text(item.wrappedValue) } emptyView: { Text("No items") .foregroundStyle(.secondary) } ``` -------------------------------- ### LuminarePicker Compact Row Example Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/components.md Example demonstrating the LuminarePicker in a compact row layout. It takes an array of elements and a selection binding, suitable for single-row choices. ```swift LuminarePicker( compactElements: ["Small", "Medium", "Large"], selection: $size ) { text in Text(text) } ``` -------------------------------- ### StringFormatStyle Formatting Example Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/utilities.md Shows the formatting capability of StringFormatStyle. This style performs identity formatting, returning the input string unchanged. ```swift let style = StringFormatStyle() let formatted = style.format("hello") // "hello" ``` -------------------------------- ### LuminareTextField String Label with Format Example Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/components.md Example of using LuminareTextField with a string literal as the label, a text binding, and a specified format. ```swift @State var username: String? var body: some View { LuminareTextField("Username", text: $username, prompt: Text("user@example.com")) } ``` -------------------------------- ### Minimal Luminare Configuration Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/configuration.md This snippet shows the basic setup for a SwiftUI app using Luminare with default configurations. It includes the necessary imports and the structure for a simple form with a text field. ```swift import SwiftUI import Luminare @main struct App: SwiftUI.App { var body: some Scene { WindowGroup { ContentView() } } } struct ContentView: View { @State var name = "" var body: some View { LuminareForm { LuminareSection { LuminareTextField("Name", text: $name) } } } } ``` -------------------------------- ### LuminareColorPicker Usage Example Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/components.md Example of how to use the LuminareColorPicker in a SwiftUI view, binding it to a state variable. ```swift @State var selectedColor: NSColor = .white var body: some View { LuminareColorPicker(selection: $selectedColor) } ``` -------------------------------- ### LuminareTextEditor Usage Example Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/components.md Demonstrates the usage of LuminareTextEditor for capturing multi-line text input. A @State variable is required to bind the text content. ```swift @State var description: String = "" var body: some View { LuminareTextEditor("Notes", text: $description) } ``` -------------------------------- ### Add and Consume Local Event Monitor Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/utilities.md Example of adding a local event monitor for key down events and consuming the event if the up arrow key is pressed. The monitor is later removed. ```swift let monitorId = UUID() EventMonitorManager.shared.addLocalMonitor( for: monitorId, matching: .keyDown ) { event in if event.keyCode == 0x7E { // up arrow print("Up arrow pressed") return nil // Consume event } return event // Propagate } // Later: remove monitor EventMonitorManager.shared.removeMonitor(for: monitorId) ``` -------------------------------- ### Implement LuminareSelectionData Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/utilities.md Example of implementing the LuminareSelectionData protocol for a custom list item. Ensures items can be configured as selectable or non-selectable. ```swift struct MyListItem: LuminareSelectionData { let id: UUID let title: String let isSelectable: Bool // Must implement } let items: [MyListItem] = [ MyListItem(id: UUID(), title: "Enabled", isSelectable: true), MyListItem(id: UUID(), title: "Disabled", isSelectable: false) ] LuminareList( items: $items, selection: $selection, id: \.id ) { item in Text(item.wrappedValue.title) } ``` -------------------------------- ### Example Usage of RectangleCornerRadii Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/types.md Demonstrates how to create an instance of RectangleCornerRadii with specific values for each corner. This is used for applying custom corner rounding to UI elements. ```swift let radii = RectangleCornerRadii( topLeading: 8, bottomLeading: 8, bottomTrailing: 4, topTrailing: 4 ) ``` -------------------------------- ### LuminareToggle Usage Example Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/components.md Demonstrates how to use the LuminareToggle component with a Text label. Ensure you have a @State variable to bind the toggle's state. ```swift @State var isEnabled = false var body: some View { LuminareToggle(isOn: $isEnabled) { Text("Enable feature") } } ``` -------------------------------- ### MenuItem Example with LuminareSelectionData Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/types.md Demonstrates how to implement LuminareSelectionData in a struct and use it within a LuminareList. Items with isSelectable set to false will be disabled. ```swift struct MenuItem: LuminareSelectionData { let name: String let isSelectable: Bool } let items = [ MenuItem(name: "Edit", isSelectable: true), MenuItem(name: "Delete", isSelectable: false) // Disabled ] LuminareList(items: $items, selection: $selection, id: \.name) { item in Text(item.wrappedValue.name) } ``` -------------------------------- ### LuminareButtonRow Usage Example Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/components.md Shows how to group multiple buttons within a LuminareButtonRow. Buttons can include standard actions, save actions, or destructive actions. ```swift LuminareButtonRow { Button("Cancel") { } Button("Save") { } Button("Delete", role: .destructive) { } } ``` -------------------------------- ### Custom Luminare Theme Configuration Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/configuration.md Configure a global theme for Luminare components by applying environment modifiers. This example sets a custom tint color, corner radii, animation, and form layout. ```swift @main struct App: SwiftUI.App { var body: some Scene { WindowGroup { ContentView() .environment(\.luminareTintColor, .blue) .environment(\.luminareCornerRadii, RectangleCornerRadii(topLeading: 12, bottomLeading: 12, bottomTrailing: 12, topTrailing: 12)) .environment(\.luminareAnimation, .easeInOut(duration: 0.25)) .environment(\.luminareFormLayout, .stacked) } } } ``` -------------------------------- ### LuminareWindow Convenience Initializer Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/window-management.md Use this initializer for a quick setup of a LuminareWindow with default title bar buttons and corner radius. It requires a content view closure. ```swift public convenience init( titleBarButtonConfiguration: LuminareTitleBarButtonConfiguration? = .default, cornerRadius: CGFloat = LuminareStyledWindow.defaultCornerRadius, content: @escaping () -> some View ) ``` -------------------------------- ### List with Disabled Items Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/QUICK_REFERENCE.md Example of how to create a list where items can be disabled based on a property, using a custom data structure that conforms to LuminareSelectionData. ```swift struct MenuItem: LuminareSelectionData { let name: String let enabled: Bool var isSelectable: Bool { enabled } } LuminareList(items: $items, selection: $selection, id: \.name) { item in Text(item.wrappedValue.name) } ``` -------------------------------- ### LuminareButton Full Builder Initializer Example Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/components.md Use this initializer when you need custom views for both the label and the button content. It requires a ButtonRole, a label view builder, a content view builder, and an action closure. ```swift LuminareButton(role: .destructive) { Label("Delete", systemImage: "trash") } content: { Text("Confirm deletion") } action: { deleteItem() } ``` -------------------------------- ### LuminareList Usage Example Source: https://github.com/mrkai77/luminare/blob/main/Sources/Luminare/Luminare.docc/Components/LuminareList.md Demonstrates how to initialize and use the LuminareList component with custom action buttons and a remove button. It shows how to provide items, selection, content for each row, an empty view, and action buttons for the toolbar. ```swift LuminareList( "List Header", "List Footer", items: $items, selection: $selection, id: \.self, removeKey: .init("Remove") ) { // Content } emptyView: { Text("Empty") .foregroundStyle(.secondary) .swipeActions { // Wwipe actions for row } } actions: { Button("Add") { withAnimation { add(&items) } } Button("Sort") { withAnimation { items.sort(by: <) } } } ``` -------------------------------- ### Configure Luminare with Environment Values Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/configuration.md Set Luminare configuration values using the .environment() modifier on SwiftUI views. This example sets the tint color and form layout. ```swift VStack { LuminareSection { LuminareTextField("Name", text: $name) } } .environment(\.luminareTintColor, .blue) .environment(\.luminareFormLayout, .stacked) ``` -------------------------------- ### Form with Sections and Rounded Behavior Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/QUICK_REFERENCE.md Example of creating a form with multiple sections, using LuminareSectionStack and applying rounded corners to individual sections. ```swift LuminareForm { LuminareSectionStack { LuminareSection { LuminareTextField("Name", text: $name) } .luminareRoundingBehavior(top: true) LuminareSection { LuminareTextField("Email", text: $email) } .luminareRoundingBehavior(bottom: true) } } ``` -------------------------------- ### LuminareSectionStack Usage Example Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/components.md Shows how to use LuminareSectionStack to arrange multiple LuminareSection components. Each section can contain its own set of form elements, and the stack manages their vertical layout and spacing. ```swift LuminareSectionStack { LuminareSection { LuminareTextField("Name", text: $name) } LuminareSection { LuminareTextField("Email", text: $email) } } ``` -------------------------------- ### LuminareSection Usage Example Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/components.md Demonstrates how to use LuminareSection to group related form elements like text fields. Ensure you have the necessary state variables (e.g., $name, $email) defined. ```swift LuminareSection { LuminareTextField("Name", text: $name) LuminareTextField("Email", text: $email) } ``` -------------------------------- ### LuminareButton String Title and Content Initializer Example Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/components.md Use this initializer for simple buttons where both the title and content are plain text. It accepts a title string, a content string, an optional ButtonRole, and an action closure. ```swift LuminareButton("Action", "Click me!") { print("Clicked") } ``` -------------------------------- ### Create and Show a Window Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/QUICK_REFERENCE.md Demonstrates how to create a new Luminare window with custom properties and content, and then make it visible. ```swift let window = LuminareWindow( cornerRadius: 12, canBecomeMain: true, onClose: { print("Closed") } ) { ContentView() } window.makeKeyAndOrderFront(nil) ``` -------------------------------- ### Basic LuminareSection Usage Source: https://github.com/mrkai77/luminare/blob/main/Sources/Luminare/Luminare.docc/Components/LuminareSection.md Demonstrates the basic structure for creating a LuminareSection with content, header, and footer. ```swift LuminareSection { // Content } header: { // Header } footer: { // Footer } ``` -------------------------------- ### LuminareSlider Usage Example Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/components.md Example of how to use LuminareSlider with a Double value, a range, step increments, and number formatting. The label is a Text view, and the content uses a standard Slider. ```swift @State var value: Double = 50 var body: some View { LuminareSlider( value: $value, in: 0...100, step: 5, format: .number, label: { Text("Volume") } ) { proxy in Slider(value: $value, in: 0...100, step: 5) } } ``` -------------------------------- ### LuminareWindow Full Initializer Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/window-management.md Initializes a LuminareWindow with comprehensive configuration options, including window behavior, positioning, and close callbacks. ```APIDOC ## LuminareWindow Full Initializer ### Description Initializes a LuminareWindow with comprehensive configuration options, including window behavior, positioning, and close callbacks. ### Method Signature ```swift init( _internalConfiguration _: () = (), titleBarButtonConfiguration: LuminareTitleBarButtonConfiguration? = .default, cornerRadius: CGFloat = LuminareStyledWindow.defaultCornerRadius, canBecomeMain: Bool = true, closesOnDefocus: Bool = false, initialOrigin: ((CGRect) -> CGPoint)? = nil, onClose: (() -> ())? = nil, content: @escaping () -> some View ) ``` ### Parameters #### Path Parameters * None #### Query Parameters * None #### Request Body * None ### Parameters Table | Parameter | Type | Required | Default | Description | |---|---|---|---|---| | _internalConfiguration _ | () | No | () | Internal configuration parameter | | titleBarButtonConfiguration | LuminareTitleBarButtonConfiguration? | No | .default | Title bar configuration | | cornerRadius | CGFloat | No | defaultCornerRadius | Window corner radius in points | | canBecomeMain | Bool | No | true | Whether window can become main window | | closesOnDefocus | Bool | No | false | Auto-close when losing key focus | | initialOrigin | ((CGRect) -> CGPoint)? | No | nil | Custom initial window position | | onClose | (() -> ())? | No | nil | Callback invoked when closed | | content | () -> some View | Yes | — | SwiftUI content for window | ### Request Example ```swift let window = LuminareWindow( titleBarButtonConfiguration: .default, cornerRadius: 12, canBecomeMain: true, onClose: { print("Window closed") } ) { VStack { Text("Window Content") } } window.setFrameOrigin(NSPoint(x: 100, y: 100)) ``` ### Response #### Success Response * LuminareWindow instance ``` -------------------------------- ### Get Complementary Color Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/modifiers-and-extensions.md Returns the complementary color of the current color. ```swift public var inverted: Color ``` ```swift let complementary = Color.blue.inverted ``` -------------------------------- ### Create a Custom Luminare Window Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/window-management.md Demonstrates how to create a custom window with specified corner radius, main window status, and defocus behavior. This is typically done within an application's delegate. ```swift class AppDelegate: NSObject, NSApplicationDelegate { var window: LuminareWindow? func applicationDidFinishLaunching(_ notification: Notification) { window = LuminareWindow( cornerRadius: 12, canBecomeMain: true, closesOnDefocus: false ) { ContentView() } window?.makeKeyAndOrderFront(nil) } } ``` -------------------------------- ### Initialize LuminareTextField with Prompt Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/QUICK_REFERENCE.md Create a text field for string input with a label and a hint prompt. ```swift // With prompt LuminareTextField("Label", text: $text, prompt: Text("Hint")) ``` -------------------------------- ### Initialize LuminarePicker as Grid Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/QUICK_REFERENCE.md Create a grid-based picker with a specified number of columns. ```swift // Grid picker LuminarePicker( elements: items, selection: $selected, columns: 4 ) { Text(item) } ``` -------------------------------- ### Show a Popover View Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/QUICK_REFERENCE.md Illustrates how to display a popover view attached to a button, allowing for contextual menus or options. ```swift @State var showPopover = false Button("Options") { showPopover = true } .luminarePopover(isPresented: $showPopover, arrowEdge: .bottom) { VStack { Button("Option 1") { } Button("Option 2") { } } } ``` -------------------------------- ### Initialize Basic LuminareList Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/QUICK_REFERENCE.md Create a list view with items, a selection binding, and a unique identifier for each item. ```swift // Basic LuminareList(items: $items, selection: $sel, id: \.self) { Text(item.wrappedValue) } ``` -------------------------------- ### Import Luminare Library Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/INDEX.md Import the main Luminare library to access its components and functionalities. ```swift import Luminare ``` -------------------------------- ### Swift: Snap Window to Size Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/window-management.md Use this method to immediately snap the window to a target size without any animation. The target size is specified as a CGSize. ```swift func snap(to size: CGSize) ``` -------------------------------- ### LuminareTextField - Full Initializer Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/components.md Initializes a LuminareTextField with a binding to a formatable value, a format style, an optional prompt, and a label view. ```APIDOC ## LuminareTextField - Full Initializer ### Description Initializes a LuminareTextField with a binding to a formatable value, a format style, an optional prompt, and a label view. ### Initializer Signature ```swift public init( value: Binding, format: F, prompt: Text? = nil, @ViewBuilder label: @escaping () -> Label ) where Label: View, F: ParseableFormatStyle, F.FormatOutput == String ``` ### Parameters #### Path Parameters - **value** (Binding) - Required - Binding to the text value - **format** (ParseableFormatStyle) - Required - Format style for parsing and formatting - **prompt** (Text?) - Optional - Placeholder text - **label** (ViewBuilder) - Required - Label view ### Request Example ```swift @State var text: String? var body: some View { LuminareTextField( value: $text, format: StringFormatStyle(), prompt: Text("Enter text"), label: { Text("Name") } ) } ``` ### Response Returns a view conforming to the `View` protocol. ``` -------------------------------- ### Initialize LuminareTextField with String Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/QUICK_REFERENCE.md Create a text field for string input with a label. ```swift // String text LuminareTextField("Label", text: $text) ``` -------------------------------- ### Invert Color Extension Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/types.md Provides a computed property to get the complementary color of a SwiftUI Color. Use this to easily access the inverted version of any color. ```swift public var inverted: Color ``` -------------------------------- ### Initialize LuminareTextField with Format Style Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/QUICK_REFERENCE.md Create a text field for numeric input, specifying a format style. ```swift // With format style LuminareTextField("Value", value: $number, format: .number) ``` -------------------------------- ### LuminarePopoverModifier Usage Example Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/window-management.md Demonstrates how to use the luminarePopover modifier to present a popover anchored to a view. Configure arrow edge and content using bindings and view builders. ```swift @State var showPopover = false var body: some View { Button("More Options") { showPopover = true } .luminarePopover(isPresented: $showPopover, arrowEdge: .top) { VStack { Button("Option 1") { } Button("Option 2") { } } .padding() } } ``` -------------------------------- ### Basic LuminareSidebar Structure Source: https://github.com/mrkai77/luminare/blob/main/Sources/Luminare/Luminare.docc/Main Window/Sidebar/LuminareSidebar.md Demonstrates the basic structure of a LuminareSidebar, showing how to organize content into sections using LuminareSidebarSection. Each section can be configured with a title, a selection binding, and a collection of items. ```swift LuminareSidebar { LuminareSidebarSection("Application", selection: $selection, items: [...]) LuminareSidebarSection("About", selection: $selection, items: [...]) ... } ``` -------------------------------- ### LuminareWindow Full Initializer Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/window-management.md This initializer provides extensive control over window behavior, including main window status, defocus closing, initial positioning, and close callbacks. It also requires a content view closure. ```swift init( _internalConfiguration _: () = (), titleBarButtonConfiguration: LuminareTitleBarButtonConfiguration? = .default, cornerRadius: CGFloat = LuminareStyledWindow.defaultCornerRadius, canBecomeMain: Bool = true, closesOnDefocus: Bool = false, initialOrigin: ((CGRect) -> CGPoint)? = nil, onClose: (() -> ())? = nil, content: @escaping () -> some View ) ``` -------------------------------- ### Initialize Basic LuminareSlider Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/QUICK_REFERENCE.md Create a basic slider with a value binding, range, format, and label. ```swift // Basic slider LuminareSlider( value: $value, in: 0...100, format: .number, label: { Text("Value") } ) { Slider(value: $value, in: 0...100) } ``` -------------------------------- ### Custom Parseable Format Style Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/utilities.md Example of creating a custom format style for text fields using ParseableFormatStyle. This allows for custom formatting and parsing logic for specific data types. ```swift @State var value: MyType? var body: some View { LuminareTextField( "Field", value: $value, format: MyFormatStyle() ) } struct MyFormatStyle: ParseableFormatStyle { func format(_ value: MyType) -> String { // Custom formatting } func parseStrategy(for locale: Locale) -> MyParseStrategy { MyParseStrategy() } } ``` -------------------------------- ### LuminarePicker - Full Grid Initializer Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/components.md Initializes a grid-based LuminarePicker with a specified number of columns and custom item content. It allows for selection of a single item from a collection. ```APIDOC ## LuminarePicker - Full Grid Initializer ### Description Initializes a grid-based LuminarePicker with a specified number of columns and custom item content. It allows for selection of a single item from a collection. ### Method Initializer ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```swift @State var selected: Int = 5 var body: some View { LuminarePicker( elements: Array(1...12), selection: $selected, columns: 3 ) { number in Text("\(number)") .frame(height: 40) } } ``` ### Response #### Success Response A view conforming to `View` protocol. #### Response Example None provided. ``` -------------------------------- ### Configure Fast Animation Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/configuration.md Set a faster animation for quick feedback effects like selection highlighting or hover states. This uses a dedicated environment key for rapid transitions. ```swift .environment(\.luminareAnimationFast, .easeInOut(duration: 0.1)) ``` -------------------------------- ### SwiftUI: Presenting a Modal Dialog Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/window-management.md Example of how to use the .luminareModal modifier to present a modal view. It involves a @State variable to control the modal's visibility and a button to trigger its presentation. ```swift @State var showModal = false var body: some View { VStack { Button("Show Modal") { showModal = true } } .luminareModal(isPresented: $showModal) { LuminareForm { Text("Modal content here") } } } ``` -------------------------------- ### Basic LuminarePicker Initialization Source: https://github.com/mrkai77/luminare/blob/main/Sources/Luminare/Luminare.docc/Components/LuminarePicker.md Initialize LuminarePicker by providing a collection of elements and a binding for the selection. A closure is used to define the content displayed for each element. ```swift LuminarePicker( elements: [...], selection: $selection ) { element in // Content } ``` -------------------------------- ### Basic LuminareCompose with Label Source: https://github.com/mrkai77/luminare/blob/main/Sources/Luminare/Luminare.docc/Components/Compose/LuminareCompose.md Use this snippet to create a basic LuminareCompose view with both content and a label. ```swift LuminareCompose { // Content } label: { // Label } ``` -------------------------------- ### LuminareWindow Convenience Initializer Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/window-management.md Initializes a LuminareWindow with basic configuration, allowing for custom title bar buttons, corner radius, and content view. ```APIDOC ## LuminareWindow Convenience Initializer ### Description Initializes a LuminareWindow with basic configuration, allowing for custom title bar buttons, corner radius, and content view. ### Method Signature ```swift public convenience init( titleBarButtonConfiguration: LuminareTitleBarButtonConfiguration? = .default, cornerRadius: CGFloat = LuminareStyledWindow.defaultCornerRadius, content: @escaping () -> some View ) ``` ### Parameters #### Path Parameters * None #### Query Parameters * None #### Request Body * None ### Parameters Table | Parameter | Type | Required | Default | Description | |---|---|---|---|---| | titleBarButtonConfiguration | LuminareTitleBarButtonConfiguration? | No | .default | Title bar button styling | | cornerRadius | CGFloat | No | defaultCornerRadius | Window corner radius | | content | () -> some View | Yes | — | Window content view | ### Request Example * None ### Response #### Success Response * LuminareWindow instance ``` -------------------------------- ### Display a Popover Menu Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/window-management.md Demonstrates how to create a popover menu using the `.luminarePopover` modifier. This involves a state variable to control visibility, an arrow edge, and content for the popover. ```swift @State var showMenu = false var body: some View { Button(action: { showMenu = true }) { Image(systemName: "ellipsis.circle") } .luminarePopover(isPresented: $showMenu, arrowEdge: .bottom) { VStack(spacing: 0) { ForEach(MenuItem.allCases, id: \.self) { item in Button(action: { performAction(item) }) { Text(item.label) } } } .padding(8) } } ``` -------------------------------- ### LuminarePicker Full Grid Initializer Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/components.md Initializes a LuminarePicker for grid-based selection with a specified number of columns and padding. Use this for multi-column layouts. ```swift public init( elements: [V], selection: Binding, columns: Int = 4, innerPadding: CGFloat = 4, @ViewBuilder content: @escaping (V) -> Content ) where Content: View, V: Equatable ``` -------------------------------- ### LuminareButton String Title with Content Initializer Example Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/components.md Use this initializer for buttons with a text title and custom content view. It takes a string title, an optional ButtonRole, a content view builder, and an action closure. ```swift LuminareButton("Settings") { Text("Configure options") } action: { openSettings() } ``` -------------------------------- ### LuminareList Full Initializer Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/components.md Initializes LuminareList with bindings for items and selection, a key path for identification, and closures for item content and an empty view. ```APIDOC ## LuminareList Full Initializer with Empty View ### Description Initializes LuminareList with bindings for items and selection, a key path for identification, and closures for item content and an empty view. ### Initializer Signature ```swift public init( items: Binding<[V]>, selection: Binding>, id keyPath: KeyPath, @ViewBuilder content: @escaping (Binding) -> ContentA, @ViewBuilder emptyView: @escaping () -> ContentB ) where V: Hashable, ID: Hashable ``` ### Parameters #### Parameters - **items** (Binding<[V]>) - Required - Array binding for list items - **selection** (Binding>) - Required - Set binding for selected items - **keyPath** (KeyPath) - Required - Key path for identifying items uniquely - **content** (ViewBuilder) - Required - Closure to build each item's content - **emptyView** (ViewBuilder) - Required - Closure for empty state view ### Returns A view conforming to `View` protocol ### Example ```swift @State var items: [String] = ["Item 1", "Item 2"] @State var selection: Set = [] var body: some View { LuminareList( items: $items, selection: $selection, id: \.self ) { item in Text(item.wrappedValue) } emptyView: { Text("No items") .foregroundStyle(.secondary) } } ``` ``` -------------------------------- ### Luminare Output Directory Structure Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/GENERATION_REPORT.md This structure outlines the organization of the generated output files for the Luminare project. It includes the main README, navigation hubs, quick reference guides, type definitions, configuration details, manifest, and the generation report itself, alongside an API reference directory containing documentation for components, window management, modifiers, and utilities. ```markdown /workspace/home/output/ ├── README.md Main overview and navigation ├── INDEX.md Navigation hub and lookup tables ├── QUICK_REFERENCE.md Essential patterns and examples ├── types.md Type definitions reference ├── configuration.md Environment configuration guide ├── MANIFEST.txt Documentation manifest ├── GENERATION_REPORT.md This report └── api-reference/ ├── components.md UI components (20+) ├── window-management.md Windows and modals ├── modifiers-and-extensions.md View modifiers and environment values └── utilities.md Utility types and helpers ``` -------------------------------- ### Initialize LuminareList with Empty View Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/QUICK_REFERENCE.md Create a list view that displays a custom view when there are no items. ```swift // With empty view LuminareList( items: $items, selection: $sel, id: \.self ) { Text(item.wrappedValue) } emptyView: { Text("No results") } ``` -------------------------------- ### Configure Luminare Window Appearance Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/window-management.md Shows how to create a Luminare window with custom title bar button configurations, including padding, spacing, and visibility, along with a specified corner radius. ```swift let window = LuminareWindow( titleBarButtonConfiguration: LuminareTitleBarButtonConfiguration( padding: NSEdgeInsets(top: 8, left: 8, bottom: 0, right: 8), spacing: 8, hidden: false ), cornerRadius: 16 ) { MainView() } ``` -------------------------------- ### LuminareCompose Initializer Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/components.md Initializes a LuminareCompose view with custom content and label views. Use this to create compound UI elements. ```swift public init( @ViewBuilder content: @escaping () -> Content, @ViewBuilder label: @escaping () -> Label ) where Label: View, Content: View ``` -------------------------------- ### Present a Modal View Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/QUICK_REFERENCE.md Shows how to present a modal view using the .luminareModal modifier. This is useful for dialogs or temporary content. ```swift @State var showModal = false Button("Show Dialog") { showModal = true } .luminareModal(isPresented: $showModal) { ModalContent() } ``` -------------------------------- ### Configure Compact UI Elements Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/QUICK_REFERENCE.md Adjust padding, list item height, and form spacing to create a more compact user interface. ```swift .environment(\.luminareSectionHorizontalPadding, 8) .environment(\.luminareListItemHeight, 20) .environment(\.luminareFormSpacing, 4) ``` -------------------------------- ### Present a Modal Dialog Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/window-management.md Illustrates how to present a modal dialog using the `.luminareModal` modifier. This requires a state variable to control the presentation and a content view for the modal. ```swift @State var isPresented = false var body: some View { VStack { Button("Show Dialog") { isPresented = true } } .luminareModal(isPresented: $isPresented) { ModalContent() } } ``` -------------------------------- ### RectangleCornerRadii Initializers Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/modifiers-and-extensions.md Initializers for creating RectangleCornerRadii instances. ```APIDOC ## RectangleCornerRadii Initializers ### Description Initializers for creating RectangleCornerRadii instances. ### Method Initializers for struct RectangleCornerRadii ### Parameters #### Initializer 1 - **topLeading** (CGFloat) - Required - **bottomLeading** (CGFloat) - Required - **bottomTrailing** (CGFloat) - Required - **topTrailing** (CGFloat) - Required #### Initializer 2 - **value** (CGFloat) - Required - Applies the same radius to all corners. #### Initializer 3 - **leading** (CGFloat) - Required - Applies radius to leading corners. - **trailing** (CGFloat) - Required - Applies radius to trailing corners. ### Request Example ```swift // Initializer 1 let radii1 = RectangleCornerRadii(topLeading: 10, bottomLeading: 5, bottomTrailing: 10, topTrailing: 5) // Initializer 2 let radii2 = RectangleCornerRadii(15) // All corners are 15 // Initializer 3 let radii3 = RectangleCornerRadii(leading: 20, trailing: 5) ``` ### Response #### Success Response - **RectangleCornerRadii** - An instance of RectangleCornerRadii. #### Response Example ```swift // The result is a RectangleCornerRadii struct instance. ``` ``` -------------------------------- ### LuminareTextField with StringFormatStyle Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/types.md Shows how to use StringFormatStyle with a LuminareTextField for formatted string input. This enables both formatting and parsing of user input. ```swift LuminareTextField( "Username", value: $text, format: StringFormatStyle() ) ``` -------------------------------- ### LuminareTextField - String Text Binding Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/components.md Initializes a LuminareTextField with a string binding for text, an optional prompt, and a label view. This initializer does not use a specific format style. ```APIDOC ## LuminareTextField - String Text Binding ### Description Initializes a LuminareTextField with a string binding for text, an optional prompt, and a label view. This initializer does not use a specific format style. ### Initializer Signature ```swift public init( text: Binding, prompt: Text? = nil, @ViewBuilder label: @escaping () -> Label ) where F == StringFormatStyle ``` ### Parameters #### Path Parameters - **text** (Binding) - Required - String binding (no format) - **prompt** (Text?) - Optional - Placeholder text - **label** (ViewBuilder) - Required - Label view ### Request Example ```swift @State var username: String? var body: some View { LuminareTextField("Username", text: $username, prompt: Text("user@example.com")) } ``` ``` -------------------------------- ### Initialize LuminareSlider with Step Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/QUICK_REFERENCE.md Create a slider with a specified step value for discrete adjustments. ```swift // With step LuminareSlider( value: $value, in: 0...100, step: 5, format: .number, label: { Text("Volume") } ) { Slider(value: $value, in: 0...100, step: 5) } ``` -------------------------------- ### List with Selection Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/INDEX.md Implement a list that supports item selection using a Set. This pattern is useful for managing multiple selections within a list. ```swift @State var items: [Item] @State var selection: Set LuminareList(items: $items, selection: $selection, id: \.id) { item in Text(item.wrappedValue.title) } ``` -------------------------------- ### Environment Appearance Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/types.md Retrieve the NSAppearance from the SwiftUI environment. This is useful for adapting views to system-level appearance settings. ```swift @Environment(\.luminareAppearance) var appearance: NSAppearance? ``` -------------------------------- ### LuminareTextEditor Initializer (String Label) Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/components.md Initializes a multi-line text editor with a string title and a text binding. The title serves as the editor's label. ```swift public init( _ title: some StringProtocol, text: Binding ) where Label == Text ``` -------------------------------- ### Responsive Configuration with Size Classes Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/configuration.md Adjusts LuminareForm padding based on the horizontal size class (compact or regular) to create responsive layouts. ```swift @Environment(\.horizontalSizeClass) var sizeClass var body: some View { LuminareForm { /* ... */ } .environment(\.luminareSectionHorizontalPadding, sizeClass == .compact ? 8 : 16) } ``` -------------------------------- ### Initialize LuminarePicker as Single Row Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/QUICK_REFERENCE.md Create a single-row picker for compact selection options. ```swift // Single row LuminarePicker( compactElements: ["S", "M", "L"], selection: $size ) { Text(text) } ``` -------------------------------- ### Apply Luminare Surface Button Style (SwiftUI) Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/utilities.md Demonstrates how to apply the custom LuminareSurfaceButtonStyle to a SwiftUI Button. ```swift Button("Click") { } // Action .buttonStyle(.luminare) ``` -------------------------------- ### LuminarePicker Configuration Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/QUICK_REFERENCE.md A grid-based picker for selecting options from a collection. Configure the number of columns for the grid layout. ```swift @State var selected = 5 LuminarePicker( elements: Array(1...12), selection: $selected, columns: 4 ) { num in Text("\(num)") } ``` -------------------------------- ### LuminareFormStyle Usage Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/types.md Demonstrates how to apply the Luminare form style to a Form view on macOS 15.0+. ```swift Form { } .formStyle(.luminare) // macOS 15.0+ ``` -------------------------------- ### LuminareList Full Initializer Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/components.md Use this initializer when you need to provide a custom view for the empty state of the list. It requires bindings for items and selection, a key path for item identification, and closures for building item content and the empty view. ```swift public init( items: Binding<[V]>, selection: Binding>, id keyPath: KeyPath, @ViewBuilder content: @escaping (Binding) -> ContentA, @ViewBuilder emptyView: @escaping () -> ContentB ) where V: Hashable, ID: Hashable ``` -------------------------------- ### LuminareCompose Initializer Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/components.md Initializes a LuminareCompose view, which combines a label with styled content. It's a foundational component for creating compound UI elements. ```APIDOC ## LuminareCompose Initializer ### Description Initializes a LuminareCompose view, which combines a label with styled content. It's a foundational component for creating compound UI elements. ### Signature ```swift public init( @ViewBuilder content: @escaping () -> Content, @ViewBuilder label: @escaping () -> Label ) where Label: View, Content: View ``` ### Parameters #### ViewBuilder Parameters - **content** (ViewBuilder) - Required - The primary content view. - **label** (ViewBuilder) - Required - The label or title view. ### Returns A view conforming to the `View` protocol. ``` -------------------------------- ### LuminareWindowResizeAnimator.snap(to:) Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/window-management.md Immediately snaps the window to a target size without any animation. This is useful for instant size adjustments. ```APIDOC ## snap(to:) ### Description Immediately snaps to target size without animation. ### Method Swift Function ### Parameters #### Path Parameters - **size** (CGSize) - Required - Target window size ``` -------------------------------- ### Initialize LuminareTextField with Custom Label Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/QUICK_REFERENCE.md Create a text field for string input using a custom label view, such as a Label with a system image. ```swift // With custom label LuminareTextField(text: $text) { Label("Field", systemImage: "doc") } ``` -------------------------------- ### Swift: Animate Window Size Source: https://github.com/mrkai77/luminare/blob/main/_autodocs/api-reference/window-management.md Use this method to animate the window to a target size with a smooth transition. The target size is specified as a CGSize. ```swift func animate(to size: CGSize) ```