@awes-io/ui 2.143.0 → 2.144.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/assets/css/components/action-card.css +1 -0
  2. package/assets/css/components/action-icon.css +2 -2
  3. package/assets/css/components/alert.css +28 -22
  4. package/assets/css/components/animation.css +14 -0
  5. package/assets/css/components/badge.css +1 -0
  6. package/assets/css/components/banner-text.css +15 -4
  7. package/assets/css/components/card.css +0 -1
  8. package/assets/css/components/content-placeholder.css +4 -3
  9. package/assets/css/components/dropdown.css +20 -7
  10. package/assets/css/components/icon-menu-item.css +12 -7
  11. package/assets/css/components/mobile-menu-nav.css +8 -4
  12. package/assets/css/components/text-field.css +4 -0
  13. package/components/1_atoms/AwActionIcon.vue +11 -2
  14. package/components/1_atoms/AwFlow.vue +26 -11
  15. package/components/1_atoms/AwGrid.vue +11 -3
  16. package/components/1_atoms/AwIcon/AwIcon.vue +5 -3
  17. package/components/1_atoms/AwIcon/AwIconSystemMono.vue +3 -2
  18. package/components/1_atoms/AwInput.vue +2 -2
  19. package/components/1_atoms/AwList.vue +3 -1
  20. package/components/1_atoms/AwRadio.vue +1 -1
  21. package/components/1_atoms/AwSlider.vue +15 -1
  22. package/components/1_atoms/AwTag.vue +6 -1
  23. package/components/2_molecules/AwAlert.vue +63 -42
  24. package/components/2_molecules/AwBadge.vue +1 -1
  25. package/components/2_molecules/AwBannerText.vue +8 -2
  26. package/components/2_molecules/AwDescriptionInput.vue +19 -1
  27. package/components/3_organisms/AwBottomBar.vue +22 -4
  28. package/components/3_organisms/AwSubnav.vue +11 -1
  29. package/components/3_organisms/AwTable/AwTableBuilder.vue +8 -0
  30. package/components/3_organisms/AwTable/_AwTableCellDropdown.vue +6 -1
  31. package/components/3_organisms/AwTable/_AwTableRow.vue +2 -1
  32. package/components/4_pages/AwPage.vue +1 -0
  33. package/components/5_layouts/_AwMenuItemIcon.vue +9 -2
  34. package/components/5_layouts/_AwMobileMenuItem.vue +5 -3
  35. package/components/_config.js +26 -1
  36. package/docs/components/atoms/aw-accordion-fold.md +55 -17
  37. package/docs/components/atoms/aw-action-card-body.md +37 -5
  38. package/docs/components/atoms/aw-action-card.md +47 -11
  39. package/docs/components/atoms/aw-action-icon.md +50 -12
  40. package/docs/components/atoms/aw-card.md +35 -10
  41. package/docs/components/atoms/aw-checkbox.md +176 -0
  42. package/docs/components/atoms/aw-content-placeholder.md +33 -2
  43. package/docs/components/atoms/aw-dock.md +20 -14
  44. package/docs/components/atoms/aw-dropdown.md +72 -22
  45. package/docs/components/atoms/aw-flow.md +71 -23
  46. package/docs/components/atoms/aw-grid.md +30 -12
  47. package/docs/components/atoms/aw-icon-system-color.md +1 -0
  48. package/docs/components/atoms/aw-icon-system-mono.md +1 -0
  49. package/docs/components/atoms/aw-icon.md +3 -3
  50. package/docs/components/atoms/aw-info.md +38 -0
  51. package/docs/components/atoms/aw-input.md +94 -2
  52. package/docs/components/atoms/aw-label.md +62 -9
  53. package/docs/components/atoms/aw-link.md +61 -9
  54. package/docs/components/atoms/aw-list.md +68 -4
  55. package/docs/components/atoms/aw-progress.md +52 -3
  56. package/docs/components/atoms/aw-radio.md +73 -0
  57. package/docs/components/atoms/aw-select-native.md +128 -0
  58. package/docs/components/atoms/aw-slider.md +114 -7
  59. package/docs/components/atoms/aw-switcher.md +77 -0
  60. package/docs/components/atoms/aw-tag.md +67 -3
  61. package/docs/components/atoms/aw-toggler.md +22 -1
  62. package/docs/components/molecules/aw-action-button.md +58 -11
  63. package/docs/components/molecules/aw-alert.md +122 -27
  64. package/docs/components/molecules/aw-badge.md +31 -10
  65. package/docs/components/molecules/aw-banner-text.md +84 -18
  66. package/docs/components/molecules/aw-button-nav.md +65 -0
  67. package/docs/components/molecules/aw-button.md +76 -6
  68. package/docs/components/molecules/aw-description-input.md +63 -6
  69. package/docs/components/molecules/aw-empty-container.md +172 -23
  70. package/docs/components/molecules/aw-island.md +282 -10
  71. package/docs/components/organisms/aw-filter-select.md +14 -0
  72. package/docs/components/pages/aw-page-single.md +47 -0
  73. package/docs/guides/page-patterns/detail-pages.md +89 -26
  74. package/docs/guides/page-patterns/list-pages.md +158 -10
  75. package/docs/reference/colors.md +232 -0
  76. package/docs/reference/icons.md +163 -0
  77. package/docs/reference/troubleshooting.md +19 -0
  78. package/package.json +2 -2
  79. package/store/awesIo.js +11 -0
  80. package/CHANGELOG.md +0 -4544
  81. package/dist/css/aw-icons.css +0 -26
  82. package/dist/fonts/aw-icons.svg +0 -18
  83. package/dist/fonts/aw-icons.ttf +0 -0
  84. package/dist/fonts/aw-icons.woff +0 -0
  85. package/dist/fonts/aw-icons.woff2 +0 -0
  86. package/nuxt/icons.css +0 -26
