solid-tom-ui 1.0.11 → 1.0.15

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 (119) hide show
  1. package/README.md +246 -246
  2. package/dist/README.md +246 -246
  3. package/dist/components/avatar/avatar.js.map +1 -1
  4. package/dist/components/badge/badge.js.map +1 -1
  5. package/dist/components/breadcrumb/breadcrumb.js.map +1 -1
  6. package/dist/components/button/button.js.map +1 -1
  7. package/dist/components/carousel/carousel.js.map +1 -1
  8. package/dist/components/chat-bubble/chatBubble.js.map +1 -1
  9. package/dist/components/checkbox/checkbox.js.map +1 -1
  10. package/dist/components/collapse/collapse.js.map +1 -1
  11. package/dist/components/context-menu/context-menu.js.map +1 -1
  12. package/dist/components/context-menu/context-menu.store.js.map +1 -1
  13. package/dist/components/divider/divider.js.map +1 -1
  14. package/dist/components/dropdown/dropdown.js.map +1 -1
  15. package/dist/components/dropdown/dropdown.store.js.map +1 -1
  16. package/dist/components/float-button/float-button.js.map +1 -1
  17. package/dist/components/hover-3d-image/hover-3d-image.js.map +1 -1
  18. package/dist/components/image-preview/image-preview.js.map +1 -1
  19. package/dist/components/input/input.js.map +1 -1
  20. package/dist/components/input/input.utils.js.map +1 -1
  21. package/dist/components/input/variants/input-color.js.map +1 -1
  22. package/dist/components/input/variants/input-date.js.map +1 -1
  23. package/dist/components/input/variants/input-number.d.ts.map +1 -1
  24. package/dist/components/input/variants/input-number.js +1 -1
  25. package/dist/components/input/variants/input-number.js.map +1 -1
  26. package/dist/components/input/variants/input-otp.js.map +1 -1
  27. package/dist/components/input/variants/input-password.js.map +1 -1
  28. package/dist/components/input/variants/input-radio.js.map +1 -1
  29. package/dist/components/input/variants/input-range.js.map +1 -1
  30. package/dist/components/input/variants/input-text.d.ts.map +1 -1
  31. package/dist/components/input/variants/input-text.js +1 -1
  32. package/dist/components/input/variants/input-text.js.map +1 -1
  33. package/dist/components/input/variants/input-textarea.js.map +1 -1
  34. package/dist/components/loading/loading.js.map +1 -1
  35. package/dist/components/mansory/mansory.js.map +1 -1
  36. package/dist/components/menu/menu.js.map +1 -1
  37. package/dist/components/modal/modal.js.map +1 -1
  38. package/dist/components/modal/modalContext.js.map +1 -1
  39. package/dist/components/pagination/pagination.js.map +1 -1
  40. package/dist/components/progress-bar/progress-bar.js.map +1 -1
  41. package/dist/components/qr-code/qr-code.js.map +1 -1
  42. package/dist/components/select/select.js +1 -1
  43. package/dist/components/select/select.js.map +1 -1
  44. package/dist/components/select-zone/select-zone.js.map +1 -1
  45. package/dist/components/skeleton/skeleton.js.map +1 -1
  46. package/dist/components/slider/slider.js.map +1 -1
  47. package/dist/components/splitter/splitter.js.map +1 -1
  48. package/dist/components/steps/steps.js.map +1 -1
  49. package/dist/components/swap/swap.js.map +1 -1
  50. package/dist/components/switch/switch.js.map +1 -1
  51. package/dist/components/tab/tab.js.map +1 -1
  52. package/dist/components/table/table.js.map +1 -1
  53. package/dist/components/timeline/timeline.js.map +1 -1
  54. package/dist/components/toast/icons/ErrorIcon.js.map +1 -1
  55. package/dist/components/toast/icons/IconCircle.js.map +1 -1
  56. package/dist/components/toast/icons/InfoIcon.js.map +1 -1
  57. package/dist/components/toast/icons/LoaderIcon.js.map +1 -1
  58. package/dist/components/toast/icons/SuccessIcon.js.map +1 -1
  59. package/dist/components/toast/icons/WarningIcon.js.map +1 -1
  60. package/dist/components/toast/toast.js.map +1 -1
  61. package/dist/components/toast/toast.store.js.map +1 -1
  62. package/dist/components/tooltip/tooltip.js.map +1 -1
  63. package/dist/components/tour/tour.js.map +1 -1
  64. package/dist/components/upload/upload.js.map +1 -1
  65. package/dist/components/z-index/z-index.context.js.map +1 -1
  66. package/dist/components/z-index/z-index.js.map +1 -1
  67. package/dist/components/z-index/z-index.store.js.map +1 -1
  68. package/dist/components/z-index/z-index.types.js.map +1 -1
  69. package/dist/package.json +1 -1
  70. package/dist/skill/avatar.skill.md.txt +255 -255
  71. package/dist/skill/badge.skill.md.txt +223 -223
  72. package/dist/skill/breadcrumb.skill.md.txt +177 -177
  73. package/dist/skill/button.skill.md.txt +198 -198
  74. package/dist/skill/carousel.skill.md.txt +406 -406
  75. package/dist/skill/chat-bubble.skill.md.txt +342 -342
  76. package/dist/skill/checkbox.skill.md.txt +326 -326
  77. package/dist/skill/code-preview.skill.md.txt +240 -240
  78. package/dist/skill/collapse.skill.md.txt +329 -329
  79. package/dist/skill/context-menu.skill.md.txt +233 -233
  80. package/dist/skill/diff.skill.md.txt +244 -244
  81. package/dist/skill/divider.skill.md.txt +151 -151
  82. package/dist/skill/doc.skill.md.txt +191 -191
  83. package/dist/skill/drawer.skill.md.txt +157 -157
  84. package/dist/skill/dropdown.skill.md.txt +198 -198
  85. package/dist/skill/float-button.skill.md.txt +315 -315
  86. package/dist/skill/hover-3d-image.skill.md.txt +120 -120
  87. package/dist/skill/iframe.skill.md.txt +114 -114
  88. package/dist/skill/image-preview.skill.md.txt +162 -162
  89. package/dist/skill/indicator.skill.md.txt +60 -60
  90. package/dist/skill/input.skill.md.txt +489 -489
  91. package/dist/skill/loading.skill.md.txt +127 -127
  92. package/dist/skill/menu.skill.md.txt +476 -476
  93. package/dist/skill/modal.skill.md.txt +359 -359
  94. package/dist/skill/pagination.skill.md.txt +405 -405
  95. package/dist/skill/progress-bar.skill.md.txt +207 -207
  96. package/dist/skill/qr-code.skill.md.txt +136 -136
  97. package/dist/skill/rating.skill.md.txt +167 -167
  98. package/dist/skill/select-zone.skill.md.txt +93 -93
  99. package/dist/skill/select.skill.md.txt +663 -663
  100. package/dist/skill/skeleton.skill.md.txt +192 -192
  101. package/dist/skill/slider.skill.md.txt +404 -404
  102. package/dist/skill/splitter.skill.md.txt +411 -411
  103. package/dist/skill/steps.skill.md.txt +264 -264
  104. package/dist/skill/swap.skill.md.txt +139 -139
  105. package/dist/skill/switch.skill.md.txt +191 -191
  106. package/dist/skill/tab.skill.md.txt +484 -484
  107. package/dist/skill/table.example.header.md.txt +666 -666
  108. package/dist/skill/table.skill.md.txt +1407 -1407
  109. package/dist/skill/text-rotate.skill.md.txt +186 -186
  110. package/dist/skill/timeline.skill.md.txt +247 -247
  111. package/dist/skill/toast.skill.md.txt +531 -531
  112. package/dist/skill/tooltip.skill.md.txt +222 -222
  113. package/dist/skill/tour.skill.md.txt +156 -156
  114. package/dist/skill/upload.skill.md.txt +358 -358
  115. package/dist/utils/cn.js.map +1 -1
  116. package/dist/utils/element-tracker.js.map +1 -1
  117. package/dist/utils/helper.js.map +1 -1
  118. package/dist/utils/hoc.js.map +1 -1
  119. package/package.json +132 -133