@@ -47,10 +47,7 @@ The `AwList` component renders an ordered list with optional items array or cust
47
47
  ### With Item Classes
48
48
 
49
49
  ```markup
50
- <AwList
51
- :items="items"
52
- item-class="custom-item-class"
53
- />
50
+ <AwList :items="items" item-class="italic" />
54
51
  ```
55
52
 
56
53
  ## API
@@ -73,6 +70,73 @@ The `AwList` component renders an ordered list with optional items array or cust
73
70
 
74
71
  No events are emitted by this component.
75
72
 
73
+ ## Component Behavior
74
+
75
+ ### List Rendering Modes
76
+
77
+ The component supports two rendering modes:
78
+
79
+ 1. **Items Array Mode**: When `items` prop is provided, items are automatically rendered as `<li>` elements
80
+ 2. **Default Slot Mode**: When using default slot, you provide `<li>` elements directly
81
+
82
+ ### Items Array Rendering
83
+
84
+ - Each item in the `items` array is rendered as a list item (`<li>`)
85
+ - Items can be primitives (strings, numbers) or objects
86
+ - Each item gets a key based on its index
87
+ - The `itemClass` prop is applied to each `<li>` element
88
+ - By default, items are rendered as their string representation
89
+
90
+ ### Item Slot Template
91
+
92
+ When using the `item` slot with the `items` array:
93
+ - **Slot props provided:**
94
+ - `item` - The current item from the array
95
+ - `index` - The zero-based index of the item
96
+ - **Use case:** Custom rendering for each item while maintaining automatic list generation
97
+ - **Example:** Displaying object properties, adding icons, conditional rendering
98
+
99
+ ### Default Slot Override
100
+
101
+ When using the default slot:
102
+ - Completely replaces the automatic item rendering
103
+ - You must provide `<li>` elements yourself
104
+ - The `items` and `itemClass` props are ignored
105
+ - **Use case:** Full control over list structure, nested lists, custom markup
106
+
107
+ ### Item Classes
108
+
109
+ The `itemClass` prop accepts:
110
+ - **String:** Single class name or space-separated classes (e.g., `"italic"`, `"text-sm font-bold"`)
111
+ - **Array:** Array of class names (e.g., `["italic", "text-sm"]`)
112
+ - **Object:** Class object (Vue class binding syntax, e.g., `{ italic: true, bold: isImportant }`)
113
+ - Applied to each `<li>` when using `items` array
114
+ - Ignored when using default slot
115
+ - Useful for applying Tailwind utility classes to all list items
116
+
117
+ ### Structure
118
+
119
+ **With items array:**
120
+ ```
121
+ <ol class="aw-list">
122
+ <li :class="itemClass">
123
+ <slot name="item" :item="item" :index="index">
124
+ {{ item }}
125
+ </slot>
126
+ </li>
127
+ ...
128
+ </ol>
129
+ ```
130
+
131
+ **With default slot:**
132
+ ```
133
+ <ol class="aw-list">
134
+ <slot>
135
+ <!-- Your custom <li> elements -->
136
+ </slot>
137
+ </ol>
138
+ ```
139
+
76
140
  ## Related Components