@@ -1,136 +1,136 @@
1
- ## COMPONENT IDENTITY
2
- - **Import**: `import { QrCode } from 'solid-tom-ui';`
3
- - **Export**: `QrCode` (named export)
4
- - **Framework**: SolidJS
5
- - **Purpose**: Renders a QR code onto an HTML `<canvas>` using the `qrcode` library; supports custom colors, logo overlay, and four status overlays (active, loading, expired, scanned)
6
-
7
- ## When to use
8
-
9
- - Sharing URLs or text as a scannable QR code
10
- - Payment or authentication flows that need status feedback (loading, expired, scanned)
11
- - Branded QR codes with a center logo
12
-
13
- ---
14
-
15
- ## Prop Reference
16
-
17
- | Prop | Type | Default | Description |
18
- |---------------|-----------------------------------------|----------------|----------------------------------------------------------|
19
- | `value` | `string` | — | **Required.** Text / URL to encode. |
20
- | `size` | `number` | `160` | Canvas size in px (square). |
21
- | `color` | `string` (hex) | `'#000000'` | Foreground dot color. |
22
- | `bgColor` | `string` (hex) | `'#ffffff'` | Background fill color. |
23
- | `errorLevel` | `'L' \| 'M' \| 'Q' \| 'H'` | `'M'` | Error correction level. Use `'H'` when adding a logo. |
24
- | `logo` | `QrCodeLogo` | — | Optional center logo config (see below). |
25
- | `status` | `'active' \| 'loading' \| 'expired' \| 'scanned'` | `'active'` | Controls overlay state. |
26
- | `expiredText` | `string` | `'QR code expired'` | Text shown in the expired overlay. |
27
- | `onRefresh` | `() => void` | — | Called when user clicks the refresh button (expired). |
28
- | `accentColor` | `BaseColorProps` | `'primary'` | Color of the loading / expired overlay icon + text. |
29
- | `class` | `Partial<Record<SlotName, string>>` | — | Per-slot class overrides (see Slots below). |
30
-
31
- ### QrCodeLogo
32
-
33
- ```ts
34
- interface QrCodeLogo {
35
- src: string; // Image URL
36
- width?: number; // Logo width in px (default: 20% of size)
37
- height?: number; // Logo height in px (default: same as width)
38
- padding?: number; // Background padding (default: 4)
39
- background?: string; // Background color (default: '#ffffff')
40
- borderRadius?: number; // Corner radius (default: 4)
41
- }
42
- ```
43
-
44
- ### Slots (`class` prop)
45
-
46
- | Slot | Element |
47
- |----------------|----------------------------------|
48
- | `root` | Outer wrapper `<div>` |
49
- | `canvas` | `<canvas>` element |
50
- | `overlay` | Status overlay `<div>` |
51
- | `overlayIcon` | Icon / button inside overlay |
52
- | `overlayText` | Text label inside expired overlay|
53
-
54
- ---
55
-
56
- ## Usage Patterns
57
-
58
- ### Basic
59
-
60
- ```tsx
61
- <QrCode value="https://solidjs.com" />
62
- ```
63
-
64
- ### Custom size and colors
65
-
66
- ```tsx
67
- <QrCode
68
- value="https://example.com"
69
- size={200}
70
- color="#7c3aed"
71
- bgColor="#ede9fe"
72
- />
73
- ```
74
-
75
- ### With logo (always use errorLevel="H")
76
-
77
- ```tsx
78
- <QrCode
79
- value="https://example.com"
80
- size={180}
81
- errorLevel="H"
82
- logo={{
83
- src: '/logo.svg',
84
- width: 36,
85
- height: 36,
86
- padding: 6,
87
- borderRadius: 8,
88
- }}
89
- />
90
- ```
91
-
92
- ### Status: loading
93
-
94
- ```tsx
95
- <QrCode value="https://example.com" status="loading" accentColor="info" />
96
- ```
97
-
98
- ### Status: expired with refresh handler
99
-
100
- ```tsx
101
- const [status, setStatus] = createSignal<QrCodeStatus>('expired');
102
-
103
- <QrCode
104
- value="https://example.com"
105
- status={status()}
106
- expiredText="Scan timed out"
107
- onRefresh={() => {
108
- setStatus('loading');
109
- fetchNewQrValue().then(() => setStatus('active'));
110
- }}
111
- />
112
- ```
113
-
114
- ### Status: scanned
115
-
116
- ```tsx
117
- <QrCode value="https://example.com" status="scanned" />
118
- ```
119
-
120
- ### Reactive value (re-renders automatically)
121
-
122
- ```tsx
123
- const [url, setUrl] = createSignal('https://solidjs.com');
124
-
125
- <QrCode value={url()} size={160} />
126
- <input value={url()} onInput={e => setUrl(e.currentTarget.value)} />
127
- ```
128
-
129
- ---
130
-
131
- ## Known Gotchas
132
-
133
- - **Logo requires `errorLevel="H"`** — lower levels don't have enough redundancy to recover from the obscured center modules.
134
- - **Cross-origin logos** — ensure the logo image server sends `Access-Control-Allow-Origin` headers; otherwise the canvas `drawImage` call will taint the canvas and throw a security error.
135
- - **Empty value** — pass `' '` (a space) instead of `''` to avoid a qrcode library error when the value is empty.
136
- - **Canvas pixel density** — the canvas renders at 1× DPR by default. For retina displays you can scale `size` up and use CSS to constrain the rendered size.
1
+ ## COMPONENT IDENTITY
2
+ - **Import**: `import { QrCode } from 'solid-tom-ui';`
3
+ - **Export**: `QrCode` (named export)
4
+ - **Framework**: SolidJS
5
+ - **Purpose**: Renders a QR code onto an HTML `<canvas>` using the `qrcode` library; supports custom colors, logo overlay, and four status overlays (active, loading, expired, scanned)
6
+
7
+ ## When to use
8
+
9
+ - Sharing URLs or text as a scannable QR code
10
+ - Payment or authentication flows that need status feedback (loading, expired, scanned)
11
+ - Branded QR codes with a center logo
12
+
13
+ ---
14
+
15
+ ## Prop Reference
16
+
17
+ | Prop | Type | Default | Description |
18
+ |---------------|-----------------------------------------|----------------|----------------------------------------------------------|
19
+ | `value` | `string` | — | **Required.** Text / URL to encode. |
20
+ | `size` | `number` | `160` | Canvas size in px (square). |
21
+ | `color` | `string` (hex) | `'#000000'` | Foreground dot color. |
22
+ | `bgColor` | `string` (hex) | `'#ffffff'` | Background fill color. |
23
+ | `errorLevel` | `'L' \| 'M' \| 'Q' \| 'H'` | `'M'` | Error correction level. Use `'H'` when adding a logo. |
24
+ | `logo` | `QrCodeLogo` | — | Optional center logo config (see below). |
25
+ | `status` | `'active' \| 'loading' \| 'expired' \| 'scanned'` | `'active'` | Controls overlay state. |
26
+ | `expiredText` | `string` | `'QR code expired'` | Text shown in the expired overlay. |
27
+ | `onRefresh` | `() => void` | — | Called when user clicks the refresh button (expired). |
28
+ | `accentColor` | `BaseColorProps` | `'primary'` | Color of the loading / expired overlay icon + text. |
29
+ | `class` | `Partial<Record<SlotName, string>>` | — | Per-slot class overrides (see Slots below). |
30
+
31
+ ### QrCodeLogo
32
+
33
+ ```ts
34
+ interface QrCodeLogo {
35
+ src: string; // Image URL
36
+ width?: number; // Logo width in px (default: 20% of size)
37
+ height?: number; // Logo height in px (default: same as width)
38
+ padding?: number; // Background padding (default: 4)
39
+ background?: string; // Background color (default: '#ffffff')
40
+ borderRadius?: number; // Corner radius (default: 4)
41
+ }
42
+ ```
43
+
44
+ ### Slots (`class` prop)
45
+
46
+ | Slot | Element |
47
+ |----------------|----------------------------------|
48
+ | `root` | Outer wrapper `<div>` |
49
+ | `canvas` | `<canvas>` element |
50
+ | `overlay` | Status overlay `<div>` |
51
+ | `overlayIcon` | Icon / button inside overlay |
52
+ | `overlayText` | Text label inside expired overlay|
53
+
54
+ ---
55
+
56
+ ## Usage Patterns
57
+
58
+ ### Basic
59
+
60
+ ```tsx
61
+ <QrCode value="https://solidjs.com" />
62
+ ```
63
+
64
+ ### Custom size and colors
65
+
66
+ ```tsx
67
+ <QrCode
68
+ value="https://example.com"
69
+ size={200}
70
+ color="#7c3aed"
71
+ bgColor="#ede9fe"
72
+ />
73
+ ```
74
+
75
+ ### With logo (always use errorLevel="H")
76
+
77
+ ```tsx
78
+ <QrCode
79
+ value="https://example.com"
80
+ size={180}
81
+ errorLevel="H"
82
+ logo={{
83
+ src: '/logo.svg',
84
+ width: 36,
85
+ height: 36,
86
+ padding: 6,
87
+ borderRadius: 8,
88
+ }}
89
+ />
90
+ ```
91
+
92
+ ### Status: loading
93
+
94
+ ```tsx
95
+ <QrCode value="https://example.com" status="loading" accentColor="info" />
96
+ ```
97
+
98
+ ### Status: expired with refresh handler
99
+
100
+ ```tsx
101
+ const [status, setStatus] = createSignal<QrCodeStatus>('expired');
102
+
103
+ <QrCode
104
+ value="https://example.com"
105
+ status={status()}
106
+ expiredText="Scan timed out"
107
+ onRefresh={() => {
108
+ setStatus('loading');
109
+ fetchNewQrValue().then(() => setStatus('active'));
110
+ }}
111
+ />
112
+ ```
113
+
114
+ ### Status: scanned
115
+
116
+ ```tsx
117
+ <QrCode value="https://example.com" status="scanned" />
118
+ ```
119
+
120
+ ### Reactive value (re-renders automatically)
121
+
122
+ ```tsx
123
+ const [url, setUrl] = createSignal('https://solidjs.com');
124
+
125
+ <QrCode value={url()} size={160} />
126
+ <input value={url()} onInput={e => setUrl(e.currentTarget.value)} />
127
+ ```
128
+
129
+ ---
130
+
131
+ ## Known Gotchas
132
+
133
+ - **Logo requires `errorLevel="H"`** — lower levels don't have enough redundancy to recover from the obscured center modules.
134
+ - **Cross-origin logos** — ensure the logo image server sends `Access-Control-Allow-Origin` headers; otherwise the canvas `drawImage` call will taint the canvas and throw a security error.
135
+ - **Empty value** — pass `' '` (a space) instead of `''` to avoid a qrcode library error when the value is empty.
136
+ - **Canvas pixel density** — the canvas renders at 1× DPR by default. For retina displays you can scale `size` up and use CSS to constrain the rendered size.
@@ -1,167 +1,167 @@
1
- ## COMPONENT IDENTITY
2
- - **Import**: `import { Rating } from 'solid-tom-ui';`
3
- - **Export**: `Rating` (named export), `RatingProps`, `RatingSize`, `RatingMask` (type exports)
4
- - **Framework**: SolidJS
5
- - **Purpose**: Star/heart rating component built on DaisyUI's `mask` utility; supports controlled and uncontrolled modes, half-star steps, multiple shapes, and read-only display
6
-
7
- ## Props
8
-
9
- | Prop | Type | Default | Description |
10
- | -------------- | --------------------------------- | ------------ | ------------------------------------------------------------------------ |
11
- | `value` | `number` | — | Controlled value. When set, component is in controlled mode |
12
- | `defaultValue` | `number` | — | Initial value for uncontrolled mode |
13
- | `count` | `number` | `5` | Total number of items |
14
- | `color` | `BaseColorProps \| string` | *(per mask)* | Item color. Accepts a `BaseColorProps` token or a Tailwind `bg-*` class |
15
- | `size` | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | `'md'` | Size of each item |
16
- | `mask` | `'star' \| 'star-2' \| 'heart'` | `'star-2'` | Shape of each item |
17
- | `readOnly` | `boolean` | `false` | Disables interaction; renders `<div>` elements instead of `<input>` |
18
- | `half` | `boolean` | `false` | Enables half-step increments (0.5, 1.0, 1.5 …) |
19
- | `allowClear` | `boolean` | `true` | Adds a hidden reset input; clicking the selected item resets to 0 |
20
- | `gap` | `boolean` | *(per mask)* | Adds `gap-1` between items. Defaults to `true` for `heart`, `false` for stars |
21
- | `onChange` | `(value: number) => void` | — | Called when the user selects a value |
22
- | `class` | `string` | — | Extra class on the wrapper `<div>` |
23
- | `ariaLabel` | `string` | — | Prefix for each item's `aria-label` (e.g. `"Product rating"` → `"Product rating 3 star"`) |
24
-
25
- All other `HTMLDivElement` attributes are forwarded to the wrapper (except `onChange`, which is intercepted).
26
-
27
- ## Class Slots
28
-
29
- `Rating` is a single-element component — `class` appends to the root wrapper `<div>`. No named sub-element slots.
30
-
31
- > **CSS encoding**: internal CSS classes use short encoded names (e.g. `rt01`, `rt02`) per project convention.
32
-
33
- > **Unique IDs**: each `Rating` instance generates a unique `name` attribute for its radio inputs using `createUniqueId()` from `solid-js` — multiple instances on the same page won't interfere.
34
-
35
- ## Controlled vs Uncontrolled
36
-
37
- ```tsx
38
- // Uncontrolled — component manages its own state
39
- <Rating defaultValue={3} />
40
-
41
- // Controlled — you manage state
42
- const [value, setValue] = createSignal(3);
43
- <Rating value={value()} onChange={setValue} />
44
- ```
45
-
46
- When `value` is provided, the internal signal syncs to it via `createEffect`. When `value` is `undefined`, the component is uncontrolled.
47
-
48
- ## Default Colors per Mask
49
-
50
- When `color` is not specified, each mask has a built-in default color:
51
-
52
- | Mask | Default color |
53
- | --------- | ------------------ |
54
- | `star` | `bg-yellow-400` |
55
- | `star-2` | `bg-orange-400` |
56
- | `heart` | `bg-red-400` |
57
-
58
- ## Examples
59
-
60
- ### Basic (uncontrolled)
61
-
62
- ```tsx
63
- <Rating defaultValue={3} />
64
- <Rating defaultValue={4} mask="star" />
65
- <Rating defaultValue={2} mask="heart" />
66
- ```
67
-
68
- ### Custom count
69
-
70
- ```tsx
71
- <Rating count={3} defaultValue={2} />
72
- <Rating count={7} defaultValue={4} />
73
- <Rating count={10} defaultValue={6} />
74
- ```
75
-
76
- ### Sizes
77
-
78
- ```tsx
79
- <Rating size="xs" defaultValue={3} />
80
- <Rating size="sm" defaultValue={3} />
81
- <Rating size="md" defaultValue={3} /> {/* default */}
82
- <Rating size="lg" defaultValue={3} />
83
- <Rating size="xl" defaultValue={3} />
84
- ```
85
-
86
- ### Custom color
87
-
88
- `color` accepts either a `BaseColorProps` token or a Tailwind `bg-*` class:
89
-
90
- ```tsx
91
- {/* Tailwind color class */}
92
- <Rating color="bg-orange-400" defaultValue={4} />
93
- <Rating color="bg-blue-400" defaultValue={4} />
94
-
95
- {/* DaisyUI token */}
96
- <Rating color="primary" defaultValue={4} />
97
- <Rating color="success" defaultValue={4} />
98
- <Rating color="error" defaultValue={4} />
99
- ```
100
-
101
- ### Half-star mode
102
-
103
- When `half={true}`, values step by 0.5. Each item is split into two halves.
104
-
105
- ```tsx
106
- <Rating half defaultValue={2.5} color="bg-orange-400" />
107
- <Rating half defaultValue={3.5} color="bg-yellow-400" size="lg" />
108
- ```
109
-
110
- ### Read-only
111
-
112
- Read-only renders `<div>` elements instead of `<input>` radio buttons — no interactivity, no tab stops.
113
-
114
- ```tsx
115
- <Rating readOnly value={3} />
116
- <Rating readOnly value={4.5} half color="bg-orange-400" size="lg" />
117
- ```
118
-
119
- ### Allow clear (reset to 0)
120
-
121
- When `allowClear={true}` (default), a hidden radio at value 0 is inserted. Re-clicking the currently selected star resets the rating to 0.
122
-
123
- ```tsx
124
- <Rating allowClear defaultValue={3} /> {/* can reset */}
125
- <Rating allowClear={false} defaultValue={3} /> {/* cannot reset */}
126
- ```
127
-
128
- ### Gap between items
129
-
130
- `gap` defaults to `true` for `heart`, `false` for `star`/`star-2`. Override explicitly:
131
-
132
- ```tsx
133
- <Rating mask="heart" gap={false} defaultValue={3} /> {/* no gap */}
134
- <Rating mask="star-2" gap={true} defaultValue={3} /> {/* force gap */}
135
- ```
136
-
137
- ### Controlled with signal
138
-
139
- ```tsx
140
- const [rating, setRating] = createSignal(3);
141
-
142
- <Rating value={rating()} onChange={setRating} color="bg-yellow-400" size="lg" />
143
- <p>Current: {rating()}</p>
144
- ```
145
-
146
- ## Render Behavior
147
-
148
- - **Interactive** (`readOnly=false`): renders `<input type="radio">` elements inside a `<div class="rating ...">`. Each input has `name` scoped to the instance via an auto-incrementing UID.
149
- - **Read-only** (`readOnly=true`): renders `<div class="mask ...">` elements. No form inputs, no keyboard interaction.
150
- - **`allowClear`**: inserts an extra hidden `<input class="rating-hidden">` as the first radio at value 0.
151
-
152
- ## Accessibility
153
-
154
- - Each interactive input gets an `aria-label` like `"3 star"` or `"2.5 stars"`.
155
- - Provide `ariaLabel` to prefix all labels: `ariaLabel="Product rating"` → `"Product rating 3 star"`.
156
- - Read-only items use `aria-current="true"` on the active item.
157
- - The component renders as a radio group with a unique `name` per instance.
158
-
159
- ## Common Mistakes
160
-
161
- | Mistake | Fix |
162
- | --- | --- |
163
- | Passing a Tailwind color name like `"orange-400"` to `color` | Pass the full class: `color="bg-orange-400"` |
164
- | Expecting `onChange` to fire in read-only mode | `readOnly` silently blocks all changes — remove `readOnly` |
165
- | Setting `half` but passing an integer `defaultValue` | Valid — integers work in half mode (e.g., `defaultValue={3}`) |
166
- | Controlled component not responding to `onChange` | Ensure you update the signal: `onChange={val => setValue(val)}` |
167
- | `allowClear` not resetting | Works only when re-clicking the already-selected star; `allowClear={false}` disables it |
1
+ ## COMPONENT IDENTITY
2
+ - **Import**: `import { Rating } from 'solid-tom-ui';`
3
+ - **Export**: `Rating` (named export), `RatingProps`, `RatingSize`, `RatingMask` (type exports)
4
+ - **Framework**: SolidJS
5
+ - **Purpose**: Star/heart rating component built on DaisyUI's `mask` utility; supports controlled and uncontrolled modes, half-star steps, multiple shapes, and read-only display
6
+
7
+ ## Props
8
+
9
+ | Prop | Type | Default | Description |
10
+ | -------------- | --------------------------------- | ------------ | ------------------------------------------------------------------------ |
11
+ | `value` | `number` | — | Controlled value. When set, component is in controlled mode |
12
+ | `defaultValue` | `number` | — | Initial value for uncontrolled mode |
13
+ | `count` | `number` | `5` | Total number of items |
14
+ | `color` | `BaseColorProps \| string` | *(per mask)* | Item color. Accepts a `BaseColorProps` token or a Tailwind `bg-*` class |
15
+ | `size` | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | `'md'` | Size of each item |
16
+ | `mask` | `'star' \| 'star-2' \| 'heart'` | `'star-2'` | Shape of each item |
17
+ | `readOnly` | `boolean` | `false` | Disables interaction; renders `<div>` elements instead of `<input>` |
18
+ | `half` | `boolean` | `false` | Enables half-step increments (0.5, 1.0, 1.5 …) |
19
+ | `allowClear` | `boolean` | `true` | Adds a hidden reset input; clicking the selected item resets to 0 |
20
+ | `gap` | `boolean` | *(per mask)* | Adds `gap-1` between items. Defaults to `true` for `heart`, `false` for stars |
21
+ | `onChange` | `(value: number) => void` | — | Called when the user selects a value |
22
+ | `class` | `string` | — | Extra class on the wrapper `<div>` |
23
+ | `ariaLabel` | `string` | — | Prefix for each item's `aria-label` (e.g. `"Product rating"` → `"Product rating 3 star"`) |
24
+
25
+ All other `HTMLDivElement` attributes are forwarded to the wrapper (except `onChange`, which is intercepted).
26
+
27
+ ## Class Slots
28
+
29
+ `Rating` is a single-element component — `class` appends to the root wrapper `<div>`. No named sub-element slots.
30
+
31
+ > **CSS encoding**: internal CSS classes use short encoded names (e.g. `rt01`, `rt02`) per project convention.
32
+
33
+ > **Unique IDs**: each `Rating` instance generates a unique `name` attribute for its radio inputs using `createUniqueId()` from `solid-js` — multiple instances on the same page won't interfere.
34
+
35
+ ## Controlled vs Uncontrolled
36
+
37
+ ```tsx
38
+ // Uncontrolled — component manages its own state
39
+ <Rating defaultValue={3} />
40
+
41
+ // Controlled — you manage state
42
+ const [value, setValue] = createSignal(3);
43
+ <Rating value={value()} onChange={setValue} />
44
+ ```
45
+
46
+ When `value` is provided, the internal signal syncs to it via `createEffect`. When `value` is `undefined`, the component is uncontrolled.
47
+
48
+ ## Default Colors per Mask
49
+
50
+ When `color` is not specified, each mask has a built-in default color:
51
+
52
+ | Mask | Default color |
53
+ | --------- | ------------------ |
54
+ | `star` | `bg-yellow-400` |
55
+ | `star-2` | `bg-orange-400` |
56
+ | `heart` | `bg-red-400` |
57
+
58
+ ## Examples
59
+
60
+ ### Basic (uncontrolled)
61
+
62
+ ```tsx
63
+ <Rating defaultValue={3} />
64
+ <Rating defaultValue={4} mask="star" />
65
+ <Rating defaultValue={2} mask="heart" />
66
+ ```
67
+
68
+ ### Custom count
69
+
70
+ ```tsx
71
+ <Rating count={3} defaultValue={2} />
72
+ <Rating count={7} defaultValue={4} />
73
+ <Rating count={10} defaultValue={6} />
74
+ ```
75
+
76
+ ### Sizes
77
+
78
+ ```tsx
79
+ <Rating size="xs" defaultValue={3} />
80
+ <Rating size="sm" defaultValue={3} />
81
+ <Rating size="md" defaultValue={3} /> {/* default */}
82
+ <Rating size="lg" defaultValue={3} />
83
+ <Rating size="xl" defaultValue={3} />
84
+ ```
85
+
86
+ ### Custom color
87
+
88
+ `color` accepts either a `BaseColorProps` token or a Tailwind `bg-*` class:
89
+
90
+ ```tsx
91
+ {/* Tailwind color class */}
92
+ <Rating color="bg-orange-400" defaultValue={4} />
93
+ <Rating color="bg-blue-400" defaultValue={4} />
94
+
95
+ {/* DaisyUI token */}
96
+ <Rating color="primary" defaultValue={4} />
97
+ <Rating color="success" defaultValue={4} />
98
+ <Rating color="error" defaultValue={4} />
99
+ ```
100
+
101
+ ### Half-star mode
102
+
103
+ When `half={true}`, values step by 0.5. Each item is split into two halves.
104
+
105
+ ```tsx
106
+ <Rating half defaultValue={2.5} color="bg-orange-400" />
107
+ <Rating half defaultValue={3.5} color="bg-yellow-400" size="lg" />
108
+ ```
109
+
110
+ ### Read-only
111
+
112
+ Read-only renders `<div>` elements instead of `<input>` radio buttons — no interactivity, no tab stops.
113
+
114
+ ```tsx
115
+ <Rating readOnly value={3} />
116
+ <Rating readOnly value={4.5} half color="bg-orange-400" size="lg" />
117
+ ```
118
+
119
+ ### Allow clear (reset to 0)
120
+
121
+ When `allowClear={true}` (default), a hidden radio at value 0 is inserted. Re-clicking the currently selected star resets the rating to 0.
122
+
123
+ ```tsx
124
+ <Rating allowClear defaultValue={3} /> {/* can reset */}
125
+ <Rating allowClear={false} defaultValue={3} /> {/* cannot reset */}
126
+ ```
127
+
128
+ ### Gap between items
129
+
130
+ `gap` defaults to `true` for `heart`, `false` for `star`/`star-2`. Override explicitly:
131
+
132
+ ```tsx
133
+ <Rating mask="heart" gap={false} defaultValue={3} /> {/* no gap */}
134
+ <Rating mask="star-2" gap={true} defaultValue={3} /> {/* force gap */}
135
+ ```
136
+
137
+ ### Controlled with signal
138
+
139
+ ```tsx
140
+ const [rating, setRating] = createSignal(3);
141
+
142
+ <Rating value={rating()} onChange={setRating} color="bg-yellow-400" size="lg" />
143
+ <p>Current: {rating()}</p>
144
+ ```
145
+
146
+ ## Render Behavior
147
+
148
+ - **Interactive** (`readOnly=false`): renders `<input type="radio">` elements inside a `<div class="rating ...">`. Each input has `name` scoped to the instance via an auto-incrementing UID.
149
+ - **Read-only** (`readOnly=true`): renders `<div class="mask ...">` elements. No form inputs, no keyboard interaction.
150
+ - **`allowClear`**: inserts an extra hidden `<input class="rating-hidden">` as the first radio at value 0.
151
+
152
+ ## Accessibility
153
+
154
+ - Each interactive input gets an `aria-label` like `"3 star"` or `"2.5 stars"`.
155
+ - Provide `ariaLabel` to prefix all labels: `ariaLabel="Product rating"` → `"Product rating 3 star"`.
156
+ - Read-only items use `aria-current="true"` on the active item.
157
+ - The component renders as a radio group with a unique `name` per instance.
158
+
159
+ ## Common Mistakes
160
+
161
+ | Mistake | Fix |
162
+ | --- | --- |
163
+ | Passing a Tailwind color name like `"orange-400"` to `color` | Pass the full class: `color="bg-orange-400"` |
164
+ | Expecting `onChange` to fire in read-only mode | `readOnly` silently blocks all changes — remove `readOnly` |
165
+ | Setting `half` but passing an integer `defaultValue` | Valid — integers work in half mode (e.g., `defaultValue={3}`) |
166
+ | Controlled component not responding to `onChange` | Ensure you update the signal: `onChange={val => setValue(val)}` |
167
+ | `allowClear` not resetting | Works only when re-clicking the already-selected star; `allowClear={false}` disables it |