77
141
 
78
142
  - `AwCard` - Card component that may contain lists
@@ -27,7 +27,7 @@ The `AwProgress` component displays an animated progress bar with customizable c
27
27
  ### With Custom Color
28
28
 
29
29
  ```markup
30
- <AwProgress :progress="50" color="success-500" />
30
+ <AwProgress :progress="50" color="success" />
31
31
  ```
32
32
 
33
33
  ### With Initial Value from URL
@@ -45,7 +45,7 @@ The `AwProgress` component displays an animated progress bar with customizable c
45
45
  |------|-------------|------|----------|---------|
46
46
  | progress | Progress value (0-100) | `Number` | `false` | `0` |
47
47
  | prevValueParam | URL query parameter name for initial value | `String` | `false` | `'prev_progress'` |
48
- | color | Progress bar color | `String` | `false` | `'accent'` |
48
+ | color | Progress bar color - see [Built-in Colors](/reference/colors) | `String` | `false` | `'accent'` |
49
49
 
50
50
  ### Slots
51
51
 
@@ -55,6 +55,55 @@ No slots are available for this component.
55
55
 
56
56
  No events are emitted by this component.
57
57
 
58
+ ## Component Behavior
59
+
60
+ ### Progress Value
61
+
62
+ - Progress value is automatically clamped between 0 and 100
63
+ - Values below 0 are treated as 0
64
+ - Values above 100 are treated as 100
65
+ - The progress ratio is calculated as `value / 100` with 4 decimal precision
66
+
67
+ ### Animation
68
+
69
+ The component uses anime.js for smooth progress animations:
70
+ - **Duration:** 1000ms (1 second)
71
+ - **Easing:** easeOutCirc - Creates a smooth deceleration effect
72
+ - **Trigger:** Automatically animates when `progress` prop changes
73
+ - **Initial animation:** Runs on component mount
74
+
75
+ ### Initial Value from URL
76
+
77
+ The component can read an initial progress value from URL query parameters:
78
+ - **Parameter name:** Configurable via `prevValueParam` prop (default: `prev_progress`)
79
+ - **Use case:** Preserving progress state across page navigation
80
+ - **Example:** URL `/page?prev_progress=30` will start at 30% and animate to the `progress` prop value
81
+
82
+ ### Color System
83
+
84
+ - Uses CSS custom property `--color` for the progress bar fill
85
+ - Color is converted using the `toColor` utility function
86
+ - Supports all semantic colors (accent, success, info, warning, error)
87
+ - Supports mono scale and custom colors
88
+ - Default color is `accent`
89
+
90
+ ### CSS Variables
91
+
92
+ The component sets two CSS custom properties:
93
+ - `--progress` - The progress ratio (0.0000 to 1.0000)
94
+ - `--color` - The progress bar fill color
95
+
96
+ ### Structure
97
+
98
+ ```
99
+ <div class="aw-progress" :style="{
100
+ --progress: progressRatio,
101
+ --color: fgColor
102
+ }"></div>
103
+ ```
104
+
105
+ The actual progress bar styling is handled by CSS using these custom properties.
106
+
58
107
  ## Related Components
59
108
 
60
109
  - `AwButton` - Button component that may show loading/progress
@@ -66,5 +115,5 @@ No events are emitted by this component.
66
115
  - Progress value is clamped between 0 and 100
67
116
  - Animation duration is 1000ms with easeOutCirc easing
68
117
  - Initial value can be read from URL query parameters
69
- - Color supports theme color names (e.g., 'accent', 'success-500')
118
+ - Color supports theme color names (e.g., 'accent', 'success')
70
119
 
@@ -93,6 +93,79 @@ All standard HTML radio attributes are supported via `$attrs` (e.g., `disabled`,
93
93
  |------|---------|-------------|
94
94
  | change | `value` | Emitted when radio is selected |
95
95
 
96
+ ## Component Behavior
97
+
98
+ ### Radio Group Logic
99
+
100
+ - Radio buttons work as a group when they share the same `v-model` binding
101
+ - Only one radio in a group can be selected at a time
102
+ - When a radio is selected, its `value` is emitted via the `change` event
103
+ - The `checked` prop (v-model binding) is compared to each radio's `value` to determine selection
104
+ - Selection is determined by strict equality: `checked === value`
105
+
106
+ ### Value Types
107
+
108
+ The component supports three value types:
109
+ - **String:** Most common, e.g., `value="option1"`
110
+ - **Number:** For numeric choices, e.g., `:value="1"` (use `:value` binding)
111
+ - **Boolean:** For yes/no choices, e.g., `:value="true"` (use `:value` binding)
112
+
113
+ **Important:** When using number or boolean values, use the `:value` binding syntax (v-bind) instead of plain `value` attribute.
114
+
115
+ ### Model Binding
116
+
117
+ - Uses `v-model` with custom model definition
118
+ - Model prop: `checked` - The currently selected value
119
+ - Model event: `change` - Emitted when selection changes
120
+ - Usage: `v-model="selectedValue"`
121
+
122
+ ### Label Rendering
123
+
124
+ - Label is optional but recommended for accessibility
125
+ - If `label` prop is provided, renders a `<label>` element linked to the radio input
126
+ - Label slot receives: `{ label, value, isChecked }`
127
+ - Clicking the label toggles the radio (native browser behavior)
128
+
129
+ ### Error Handling
130
+
131
+ The component extends the ErrorMixin:
132
+ - Supports `error` prop for error messages
133
+ - Shows error tooltip on hover when error is present
134
+ - Automatically clears error on selection change
135
+ - Error state adds visual styling via `has-error` class
136
+
137
+ ### Field Attributes
138
+
139
+ Extends FieldMixin for consistent field behavior:
140
+ - Supports standard HTML radio attributes via `$attrs`
141
+ - Common attributes: `disabled`, `required`, `name`
142
+ - Auto-generates unique ID if not provided
143
+ - Links label to input via `for`/`id` attributes
144
+
145
+ ### Accessibility
146
+
147
+ - Proper label-input association via `id` and `for` attributes
148
+ - Error messages linked via `aria-describedby`
149
+ - Supports all native radio button keyboard navigation
150
+ - Disabled state properly communicated to screen readers
151
+
152
+ ### Structure
153
+
154
+ ```
155
+ <div class="aw-switch-field is-radio" :class="{ 'has-error': hasError }">
156
+ <input
157
+ type="radio"
158
+ class="aw-switch-field__element"
159
+ :id="id"
160
+ :value="value"
161
+ :checked="isChecked"
162
+ />
163
+ <label class="aw-switch-field__label" :for="id">
164
+ <slot name="label">{{ label }}</slot>
165
+ </label>
166
+ </div>
167
+ ```
168
+
96
169
  ## Related Components
97
170
 
98
171
  - `AwCheckbox` - Checkbox component
@@ -89,6 +89,134 @@ The `AwSelectNative` component is a styled wrapper around the native HTML select
89
89
  |------|---------|-------------|
90
90
  | input | `value` | Emitted when selection changes |
91
91
 
92
+ ## Component Behavior
93
+
94
+ ### Option Handling
95
+
96
+ The component supports two types of options:
97
+
98
+ #### String Arrays
99
+ ```javascript
100
+ options: ['Option 1', 'Option 2', 'Option 3']
101
+ ```
102
+ - Simple string arrays where each string is both the label and value
103
+ - Ideal for basic dropdowns with simple text options
104
+
105
+ #### Object Arrays
106
+ ```javascript
107
+ options: [
108
+ { id: 1, name: 'Option 1' },
109
+ { id: 2, name: 'Option 2' }
110
+ ]
111
+ ```
112
+ - Requires `optionLabel` prop to specify which property to display
113
+ - Requires `trackBy` prop to specify which property to use as value
114
+ - Supports nested properties using dot notation (e.g., `'user.name'`)
115
+
116
+ ### Option Label and TrackBy
117
+
118
+ Both `optionLabel` and `trackBy` props accept:
119
+
120
+ **String (property path):**
121
+ ```markup
122
+ <AwSelectNative
123
+ :options="users"
124
+ option-label="name"
125
+ track-by="id"
126
+ />
127
+ ```
128
+
129
+ **Function:**
130
+ ```markup
131
+ <AwSelectNative
132
+ :options="users"
133
+ :option-label="user => `${user.firstName} ${user.lastName}`"
134
+ :track-by="user => user.id"
135
+ />
136
+ ```
137
+
138
+ **Nested properties:**
139
+ ```markup
140
+ <AwSelectNative
141
+ :options="items"
142
+ option-label="user.profile.name"
143
+ track-by="user.id"
144
+ />
145
+ ```
146
+
147
+ ### Disabled Options
148
+
149
+ The `optionDisabled` prop accepts a function that determines if an option should be disabled:
150
+
151
+ ```javascript
152
+ optionDisabled(option) {
153
+ return !option.available || option.stock === 0
154
+ }
155
+ ```
156
+
157
+ Disabled options appear in the dropdown but cannot be selected.
158
+
159
+ ### Label Behavior
160
+
161
+ - Label appears as floating label inside the select field
162
+ - When option is selected, label moves to top position (filled state)
163
+ - Required indicator (`*`) shown when field has `required` attribute
164
+ - Label slot provides full customization
165
+
166
+ ### Prefix and Postfix
167
+
168
+ - **Prefix:** Displayed before the select dropdown (e.g., "https://")
169
+ - **Postfix:** Displayed after the select dropdown (e.g., ".com")
170
+ - Both support text or custom slot content
171
+ - Useful for adding context or units to the selection
172
+
173
+ ### Size Variants
174
+
175
+ - **sm:** Smaller padding (p-2) - compact dropdowns
176
+ - **md:** Medium padding (p-3) - default, standard size
177
+
178
+ ### Error Handling
179
+
180
+ Extends ErrorMixin for error management:
181
+ - Shows error tooltip on hover when error is present
182
+ - Error state adds visual styling via `has-error` class
183
+ - Error automatically clears when selection changes
184
+ - Error message displayed via tooltip
185
+
186
+ ### Field States
187
+
188
+ The component applies CSS classes based on state:
189
+ - `is-filled` - When a valid option is selected
190
+ - `has-label` - When label prop is provided
191
+ - `has-error` - When error is present
192
+ - `is-disabled` - When disabled attribute is set
193
+ - `has-prefix` - When prefix is provided
194
+ - `has-postfix` - When postfix is provided
195
+
196
+ ### Native Select Element
197
+
198
+ - Uses native HTML `<select>` element for better mobile support
199
+ - Inherits all standard HTML select attributes via `$attrs`
200
+ - Native mobile picker UI on iOS and Android
201
+ - Better accessibility with native keyboard navigation
202
+ - No custom dropdown UI to maintain
203
+
204
+ ### Structure
205
+
206
+ ```
207
+ <div class="aw-text-field is-select">
208
+ <div class="aw-text-field__prefix">Prefix</div>
209
+ <div class="relative">
210
+ <select class="aw-text-field__element">
211
+ <option>...</option>
212
+ </select>
213
+ <label class="aw-text-field__label">Label</label>
214
+ <div class="aw-text-field__caret">▼</div>
215
+ </div>
216
+ <div class="aw-text-field__postfix">Postfix</div>
217
+ </div>
218
+ ```
219
+
92
220
  ## Related Components
93
221
 
94
222
  - `AwSelect` - Advanced select component with search and custom options
@@ -21,23 +21,31 @@ The `AwSlider` component provides a horizontal scrollable container with drag su
21
21
  ### Basic Example
22
22
 
23
23
  ```markup
24
- <AwSlider>
25
- <div class="flex gap-4">
26
- <div>Item 1</div>
27
- <div>Item 2</div>
28
- <div>Item 3</div>
29
- </div>
24
+ <AwSlider :gap="4">
25
+ <div>Item 1</div>
26
+ <div>Item 2</div>
27
+ <div>Item 3</div>
30
28
  </AwSlider>
31
29
  ```
32
30
 
33
31
  ### Custom Tag
34
32
 
35
33
  ```markup
36
- <AwSlider tag="section">
34
+ <AwSlider tag="section" :gap="3">
37
35
  <div>Scrollable content</div>
38
36
  </AwSlider>
39
37
  ```
40
38
 
39
+ ### With Gap Spacing
40
+
41
+ ```markup
42
+ <AwSlider :gap="6">
43
+ <AwCard v-for="n in 5" :key="n" class="flex-shrink-0">
44
+ Card {{ n }}
45
+ </AwCard>
46
+ </AwSlider>
47
+ ```
48
+
41
49
  ## API
42
50
 
43
51
  ### Props
@@ -45,6 +53,7 @@ The `AwSlider` component provides a horizontal scrollable container with drag su
45
53
  | Name | Description | Type | Required | Default |
46
54
  |------|-------------|------|----------|---------|
47
55
  | tag | HTML tag for container | `String` | `false` | `'div'` |
56
+ | gap | Gap between items (1-8) | `Number` | `false` | `0` |
48
57
 
49
58
  ### Slots
50
59
 
@@ -64,6 +73,104 @@ The `AwSlider` component provides a horizontal scrollable container with drag su
64
73
  |------|-----------|-------------|
65
74
  | scrollTo | `element` | Scrolls to the specified child element |
66
75
 
76
+ ## Component Behavior
77
+
78
+ ### Scrolling Mechanism
79
+
80
+ The component provides multiple ways to scroll:
81
+ - **Mouse drag:** Click and drag horizontally to scroll
82
+ - **Touch drag:** Touch and swipe horizontally on mobile devices
83
+ - **Native scroll:** Use scrollbar or trackpad/mouse wheel
84
+ - **Programmatic:** Use the `scrollTo(element)` method
85
+
86
+ ### Drag Detection
87
+
88
+ The component intelligently distinguishes between clicks and drags:
89
+ - **Click threshold (time):** 300ms - Movement within this time may be treated as click
90
+ - **Click threshold (distance):** 5px - Movement less than this may be treated as click
91
+ - **Drag detection:** If movement exceeds either threshold, it's treated as a drag
92
+ - **Click prevention:** During drag operations, click events are prevented to avoid unintended actions
93
+
94
+ ### Shadow Indicators
95
+
96
+ Visual feedback for scrollable content:
97
+ - **Left shadow:** Appears when content can be scrolled to the left (opacity: 0 when at start)
98
+ - **Right shadow:** Appears when content can be scrolled to the right (opacity: 0 when at end)
99
+ - **Responsive:** Shadows automatically update as user scrolls or content changes
100
+ - **Overscroll handling:** Shadows properly handle browser overscroll behavior
101
+
102
+ ### Resize Handling
103
+
104
+ The component automatically adapts to size changes:
105
+ - **Window resize listener:** Listens to window resize events
106
+ - **Debounced update:** Waits 300ms after resize before recalculating dimensions
107
+ - **Dimension recalculation:** Updates scroll width, container width, and scroll position
108
+ - **Resize event:** Emits `resized` event after recalculation completes
109
+ - **Border correction:** Ensures scroll position stays within valid bounds after resize
110
+
111
+ ### Programmatic Scrolling
112
+
113
+ Use the `scrollTo` method to scroll to specific child elements:
114
+
115
+ ```javascript
116
+ // Scroll to a specific element
117
+ this.$refs.slider.scrollTo(this.$refs.targetElement)
118
+ ```
119
+
120
+ **How it works:**
121
+ - Calculates the cumulative width of all child elements before the target
122
+ - Includes margins and borders in width calculation
123
+ - Scrolls to position the target element at the start of the visible area
124
+ - Respects scroll boundaries (won't scroll beyond max scroll position)
125
+
126
+ ### Dimension Calculation
127
+
128
+ The component calculates child element dimensions including:
129
+ - **scrollWidth:** Full content width including overflow
130
+ - **margins:** Left and right margins
131
+ - **borders:** Left and right borders
132
+ - Uses `getComputedStyle` for accurate measurements
133
+
134
+ ### Mouse Move State
135
+
136
+ - **movedByMouse flag:** Tracks whether scrolling is currently controlled by mouse/touch
137
+ - **Event listeners:** Dynamically adds/removes mousemove and mouseup listeners
138
+ - **Performance:** Only active during drag operations to minimize overhead
139
+ - **Clean up:** Properly removes listeners on component destroy
140
+
141
+ ### Touch Support
142
+
143
+ - **Touch events:** Fully supports touch gestures on mobile devices
144
+ - **pageX detection:** Automatically detects touch coordinates from touch events
145
+ - **Native mobile scroll:** Works seamlessly with native mobile scrolling behavior
146
+
147
+ ### Gap Spacing
148
+
149
+ The component includes a built-in `gap` prop for spacing between items:
150
+ - **Supported values:** 1, 2, 3, 4, 5, 6, 8 (maps to Tailwind gap classes)
151
+ - **Default:** 0 (no gap)
152
+ - **Usage:** `:gap="4"` applies `gap-4` class to the scroller
153
+ - Eliminates need for wrapper flex containers with gap classes
154
+
155
+ ### Content Requirements
156
+
157
+ For proper functionality:
158
+ - Items should have `flex-shrink-0` class to prevent shrinking
159
+ - Total content width should exceed container width to enable scrolling
160
+ - Use the `gap` prop for spacing between items instead of manual flex wrappers
161
+
162
+ ### Structure
163
+
164
+ ```
165
+ <div class="aw-slider">
166
+ <span class="aw-slider__scroller">
167
+ <slot /> <!-- Your scrollable content -->
168
+ </span>
169
+ <span class="aw-slider__shadow aw-slider__shadow_left" />
170
+ <span class="aw-slider__shadow aw-slider__shadow_right" />
171
+ </div>
172
+ ```
173
+
67
174
  ## Related Components
68
175
 
69
176
  - `AwFlow` - Flow layout component
@@ -98,6 +98,83 @@ All props from `AwCheckbox` are also supported.
98
98
  |------|---------|-------------|
99
99
  | change | `value` | Emitted when switch state changes |
100
100
 
101
+ ## Component Behavior
102
+
103
+ ### Toggle Interaction
104
+
105
+ The component supports two methods of toggling:
106
+
107
+ **Click to toggle:**
108
+ - Single click/tap anywhere on the switch toggles the state
109
+ - Works on the toggle circle, background, or label
110
+
111
+ **Drag to toggle:**
112
+ - Click/touch and drag horizontally to switch states
113
+ - Drag threshold is 5 pixels to prevent accidental toggles
114
+ - Visual feedback shows state change during drag
115
+ - Works with both mouse and touch events
116
+
117
+ ### Drag Detection
118
+
119
+ The component intelligently distinguishes between clicks and drags:
120
+ - **Threshold:** 5 pixels of horizontal movement
121
+ - **Click:** Movement less than threshold triggers immediate toggle
122
+ - **Drag:** Movement exceeds threshold, switch follows drag direction
123
+ - **Right drag (unchecked → checked):** Turns switch on when dragging right
124
+ - **Left drag (checked → unchecked):** Turns switch off when dragging left
125
+
126
+ ### Icon Display
127
+
128
+ Icons are displayed based on size and props:
129
+ - **sm size:** Icons are never shown (too small)
130
+ - **md size:** Icons shown at 12px, can be placed outside or inside toggle circle
131
+ - **lg size:** Icons shown at 22px, can be placed outside or inside toggle circle
132
+
133
+ **Icon placement:**
134
+ - `iconPlaceIn={false}` (default): Icons appear outside the toggle circle (active on left, inactive on right)
135
+ - `iconPlaceIn={true}`: Single icon appears inside the moving toggle circle
136
+
137
+ **Icon props:**
138
+ - `icon`: Icon shown when switch is active/on
139
+ - `offIcon`: Icon shown when switch is inactive/off (defaults to `icon` value if not specified)
140
+ - `hideIcon`: Completely hides all icons regardless of size
141
+
142
+ For a complete list of available icons, see [Built-in Icons](/reference/icons).
143
+
144
+ ### Color System
145
+
146
+ Background colors adapt to switch state:
147
+ - **Active (checked):** Uses `activeColor` prop (default: `'success'`)
148
+ - **Inactive (unchecked):** Uses `inactiveColor` prop (default: transparent/gray)
149
+ - Colors accept any valid color from the AwesCode UI color system
150
+ - Common active colors: `success`, `info`, `warning`, `error`, `accent`
151
+
152
+ For a complete list of available colors, see [Built-in Colors](/reference/colors).
153
+
154
+ ### State Management
155
+
156
+ Extends `AwCheckbox` for state handling:
157
+ - Supports `v-model` for two-way binding
158
+ - `checked` prop accepts Boolean, Array, or Number
159
+ - `value` prop specifies the value emitted when checked
160
+ - Internal state tracks both checkbox state and drag position
161
+ - Watch updates internal state when external `checked` prop changes
162
+
163
+ ### Event Listeners
164
+
165
+ The component dynamically manages event listeners:
166
+ - **Mouse/touch down:** Initiates drag detection, adds move/up listeners
167
+ - **Mouse/touch move:** Tracks drag position, updates visual state
168
+ - **Mouse/touch up:** Completes toggle action, removes listeners
169
+ - **Cleanup:** All listeners properly removed on component destroy
170
+
171
+ ### Touch Support
172
+
173
+ Full touch gesture support for mobile devices:
174
+ - Touch events (touchstart, touchmove, touchend) handled separately from mouse
175
+ - Uses `screenX` for accurate position tracking across devices
176
+ - Prevents unwanted interactions during drag operations
177
+
101
178
  ## Related Components
102
179
 
103
180
  - `AwCheckbox` - Checkbox component (extended by switcher)