@cloudflare/kumo 2.0.0 → 2.0.1
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.
- package/CHANGELOG.md +9 -0
- package/ai/component-registry.json +10 -17
- package/ai/component-registry.md +15 -15
- package/dist/.build-complete +1 -1
- package/dist/blocks-source/resource-list/resource-list.tsx +1 -1
- package/dist/chunks/{autocomplete-cs3fwy6lwzlyirpq.js → autocomplete-48aq0d244bs2e8zv.js} +3 -3
- package/dist/chunks/{autocomplete-cs3fwy6lwzlyirpq.js.map → autocomplete-48aq0d244bs2e8zv.js.map} +1 -1
- package/dist/chunks/{checkbox-eren6w2csum1xghg.js → checkbox-hvxfvhtx1qjo2mww.js} +2 -2
- package/dist/chunks/{checkbox-eren6w2csum1xghg.js.map → checkbox-hvxfvhtx1qjo2mww.js.map} +1 -1
- package/dist/chunks/{clipboard-text-f9q753udny1uyxr5.js → clipboard-text-hswydzx3iql369sd.js} +2 -2
- package/dist/chunks/{clipboard-text-f9q753udny1uyxr5.js.map → clipboard-text-hswydzx3iql369sd.js.map} +1 -1
- package/dist/chunks/{code-cz0w1y5z4h29a9eg.js → code-f9v1ikwhekqw274q.js} +4 -4
- package/dist/chunks/{code-cz0w1y5z4h29a9eg.js.map → code-f9v1ikwhekqw274q.js.map} +1 -1
- package/dist/chunks/{combobox-n9qht9h9ag6kh5sn.js → combobox-fq36ye0hstote16x.js} +10 -10
- package/dist/chunks/{combobox-n9qht9h9ag6kh5sn.js.map → combobox-fq36ye0hstote16x.js.map} +1 -1
- package/dist/chunks/{command-palette-gk9m34ymp2b3hfc5.js → command-palette-md65owxt5hv4rt9r.js} +142 -142
- package/dist/chunks/{command-palette-gk9m34ymp2b3hfc5.js.map → command-palette-md65owxt5hv4rt9r.js.map} +1 -1
- package/dist/chunks/{date-range-picker-c9wnx9tbwohai7jy.js → date-range-picker-o8uyril1kogvhoei.js} +19 -19
- package/dist/chunks/{date-range-picker-c9wnx9tbwohai7jy.js.map → date-range-picker-o8uyril1kogvhoei.js.map} +1 -1
- package/dist/chunks/{dialog-94v7wiz7j3in6528.js → dialog-k3f1fbam6nt96k8x.js} +2 -2
- package/dist/chunks/{dialog-94v7wiz7j3in6528.js.map → dialog-k3f1fbam6nt96k8x.js.map} +1 -1
- package/dist/chunks/{empty-kpymw59thjf2ip8g.js → empty-b82oer7npkhtkx7k.js} +6 -6
- package/dist/chunks/{empty-kpymw59thjf2ip8g.js.map → empty-b82oer7npkhtkx7k.js.map} +1 -1
- package/dist/chunks/{field-lnj619xpe8zjd26r.js → field-c0wf94plit2gci59.js} +2 -2
- package/dist/chunks/{field-lnj619xpe8zjd26r.js.map → field-c0wf94plit2gci59.js.map} +1 -1
- package/dist/chunks/{input-area-h8xbqturegdfm1mi.js → input-area-bkyzu6f7gsck479h.js} +3 -3
- package/dist/chunks/{input-area-h8xbqturegdfm1mi.js.map → input-area-bkyzu6f7gsck479h.js.map} +1 -1
- package/dist/chunks/{input-group-dh4pg8p20rh4mdi0.js → input-group-bidweffa0zyg8gt0.js} +3 -3
- package/dist/chunks/{input-group-dh4pg8p20rh4mdi0.js.map → input-group-bidweffa0zyg8gt0.js.map} +1 -1
- package/dist/chunks/{input-lpa5fc75tgrraafv.js → input-ncfowphv81yq7fyy.js} +18 -18
- package/dist/chunks/input-ncfowphv81yq7fyy.js.map +1 -0
- package/dist/chunks/{label-be8m7qzlakzig2sl.js → label-c3h9i3y4wiccelt7.js} +22 -22
- package/dist/chunks/{label-be8m7qzlakzig2sl.js.map → label-c3h9i3y4wiccelt7.js.map} +1 -1
- package/dist/chunks/{layer-card-hvivdirwwnyq88wa.js → layer-card-ikm31xemd70w3lru.js} +2 -2
- package/dist/chunks/{layer-card-hvivdirwwnyq88wa.js.map → layer-card-ikm31xemd70w3lru.js.map} +1 -1
- package/dist/chunks/{meter-bqetlujwg8gm2u7m.js → meter-n34a7yb8c3rim26i.js} +2 -2
- package/dist/chunks/{meter-bqetlujwg8gm2u7m.js.map → meter-n34a7yb8c3rim26i.js.map} +1 -1
- package/dist/chunks/{pagination-ho8zesqfyp6ckmrl.js → pagination-jb3mncivbwsoi1se.js} +40 -40
- package/dist/chunks/{pagination-ho8zesqfyp6ckmrl.js.map → pagination-jb3mncivbwsoi1se.js.map} +1 -1
- package/dist/chunks/{select-kpfbib9l8xrrmzpz.js → select-g261chvosodu22i8.js} +3 -3
- package/dist/chunks/{select-kpfbib9l8xrrmzpz.js.map → select-g261chvosodu22i8.js.map} +1 -1
- package/dist/chunks/{sensitive-input-i1upqytzaw2pus8v.js → sensitive-input-cijagk551mesdtk4.js} +3 -3
- package/dist/chunks/{sensitive-input-i1upqytzaw2pus8v.js.map → sensitive-input-cijagk551mesdtk4.js.map} +1 -1
- package/dist/chunks/{sidebar-kh37grvfxto14ek6.js → sidebar-kb9kykqfgy5yzqwr.js} +4 -4
- package/dist/chunks/{sidebar-kh37grvfxto14ek6.js.map → sidebar-kb9kykqfgy5yzqwr.js.map} +1 -1
- package/dist/chunks/{surface-o63tktyrifcjejyb.js → surface-k0e8mq1x00b7i8r6.js} +2 -2
- package/dist/chunks/{surface-o63tktyrifcjejyb.js.map → surface-k0e8mq1x00b7i8r6.js.map} +1 -1
- package/dist/chunks/{switch-lclhiplr9zqf73tj.js → switch-jdfsr3j3oa1qxegw.js} +2 -2
- package/dist/chunks/{switch-lclhiplr9zqf73tj.js.map → switch-jdfsr3j3oa1qxegw.js.map} +1 -1
- package/dist/chunks/{table-fyy8gl875yyevqs3.js → table-iudje0lva0z68jto.js} +2 -2
- package/dist/chunks/{table-fyy8gl875yyevqs3.js.map → table-iudje0lva0z68jto.js.map} +1 -1
- package/dist/chunks/{tabs-jywwt8ebjqjkux75.js → tabs-mkhf1uemgr3ij0ps.js} +3 -3
- package/dist/chunks/{tabs-jywwt8ebjqjkux75.js.map → tabs-mkhf1uemgr3ij0ps.js.map} +1 -1
- package/dist/chunks/toast-h573o0tc7tefivk2.js.map +1 -1
- package/dist/code.js +30 -30
- package/dist/code.js.map +1 -1
- package/dist/components/autocomplete.js +1 -1
- package/dist/components/checkbox.js +1 -1
- package/dist/components/clipboard-text.js +1 -1
- package/dist/components/code.js +1 -1
- package/dist/components/combobox.js +1 -1
- package/dist/components/command-palette.js +1 -1
- package/dist/components/date-range-picker.js +1 -1
- package/dist/components/dialog.js +1 -1
- package/dist/components/empty.js +1 -1
- package/dist/components/field.js +1 -1
- package/dist/components/input-group.js +1 -1
- package/dist/components/input.js +3 -3
- package/dist/components/label.js +1 -1
- package/dist/components/layer-card.js +1 -1
- package/dist/components/meter.js +1 -1
- package/dist/components/pagination.js +1 -1
- package/dist/components/select.js +1 -1
- package/dist/components/sensitive-input.js +1 -1
- package/dist/components/sidebar.js +1 -1
- package/dist/components/surface.js +1 -1
- package/dist/components/switch.js +1 -1
- package/dist/components/table.js +1 -1
- package/dist/components/tabs.js +1 -1
- package/dist/index.js +26 -26
- package/dist/scripts/theme-generator/config.js +11 -4
- package/dist/scripts/theme-generator/config.js.map +1 -1
- package/dist/src/components/code/code.d.ts +2 -2
- package/dist/src/components/toast/toast.d.ts +1 -1
- package/dist/src/components/toast/toast.d.ts.map +1 -1
- package/dist/styles/kumo-standalone.css +1 -1
- package/dist/styles/theme-kumo.css +8 -8
- package/package.json +1 -1
- package/scripts/component-registry/metadata.ts +1 -1
- package/scripts/theme-generator/config.ts +9 -9
- package/dist/chunks/input-lpa5fc75tgrraafv.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @cloudflare/kumo
|
|
2
2
|
|
|
3
|
+
## 2.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e53bd68: Rebalanced semantic text token usage to improve hierarchy and consistency across components, docs, and generated Figma output.
|
|
8
|
+
- Updated theme token definitions so `text-kumo-strong` represents high-emphasis text and `text-kumo-inactive` is lighter/inactive in both light and dark modes.
|
|
9
|
+
- Migrated affected UI surfaces from `text-kumo-strong` to `text-kumo-subtle` where content is supportive metadata, labels, or secondary text.
|
|
10
|
+
- Synced token usage in docs and Figma code generators with the updated semantic text mapping.
|
|
11
|
+
|
|
3
12
|
## 2.0.0
|
|
4
13
|
|
|
5
14
|
### Major Changes
|
|
@@ -2181,7 +2181,7 @@
|
|
|
2181
2181
|
"colors": [
|
|
2182
2182
|
"bg-kumo-base",
|
|
2183
2183
|
"border-kumo-fill",
|
|
2184
|
-
"text-kumo-
|
|
2184
|
+
"text-kumo-subtle"
|
|
2185
2185
|
],
|
|
2186
2186
|
"subComponents": {
|
|
2187
2187
|
"Block": {
|
|
@@ -2201,7 +2201,7 @@
|
|
|
2201
2201
|
},
|
|
2202
2202
|
"styling": {
|
|
2203
2203
|
"baseTokens": [
|
|
2204
|
-
"text-kumo-
|
|
2204
|
+
"text-kumo-subtle"
|
|
2205
2205
|
],
|
|
2206
2206
|
"typography": {
|
|
2207
2207
|
"fontFamily": "font-mono",
|
|
@@ -2421,7 +2421,6 @@
|
|
|
2421
2421
|
"ring-kumo-hairline",
|
|
2422
2422
|
"ring-kumo-line",
|
|
2423
2423
|
"text-kumo-default",
|
|
2424
|
-
"text-kumo-strong",
|
|
2425
2424
|
"text-kumo-subtle"
|
|
2426
2425
|
],
|
|
2427
2426
|
"subComponents": {
|
|
@@ -2561,7 +2560,6 @@
|
|
|
2561
2560
|
"ring-kumo-brand",
|
|
2562
2561
|
"ring-kumo-hairline",
|
|
2563
2562
|
"text-kumo-default",
|
|
2564
|
-
"text-kumo-strong",
|
|
2565
2563
|
"text-kumo-subtle"
|
|
2566
2564
|
]
|
|
2567
2565
|
},
|
|
@@ -2588,7 +2586,7 @@
|
|
|
2588
2586
|
"<div className=\"flex flex-col gap-4\">\n <DatePicker\n mode=\"range\"\n selected={range}\n onChange={setRange}\n min={3}\n max={7}\n footer={\n <span className=\"text-xs text-kumo-subtle\">Select 3-7 nights</span>\n }\n />\n </div>",
|
|
2589
2587
|
"<Popover>\n <Popover.Trigger\n render={<Button variant=\"outline\" icon={CalendarDotsIcon} />}\n >\n {date ? date.toLocaleDateString() : \"Pick a date\"}\n </Popover.Trigger>\n <Popover.Content className=\"p-3\">\n <DatePicker mode=\"single\" selected={date} onChange={setDate} />\n </Popover.Content>\n </Popover>",
|
|
2590
2588
|
"<Popover>\n <Popover.Trigger\n render={<Button variant=\"outline\" icon={CalendarDotsIcon} />}\n >\n {formatRange()}\n </Popover.Trigger>\n <Popover.Content className=\"p-3\">\n <DatePicker\n mode=\"range\"\n selected={range}\n onChange={setRange}\n numberOfMonths={2}\n />\n </Popover.Content>\n </Popover>",
|
|
2591
|
-
"<Popover>\n <Popover.Trigger\n render={<Button variant=\"outline\" icon={CalendarDotsIcon} />}\n >\n {formatRange()}\n </Popover.Trigger>\n <Popover.Content className=\"p-0\">\n <div className=\"flex\">\n <div className=\"flex flex-col gap-1 border-r border-kumo-hairline p-2 text-sm\">\n {presets.map((preset) => {\n const isActive = isPresetActive(preset);\n return (\n <button\n key={preset.label}\n type=\"button\"\n onClick={() => handlePresetClick(preset)}\n className={`rounded-md px-3 py-1.5 text-left whitespace-nowrap ${\n isActive\n ? \"bg-kumo-bg-inverse text-kumo-text-inverse\"\n : \"text-kumo-
|
|
2589
|
+
"<Popover>\n <Popover.Trigger\n render={<Button variant=\"outline\" icon={CalendarDotsIcon} />}\n >\n {formatRange()}\n </Popover.Trigger>\n <Popover.Content className=\"p-0\">\n <div className=\"flex\">\n <div className=\"flex flex-col gap-1 border-r border-kumo-hairline p-2 text-sm\">\n {presets.map((preset) => {\n const isActive = isPresetActive(preset);\n return (\n <button\n key={preset.label}\n type=\"button\"\n onClick={() => handlePresetClick(preset)}\n className={`rounded-md px-3 py-1.5 text-left whitespace-nowrap ${\n isActive\n ? \"bg-kumo-bg-inverse text-kumo-text-inverse\"\n : \"text-kumo-subtle hover:bg-kumo-control\"\n }`}\n >\n {preset.label}\n </button>\n );\n })}\n </div>\n <div className=\"p-3\">\n <DatePicker\n mode=\"range\"\n selected={range}\n onChange={setRange}\n month={month}\n onMonthChange={setMonth}\n numberOfMonths={2}\n />\n </div>\n </div>\n </Popover.Content>\n </Popover>",
|
|
2592
2590
|
"<DatePicker\n mode=\"multiple\"\n selected={dates}\n onChange={setDates}\n max={maxDays}\n disabled={unavailableDates}\n fixedWeeks\n footer={\n <p className=\"text-xs text-kumo-subtle pt-2 w-full\">\n {selectedCount}/{maxDays} days selected. Grayed dates are unavailable.\n </p>\n }\n />"
|
|
2593
2591
|
],
|
|
2594
2592
|
"colors": [
|
|
@@ -2670,7 +2668,6 @@
|
|
|
2670
2668
|
"ring-kumo-focus",
|
|
2671
2669
|
"text-kumo-default",
|
|
2672
2670
|
"text-kumo-inverse",
|
|
2673
|
-
"text-kumo-strong",
|
|
2674
2671
|
"text-kumo-subtle"
|
|
2675
2672
|
],
|
|
2676
2673
|
"styling": {
|
|
@@ -3082,7 +3079,7 @@
|
|
|
3082
3079
|
"text-kumo-brand",
|
|
3083
3080
|
"text-kumo-default",
|
|
3084
3081
|
"text-kumo-inactive",
|
|
3085
|
-
"text-kumo-
|
|
3082
|
+
"text-kumo-subtle",
|
|
3086
3083
|
"text-kumo-success"
|
|
3087
3084
|
]
|
|
3088
3085
|
},
|
|
@@ -3342,8 +3339,7 @@
|
|
|
3342
3339
|
"ring-kumo-danger",
|
|
3343
3340
|
"ring-kumo-focus",
|
|
3344
3341
|
"ring-kumo-line",
|
|
3345
|
-
"text-kumo-default"
|
|
3346
|
-
"text-kumo-subtle"
|
|
3342
|
+
"text-kumo-default"
|
|
3347
3343
|
],
|
|
3348
3344
|
"styling": {
|
|
3349
3345
|
"dimensions": {
|
|
@@ -3610,7 +3606,7 @@
|
|
|
3610
3606
|
],
|
|
3611
3607
|
"colors": [
|
|
3612
3608
|
"text-kumo-default",
|
|
3613
|
-
"text-kumo-
|
|
3609
|
+
"text-kumo-subtle"
|
|
3614
3610
|
]
|
|
3615
3611
|
},
|
|
3616
3612
|
"LayerCard": {
|
|
@@ -3658,7 +3654,7 @@
|
|
|
3658
3654
|
"ring-kumo-fill",
|
|
3659
3655
|
"ring-kumo-hairline",
|
|
3660
3656
|
"ring-kumo-line",
|
|
3661
|
-
"text-kumo-
|
|
3657
|
+
"text-kumo-subtle"
|
|
3662
3658
|
],
|
|
3663
3659
|
"subComponents": {
|
|
3664
3660
|
"Primary": {
|
|
@@ -3960,7 +3956,7 @@
|
|
|
3960
3956
|
"colors": [
|
|
3961
3957
|
"bg-kumo-fill",
|
|
3962
3958
|
"text-kumo-default",
|
|
3963
|
-
"text-kumo-
|
|
3959
|
+
"text-kumo-subtle"
|
|
3964
3960
|
]
|
|
3965
3961
|
},
|
|
3966
3962
|
"Pagination": {
|
|
@@ -4040,7 +4036,7 @@
|
|
|
4040
4036
|
"colors": [
|
|
4041
4037
|
"border-kumo-hairline",
|
|
4042
4038
|
"ring-kumo-hairline",
|
|
4043
|
-
"text-kumo-
|
|
4039
|
+
"text-kumo-subtle"
|
|
4044
4040
|
],
|
|
4045
4041
|
"subComponents": {
|
|
4046
4042
|
"Info": {
|
|
@@ -4836,7 +4832,6 @@
|
|
|
4836
4832
|
"ring-kumo-brand",
|
|
4837
4833
|
"ring-kumo-hairline",
|
|
4838
4834
|
"text-kumo-default",
|
|
4839
|
-
"text-kumo-strong",
|
|
4840
4835
|
"text-kumo-subtle"
|
|
4841
4836
|
],
|
|
4842
4837
|
"subComponents": {
|
|
@@ -5681,7 +5676,6 @@
|
|
|
5681
5676
|
"ring-kumo-hairline",
|
|
5682
5677
|
"ring-kumo-line",
|
|
5683
5678
|
"text-kumo-default",
|
|
5684
|
-
"text-kumo-strong",
|
|
5685
5679
|
"text-kumo-subtle"
|
|
5686
5680
|
],
|
|
5687
5681
|
"styling": {
|
|
@@ -5923,7 +5917,6 @@
|
|
|
5923
5917
|
"text-kumo-danger",
|
|
5924
5918
|
"text-kumo-default",
|
|
5925
5919
|
"text-kumo-info",
|
|
5926
|
-
"text-kumo-strong",
|
|
5927
5920
|
"text-kumo-subtle",
|
|
5928
5921
|
"text-kumo-success",
|
|
5929
5922
|
"text-kumo-warning"
|
|
@@ -6247,7 +6240,7 @@
|
|
|
6247
6240
|
"examples": [],
|
|
6248
6241
|
"colors": [
|
|
6249
6242
|
"bg-kumo-overlay",
|
|
6250
|
-
"text-kumo-
|
|
6243
|
+
"text-kumo-subtle"
|
|
6251
6244
|
],
|
|
6252
6245
|
"files": [
|
|
6253
6246
|
"resource-list/resource-list.tsx",
|
package/ai/component-registry.md
CHANGED
|
@@ -1422,12 +1422,12 @@ Code component
|
|
|
1422
1422
|
|
|
1423
1423
|
**Colors (kumo tokens used):**
|
|
1424
1424
|
|
|
1425
|
-
`bg-kumo-base`, `border-kumo-fill`, `text-kumo-
|
|
1425
|
+
`bg-kumo-base`, `border-kumo-fill`, `text-kumo-subtle`
|
|
1426
1426
|
|
|
1427
1427
|
**Styling:**
|
|
1428
1428
|
|
|
1429
1429
|
- **Dimensions:** `[object Object]`
|
|
1430
|
-
- **Base Tokens:** `text-kumo-
|
|
1430
|
+
- **Base Tokens:** `text-kumo-subtle`
|
|
1431
1431
|
|
|
1432
1432
|
**Sub-Components:**
|
|
1433
1433
|
|
|
@@ -1628,7 +1628,7 @@ Combobox — autocomplete input with filterable dropdown list. Compound compone
|
|
|
1628
1628
|
|
|
1629
1629
|
**Colors (kumo tokens used):**
|
|
1630
1630
|
|
|
1631
|
-
`bg-kumo-base`, `bg-kumo-fill-hover`, `bg-kumo-overlay`, `bg-kumo-tint`, `border-kumo-hairline`, `ring-kumo-hairline`, `ring-kumo-line`, `text-kumo-default`, `text-kumo-
|
|
1631
|
+
`bg-kumo-base`, `bg-kumo-fill-hover`, `bg-kumo-overlay`, `bg-kumo-tint`, `border-kumo-hairline`, `ring-kumo-hairline`, `ring-kumo-line`, `text-kumo-default`, `text-kumo-subtle`
|
|
1632
1632
|
|
|
1633
1633
|
**Sub-Components:**
|
|
1634
1634
|
|
|
@@ -2037,7 +2037,7 @@ CommandPalette — accessible command palette / spotlight search overlay. Compo
|
|
|
2037
2037
|
|
|
2038
2038
|
**Colors (kumo tokens used):**
|
|
2039
2039
|
|
|
2040
|
-
`bg-kumo-base`, `bg-kumo-elevated`, `bg-kumo-overlay`, `bg-kumo-warning`, `ring-kumo-brand`, `ring-kumo-hairline`, `text-kumo-default`, `text-kumo-
|
|
2040
|
+
`bg-kumo-base`, `bg-kumo-elevated`, `bg-kumo-overlay`, `bg-kumo-warning`, `ring-kumo-brand`, `ring-kumo-hairline`, `text-kumo-default`, `text-kumo-subtle`
|
|
2041
2041
|
|
|
2042
2042
|
**Examples:**
|
|
2043
2043
|
|
|
@@ -2458,7 +2458,7 @@ DatePicker — a date selection calendar. Built on [react-day-picker](https://d
|
|
|
2458
2458
|
className={`rounded-md px-3 py-1.5 text-left whitespace-nowrap ${
|
|
2459
2459
|
isActive
|
|
2460
2460
|
? "bg-kumo-bg-inverse text-kumo-text-inverse"
|
|
2461
|
-
: "text-kumo-
|
|
2461
|
+
: "text-kumo-subtle hover:bg-kumo-control"
|
|
2462
2462
|
}`}
|
|
2463
2463
|
>
|
|
2464
2464
|
{preset.label}
|
|
@@ -2530,7 +2530,7 @@ DateRangePicker — dual-calendar date range selector. Renders two side-by-side
|
|
|
2530
2530
|
|
|
2531
2531
|
**Colors (kumo tokens used):**
|
|
2532
2532
|
|
|
2533
|
-
`bg-kumo-base`, `bg-kumo-contrast`, `bg-kumo-fill`, `bg-kumo-interact`, `bg-kumo-overlay`, `ring-kumo-focus`, `text-kumo-default`, `text-kumo-inverse`, `text-kumo-
|
|
2533
|
+
`bg-kumo-base`, `bg-kumo-contrast`, `bg-kumo-fill`, `bg-kumo-interact`, `bg-kumo-overlay`, `ring-kumo-focus`, `text-kumo-default`, `text-kumo-inverse`, `text-kumo-subtle`
|
|
2534
2534
|
|
|
2535
2535
|
**Styling:**
|
|
2536
2536
|
|
|
@@ -3014,7 +3014,7 @@ Placeholder shown when a list, table, or page has no content to display.
|
|
|
3014
3014
|
|
|
3015
3015
|
**Colors (kumo tokens used):**
|
|
3016
3016
|
|
|
3017
|
-
`bg-kumo-control`, `bg-kumo-overlay`, `border-kumo-fill`, `border-kumo-interact`, `text-kumo-brand`, `text-kumo-default`, `text-kumo-inactive`, `text-kumo-
|
|
3017
|
+
`bg-kumo-control`, `bg-kumo-overlay`, `border-kumo-fill`, `border-kumo-interact`, `text-kumo-brand`, `text-kumo-default`, `text-kumo-inactive`, `text-kumo-subtle`, `text-kumo-success`
|
|
3018
3018
|
|
|
3019
3019
|
**Examples:**
|
|
3020
3020
|
|
|
@@ -3463,7 +3463,7 @@ Input component
|
|
|
3463
3463
|
|
|
3464
3464
|
**Colors (kumo tokens used):**
|
|
3465
3465
|
|
|
3466
|
-
`bg-kumo-control`, `ring-kumo-danger`, `ring-kumo-focus`, `ring-kumo-line`, `text-kumo-default
|
|
3466
|
+
`bg-kumo-control`, `ring-kumo-danger`, `ring-kumo-focus`, `ring-kumo-line`, `text-kumo-default`
|
|
3467
3467
|
|
|
3468
3468
|
**Styling:**
|
|
3469
3469
|
|
|
@@ -3962,7 +3962,7 @@ Label component for form fields. Provides a standardized way to display labels
|
|
|
3962
3962
|
|
|
3963
3963
|
**Colors (kumo tokens used):**
|
|
3964
3964
|
|
|
3965
|
-
`text-kumo-default`, `text-kumo-
|
|
3965
|
+
`text-kumo-default`, `text-kumo-subtle`
|
|
3966
3966
|
|
|
3967
3967
|
**Examples:**
|
|
3968
3968
|
|
|
@@ -4043,7 +4043,7 @@ Accepts a `ReactElement` or a function that returns the element to render.
|
|
|
4043
4043
|
|
|
4044
4044
|
**Colors (kumo tokens used):**
|
|
4045
4045
|
|
|
4046
|
-
`bg-kumo-base`, `bg-kumo-elevated`, `ring-kumo-fill`, `ring-kumo-hairline`, `ring-kumo-line`, `text-kumo-
|
|
4046
|
+
`bg-kumo-base`, `bg-kumo-elevated`, `ring-kumo-fill`, `ring-kumo-hairline`, `ring-kumo-line`, `text-kumo-subtle`
|
|
4047
4047
|
|
|
4048
4048
|
**Styling:**
|
|
4049
4049
|
|
|
@@ -4351,7 +4351,7 @@ Progress bar showing a measured value within a known range (e.g. quota usage).
|
|
|
4351
4351
|
|
|
4352
4352
|
**Colors (kumo tokens used):**
|
|
4353
4353
|
|
|
4354
|
-
`bg-kumo-fill`, `text-kumo-default`, `text-kumo-
|
|
4354
|
+
`bg-kumo-fill`, `text-kumo-default`, `text-kumo-subtle`
|
|
4355
4355
|
|
|
4356
4356
|
**Examples:**
|
|
4357
4357
|
|
|
@@ -4415,7 +4415,7 @@ For visible text like "Showing X of Y", use render props on sub-components:
|
|
|
4415
4415
|
|
|
4416
4416
|
**Colors (kumo tokens used):**
|
|
4417
4417
|
|
|
4418
|
-
`border-kumo-hairline`, `ring-kumo-hairline`, `text-kumo-
|
|
4418
|
+
`border-kumo-hairline`, `ring-kumo-hairline`, `text-kumo-subtle`
|
|
4419
4419
|
|
|
4420
4420
|
**Styling:**
|
|
4421
4421
|
|
|
@@ -5745,7 +5745,7 @@ Sidebar — responsive navigation panel with expand/collapse support. Compound
|
|
|
5745
5745
|
|
|
5746
5746
|
**Colors (kumo tokens used):**
|
|
5747
5747
|
|
|
5748
|
-
`bg-kumo-base`, `bg-kumo-brand`, `bg-kumo-hairline`, `bg-kumo-overlay`, `bg-kumo-recessed`, `bg-kumo-tint`, `border-kumo-hairline`, `ring-kumo-brand`, `ring-kumo-hairline`, `text-kumo-default`, `text-kumo-
|
|
5748
|
+
`bg-kumo-base`, `bg-kumo-brand`, `bg-kumo-hairline`, `bg-kumo-overlay`, `bg-kumo-recessed`, `bg-kumo-tint`, `border-kumo-hairline`, `ring-kumo-brand`, `ring-kumo-hairline`, `text-kumo-default`, `text-kumo-subtle`
|
|
5749
5749
|
|
|
5750
5750
|
**Styling:**
|
|
5751
5751
|
|
|
@@ -7117,7 +7117,7 @@ Tab navigation component with segmented or underline style. Built on Base UI Tab
|
|
|
7117
7117
|
|
|
7118
7118
|
**Colors (kumo tokens used):**
|
|
7119
7119
|
|
|
7120
|
-
`bg-kumo-base`, `bg-kumo-brand`, `bg-kumo-recessed`, `bg-kumo-tint`, `border-kumo-hairline`, `ring-kumo-brand`, `ring-kumo-focus`, `ring-kumo-hairline`, `ring-kumo-line`, `text-kumo-default`, `text-kumo-
|
|
7120
|
+
`bg-kumo-base`, `bg-kumo-brand`, `bg-kumo-recessed`, `bg-kumo-tint`, `border-kumo-hairline`, `ring-kumo-brand`, `ring-kumo-focus`, `ring-kumo-hairline`, `ring-kumo-line`, `text-kumo-default`, `text-kumo-subtle`
|
|
7121
7121
|
|
|
7122
7122
|
**Styling:**
|
|
7123
7123
|
|
|
@@ -7377,7 +7377,7 @@ Toasty — toast notification provider and viewport. Renders a `Toast.Provider`
|
|
|
7377
7377
|
|
|
7378
7378
|
**Colors (kumo tokens used):**
|
|
7379
7379
|
|
|
7380
|
-
`bg-kumo-base`, `bg-kumo-contrast`, `bg-kumo-control`, `bg-kumo-danger`, `bg-kumo-fill-hover`, `bg-kumo-info`, `bg-kumo-success`, `bg-kumo-warning`, `border-kumo-fill`, `ring-kumo-danger`, `ring-kumo-hairline`, `ring-kumo-info`, `ring-kumo-line`, `ring-kumo-success`, `ring-kumo-warning`, `text-kumo-danger`, `text-kumo-default`, `text-kumo-info`, `text-kumo-
|
|
7380
|
+
`bg-kumo-base`, `bg-kumo-contrast`, `bg-kumo-control`, `bg-kumo-danger`, `bg-kumo-fill-hover`, `bg-kumo-info`, `bg-kumo-success`, `bg-kumo-warning`, `border-kumo-fill`, `ring-kumo-danger`, `ring-kumo-hairline`, `ring-kumo-info`, `ring-kumo-line`, `ring-kumo-success`, `ring-kumo-warning`, `text-kumo-danger`, `text-kumo-default`, `text-kumo-info`, `text-kumo-subtle`, `text-kumo-success`, `text-kumo-warning`
|
|
7381
7381
|
|
|
7382
7382
|
**Styling:**
|
|
7383
7383
|
|
package/dist/.build-complete
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
1777571062774
|
|
@@ -41,7 +41,7 @@ export function ResourceListPage({
|
|
|
41
41
|
{title}
|
|
42
42
|
</h1>
|
|
43
43
|
</div>
|
|
44
|
-
<p className="hidden p-0 text-lg leading-normal text-pretty text-kumo-
|
|
44
|
+
<p className="hidden p-0 text-lg leading-normal text-pretty text-kumo-subtle md:block">
|
|
45
45
|
{description}
|
|
46
46
|
</p>
|
|
47
47
|
</div>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as t, jsxs as A } from "react/jsx-runtime";
|
|
3
3
|
import { CheckIcon as g } from "@phosphor-icons/react";
|
|
4
|
-
import { K as c, i as y } from "./input-
|
|
4
|
+
import { K as c, i as y } from "./input-ncfowphv81yq7fyy.js";
|
|
5
5
|
import { c as s } from "./cn-ct4n7r74mh8y0f48.js";
|
|
6
|
-
import { F as C } from "./field-
|
|
6
|
+
import { F as C } from "./field-c0wf94plit2gci59.js";
|
|
7
7
|
import { a6 as I, ab as T, bu as k, a8 as v, S as G, a9 as L, aa as O, bt as P, am as _, an as w, ao as z, ac as E } from "./vendor-base-ui-ie71jahf0czyf58j.js";
|
|
8
8
|
const D = {
|
|
9
9
|
size: c.size
|
|
@@ -171,4 +171,4 @@ export {
|
|
|
171
171
|
$ as a,
|
|
172
172
|
u as b
|
|
173
173
|
};
|
|
174
|
-
//# sourceMappingURL=autocomplete-
|
|
174
|
+
//# sourceMappingURL=autocomplete-48aq0d244bs2e8zv.js.map
|
package/dist/chunks/{autocomplete-cs3fwy6lwzlyirpq.js.map → autocomplete-48aq0d244bs2e8zv.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete-cs3fwy6lwzlyirpq.js","sources":["../../src/components/autocomplete/autocomplete.tsx"],"sourcesContent":["import { Autocomplete as AutocompleteBase } from \"@base-ui/react/autocomplete\";\nimport { CheckIcon } from \"@phosphor-icons/react\";\nimport { type ReactNode } from \"react\";\nimport { inputVariants, KUMO_INPUT_VARIANTS } from \"../input/input\";\nimport { cn } from \"../../utils/cn\";\nimport { Field, type FieldErrorMatch } from \"../field/field\";\n\n/** Autocomplete variant definitions. */\nexport const KUMO_AUTOCOMPLETE_VARIANTS = {\n size: KUMO_INPUT_VARIANTS.size,\n} as const;\n\nexport const KUMO_AUTOCOMPLETE_DEFAULT_VARIANTS = {\n size: \"base\",\n} as const;\n\n// Derived types from KUMO_AUTOCOMPLETE_VARIANTS\nexport type KumoAutocompleteSize = keyof typeof KUMO_AUTOCOMPLETE_VARIANTS.size;\n\nexport interface KumoAutocompleteVariantsProps {\n /**\n * Size of the autocomplete input. Matches Input component sizes.\n * - `\"xs\"` — Extra small for compact UIs (h-5 / 20px)\n * - `\"sm\"` — Small for secondary fields (h-6.5 / 26px)\n * - `\"base\"` — Default size (h-9 / 36px)\n * - `\"lg\"` — Large for prominent fields (h-10 / 40px)\n * @default \"base\"\n */\n size?: KumoAutocompleteSize;\n}\n\nexport function autocompleteVariants({\n size = KUMO_AUTOCOMPLETE_DEFAULT_VARIANTS.size,\n}: KumoAutocompleteVariantsProps = {}) {\n return cn(KUMO_INPUT_VARIANTS.size[size].classes);\n}\n\n/**\n * Autocomplete component props.\n *\n * Autocomplete provides a free-form text input with optional suggestions in a\n * filterable dropdown. Unlike Combobox, the input value is not constrained to\n * the suggestion list items.\n *\n * @example\n * ```tsx\n * <Autocomplete label=\"Country\" items={countries}>\n * <Autocomplete.InputGroup />\n * <Autocomplete.Content>\n * <Autocomplete.List>\n * {(item) => <Autocomplete.Item value={item}>{item}</Autocomplete.Item>}\n * </Autocomplete.List>\n * </Autocomplete.Content>\n * </Autocomplete>\n * ```\n */\nexport interface AutocompleteProps {\n /** Array of items to display in the dropdown */\n items: unknown[];\n /** The controlled input value */\n value?: string | number | string[];\n /** The uncontrolled default input value */\n defaultValue?: string | number | string[];\n /** Callback when the input value changes */\n onValueChange?: AutocompleteBase.Root.Props<unknown>[\"onValueChange\"];\n /** Whether the popup is open (controlled) */\n open?: boolean;\n /** Callback when the popup opens or closes */\n onOpenChange?: AutocompleteBase.Root.Props<unknown>[\"onOpenChange\"];\n /** Autocomplete content (input group, popup content) */\n children: ReactNode;\n /** Additional CSS classes */\n className?: string;\n /** Label content (enables Field wrapper) */\n label?: ReactNode;\n /** Whether the field is required */\n required?: boolean;\n /** Tooltip content to display next to the label */\n labelTooltip?: ReactNode;\n /** Helper text displayed below the field */\n description?: ReactNode;\n /** Error message or validation error object */\n error?: string | { message: ReactNode; match: FieldErrorMatch };\n}\n\nfunction Root<ItemValue>({\n label,\n required,\n labelTooltip,\n description,\n error,\n children,\n ...props\n}: AutocompleteBase.Root.Props<ItemValue> & {\n label?: ReactNode;\n required?: boolean;\n labelTooltip?: ReactNode;\n description?: ReactNode;\n error?: string | { message: ReactNode; match: FieldErrorMatch };\n}) {\n const rootProps = props as Omit<\n AutocompleteBase.Root.Props<ItemValue>,\n \"items\"\n > & {\n items?: readonly ItemValue[];\n };\n const control = (\n <AutocompleteBase.Root {...rootProps}>{children}</AutocompleteBase.Root>\n );\n\n if (label) {\n return (\n <Field\n label={label}\n required={required}\n labelTooltip={labelTooltip}\n description={description}\n error={\n error\n ? typeof error === \"string\"\n ? { message: error, match: true }\n : error\n : undefined\n }\n >\n {control}\n </Field>\n );\n }\n\n return control;\n}\n\nfunction InputGroup({\n className,\n size = KUMO_AUTOCOMPLETE_DEFAULT_VARIANTS.size,\n placeholder,\n}: {\n className?: string;\n size?: KumoAutocompleteSize;\n placeholder?: string;\n}) {\n return (\n <AutocompleteBase.Input\n className={cn(\n inputVariants({ size, focusIndicator: true }),\n \"w-full\",\n className,\n )}\n placeholder={placeholder}\n />\n );\n}\n\nfunction Content({\n children,\n className,\n align = \"start\",\n sideOffset = 4,\n alignOffset,\n side,\n}: {\n children?: ReactNode;\n className?: string;\n align?: AutocompleteBase.Positioner.Props[\"align\"];\n alignOffset?: AutocompleteBase.Positioner.Props[\"alignOffset\"];\n side?: AutocompleteBase.Positioner.Props[\"side\"];\n sideOffset?: AutocompleteBase.Positioner.Props[\"sideOffset\"];\n}) {\n return (\n <AutocompleteBase.Portal>\n <AutocompleteBase.Positioner\n className=\"outline-none\"\n align={align}\n sideOffset={sideOffset}\n alignOffset={alignOffset}\n side={side}\n >\n <AutocompleteBase.Popup\n className={(state: AutocompleteBase.Popup.State) =>\n cn(\n \"flex flex-col\",\n \"max-h-[min(var(--available-height),24rem)] max-w-(--available-width) min-w-(--anchor-width) py-1.5\",\n \"bg-kumo-control text-kumo-default\",\n \"rounded-lg shadow-lg ring ring-kumo-line\",\n state.empty && \"hidden\",\n className,\n )\n }\n >\n {children}\n </AutocompleteBase.Popup>\n </AutocompleteBase.Positioner>\n </AutocompleteBase.Portal>\n );\n}\n\nfunction List({\n className,\n ...props\n}: AutocompleteBase.List.Props & { className?: string }) {\n return (\n <AutocompleteBase.List\n {...props}\n className={cn(\n \"min-h-0 flex-1 overflow-y-auto overscroll-contain scroll-pt-2 scroll-pb-2\",\n className,\n )}\n />\n );\n}\n\nfunction Item({ children, ...props }: AutocompleteBase.Item.Props) {\n return (\n <AutocompleteBase.Item\n {...props}\n className=\"group mx-1.5 grid cursor-pointer grid-cols-[1fr_16px] gap-2 rounded px-2 py-1.5 text-base data-highlighted:bg-kumo-overlay data-selected:font-medium\"\n >\n <div className=\"col-start-1\">{children}</div>\n <span className=\"col-start-2 hidden items-center group-data-selected:flex\">\n <CheckIcon size={14} />\n </span>\n </AutocompleteBase.Item>\n );\n}\n\nfunction GroupLabel(props: AutocompleteBase.GroupLabel.Props) {\n return (\n <AutocompleteBase.GroupLabel\n {...props}\n className={cn(\n \"mx-1.5 px-2 py-1.5 text-sm text-kumo-strong\",\n props.className,\n )}\n />\n );\n}\n\nfunction Group(props: AutocompleteBase.Group.Props) {\n return (\n <AutocompleteBase.Group\n {...props}\n className=\"border-t border-kumo-line mt-2 pt-2 first:border-t-0 first:mt-0 first:pt-0\"\n />\n );\n}\n\nfunction Separator(props: AutocompleteBase.Separator.Props) {\n return (\n <AutocompleteBase.Separator\n {...props}\n className={cn(\"mx-0 my-1 h-px bg-kumo-line\", props.className)}\n />\n );\n}\n\nRoot.displayName = \"Autocomplete.Root\";\nInputGroup.displayName = \"Autocomplete.InputGroup\";\nContent.displayName = \"Autocomplete.Content\";\nItem.displayName = \"Autocomplete.Item\";\nGroupLabel.displayName = \"Autocomplete.GroupLabel\";\nGroup.displayName = \"Autocomplete.Group\";\nSeparator.displayName = \"Autocomplete.Separator\";\n\n/**\n * Autocomplete — free-form text input with an optional filtered suggestion list.\n *\n * Unlike Combobox, the input value is not restricted to items in the list.\n * Use Combobox when the selected value must come from the list.\n *\n * Compound component: `Autocomplete` (Root), `.InputGroup`, `.Content`, `.Item`,\n * `.GroupLabel`, `.Group`, `.Separator`, `.List`, `.Collection`.\n *\n * `InputGroup` renders the text input with Input component styling.\n * Pass a `size` prop to `InputGroup` to match the Input component sizes.\n *\n * @example\n * ```tsx\n * <Autocomplete items={fruits} label=\"Fruit\">\n * <Autocomplete.InputGroup size=\"base\" />\n * <Autocomplete.Content>\n * <Autocomplete.List>\n * {(item) => <Autocomplete.Item value={item}>{item}</Autocomplete.Item>}\n * </Autocomplete.List>\n * </Autocomplete.Content>\n * </Autocomplete>\n * ```\n *\n * @see https://base-ui.com/react/components/autocomplete\n */\nexport const Autocomplete = Object.assign(Root, {\n // Styled compound sub-components\n InputGroup,\n Content,\n Item,\n GroupLabel,\n Group,\n Separator,\n List,\n\n // Pass-through Base UI sub-components\n Empty: AutocompleteBase.Empty,\n Collection: AutocompleteBase.Collection,\n});\n"],"names":["KUMO_AUTOCOMPLETE_VARIANTS","KUMO_INPUT_VARIANTS","KUMO_AUTOCOMPLETE_DEFAULT_VARIANTS","autocompleteVariants","size","cn","Root","label","required","labelTooltip","description","error","children","props","control","jsx","AutocompleteBase.Root","Field","InputGroup","className","placeholder","AutocompleteBase.Input","inputVariants","Content","align","sideOffset","alignOffset","side","AutocompleteBase.Portal","AutocompleteBase.Positioner","AutocompleteBase.Popup","state","List","AutocompleteBase.List","Item","jsxs","AutocompleteBase.Item","CheckIcon","GroupLabel","AutocompleteBase.GroupLabel","Group","AutocompleteBase.Group","Separator","AutocompleteBase.Separator","Autocomplete","AutocompleteBase.Empty","AutocompleteBase.Collection"],"mappings":";;;;;;;AAQO,MAAMA,IAA6B;AAAA,EACxC,MAAMC,EAAoB;AAC5B,GAEaC,IAAqC;AAAA,EAChD,MAAM;AACR;AAiBO,SAASC,EAAqB;AAAA,EACnC,MAAAC,IAAOF,EAAmC;AAC5C,IAAmC,IAAI;AACrC,SAAOG,EAAGJ,EAAoB,KAAKG,CAAI,EAAE,OAAO;AAClD;AAkDA,SAASE,EAAgB;AAAA,EACvB,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,cAAAC;AAAA,EACA,aAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,GAAGC;AACL,GAMG;AAOD,QAAMC,IACJ,gBAAAC,EAACC,GAAA,EAAuB,GAPRH,GAOuB,UAAAD,GAAS;AAGlD,SAAIL,IAEA,gBAAAQ;AAAA,IAACE;AAAA,IAAA;AAAA,MACC,OAAAV;AAAA,MACA,UAAAC;AAAA,MACA,cAAAC;AAAA,MACA,aAAAC;AAAA,MACA,OACEC,IACI,OAAOA,KAAU,WACf,EAAE,SAASA,GAAO,OAAO,GAAA,IACzBA,IACF;AAAA,MAGL,UAAAG;AAAA,IAAA;AAAA,EAAA,IAKAA;AACT;AAEA,SAASI,EAAW;AAAA,EAClB,WAAAC;AAAA,EACA,MAAAf,IAAOF,EAAmC;AAAA,EAC1C,aAAAkB;AACF,GAIG;AACD,SACE,gBAAAL;AAAA,IAACM;AAAAA,IAAA;AAAA,MACC,WAAWhB;AAAA,QACTiB,EAAc,EAAE,MAAAlB,GAAM,gBAAgB,IAAM;AAAA,QAC5C;AAAA,QACAe;AAAA,MAAA;AAAA,MAEF,aAAAC;AAAA,IAAA;AAAA,EAAA;AAGN;AAEA,SAASG,EAAQ;AAAA,EACf,UAAAX;AAAA,EACA,WAAAO;AAAA,EACA,OAAAK,IAAQ;AAAA,EACR,YAAAC,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AEA,SAAS2B,EAAM3B,GAAqC;AAClD,SACE,gBAAAE;AAAA,IAAC0B;AAAAA,IAAA;AAAA,MACE,GAAG5B;AAAA,MACJ,WAAU;AAAA,IAAA;AAAA,EAAA;AAGhB;AAEA,SAAS6B,EAAU7B,GAAyC;AAC1D,SACE,gBAAAE;AAAA,IAAC4B;AAAAA,IAAA;AAAA,MACE,GAAG9B;AAAA,MACJ,WAAWR,EAAG,+BAA+BQ,EAAM,SAAS;AAAA,IAAA;AAAA,EAAA;AAGlE;AAEAP,EAAK,cAAc;AACnBY,EAAW,cAAc;AACzBK,EAAQ,cAAc;AACtBW,EAAK,cAAc;AACnBI,EAAW,cAAc;AACzBE,EAAM,cAAc;AACpBE,EAAU,cAAc;AA4BjB,MAAME,IAAe,OAAO,OAAOtC,GAAM;AAAA;AAAA,EAE9C,YAAAY;AAAA,EACA,SAAAK;AAAA,EACA,MAAAW;AAAA,EACA,YAAAI;AAAA,EACA,OAAAE;AAAA,EACA,WAAAE;AAAA,EACA,MAAAV;AAAA;AAAA,EAGA,OAAOa;AAAAA,EACP,YAAYC;AACd,CAAC;"}
|
|
1
|
+
{"version":3,"file":"autocomplete-48aq0d244bs2e8zv.js","sources":["../../src/components/autocomplete/autocomplete.tsx"],"sourcesContent":["import { Autocomplete as AutocompleteBase } from \"@base-ui/react/autocomplete\";\nimport { CheckIcon } from \"@phosphor-icons/react\";\nimport { type ReactNode } from \"react\";\nimport { inputVariants, KUMO_INPUT_VARIANTS } from \"../input/input\";\nimport { cn } from \"../../utils/cn\";\nimport { Field, type FieldErrorMatch } from \"../field/field\";\n\n/** Autocomplete variant definitions. */\nexport const KUMO_AUTOCOMPLETE_VARIANTS = {\n size: KUMO_INPUT_VARIANTS.size,\n} as const;\n\nexport const KUMO_AUTOCOMPLETE_DEFAULT_VARIANTS = {\n size: \"base\",\n} as const;\n\n// Derived types from KUMO_AUTOCOMPLETE_VARIANTS\nexport type KumoAutocompleteSize = keyof typeof KUMO_AUTOCOMPLETE_VARIANTS.size;\n\nexport interface KumoAutocompleteVariantsProps {\n /**\n * Size of the autocomplete input. Matches Input component sizes.\n * - `\"xs\"` — Extra small for compact UIs (h-5 / 20px)\n * - `\"sm\"` — Small for secondary fields (h-6.5 / 26px)\n * - `\"base\"` — Default size (h-9 / 36px)\n * - `\"lg\"` — Large for prominent fields (h-10 / 40px)\n * @default \"base\"\n */\n size?: KumoAutocompleteSize;\n}\n\nexport function autocompleteVariants({\n size = KUMO_AUTOCOMPLETE_DEFAULT_VARIANTS.size,\n}: KumoAutocompleteVariantsProps = {}) {\n return cn(KUMO_INPUT_VARIANTS.size[size].classes);\n}\n\n/**\n * Autocomplete component props.\n *\n * Autocomplete provides a free-form text input with optional suggestions in a\n * filterable dropdown. Unlike Combobox, the input value is not constrained to\n * the suggestion list items.\n *\n * @example\n * ```tsx\n * <Autocomplete label=\"Country\" items={countries}>\n * <Autocomplete.InputGroup />\n * <Autocomplete.Content>\n * <Autocomplete.List>\n * {(item) => <Autocomplete.Item value={item}>{item}</Autocomplete.Item>}\n * </Autocomplete.List>\n * </Autocomplete.Content>\n * </Autocomplete>\n * ```\n */\nexport interface AutocompleteProps {\n /** Array of items to display in the dropdown */\n items: unknown[];\n /** The controlled input value */\n value?: string | number | string[];\n /** The uncontrolled default input value */\n defaultValue?: string | number | string[];\n /** Callback when the input value changes */\n onValueChange?: AutocompleteBase.Root.Props<unknown>[\"onValueChange\"];\n /** Whether the popup is open (controlled) */\n open?: boolean;\n /** Callback when the popup opens or closes */\n onOpenChange?: AutocompleteBase.Root.Props<unknown>[\"onOpenChange\"];\n /** Autocomplete content (input group, popup content) */\n children: ReactNode;\n /** Additional CSS classes */\n className?: string;\n /** Label content (enables Field wrapper) */\n label?: ReactNode;\n /** Whether the field is required */\n required?: boolean;\n /** Tooltip content to display next to the label */\n labelTooltip?: ReactNode;\n /** Helper text displayed below the field */\n description?: ReactNode;\n /** Error message or validation error object */\n error?: string | { message: ReactNode; match: FieldErrorMatch };\n}\n\nfunction Root<ItemValue>({\n label,\n required,\n labelTooltip,\n description,\n error,\n children,\n ...props\n}: AutocompleteBase.Root.Props<ItemValue> & {\n label?: ReactNode;\n required?: boolean;\n labelTooltip?: ReactNode;\n description?: ReactNode;\n error?: string | { message: ReactNode; match: FieldErrorMatch };\n}) {\n const rootProps = props as Omit<\n AutocompleteBase.Root.Props<ItemValue>,\n \"items\"\n > & {\n items?: readonly ItemValue[];\n };\n const control = (\n <AutocompleteBase.Root {...rootProps}>{children}</AutocompleteBase.Root>\n );\n\n if (label) {\n return (\n <Field\n label={label}\n required={required}\n labelTooltip={labelTooltip}\n description={description}\n error={\n error\n ? typeof error === \"string\"\n ? { message: error, match: true }\n : error\n : undefined\n }\n >\n {control}\n </Field>\n );\n }\n\n return control;\n}\n\nfunction InputGroup({\n className,\n size = KUMO_AUTOCOMPLETE_DEFAULT_VARIANTS.size,\n placeholder,\n}: {\n className?: string;\n size?: KumoAutocompleteSize;\n placeholder?: string;\n}) {\n return (\n <AutocompleteBase.Input\n className={cn(\n inputVariants({ size, focusIndicator: true }),\n \"w-full\",\n className,\n )}\n placeholder={placeholder}\n />\n );\n}\n\nfunction Content({\n children,\n className,\n align = \"start\",\n sideOffset = 4,\n alignOffset,\n side,\n}: {\n children?: ReactNode;\n className?: string;\n align?: AutocompleteBase.Positioner.Props[\"align\"];\n alignOffset?: AutocompleteBase.Positioner.Props[\"alignOffset\"];\n side?: AutocompleteBase.Positioner.Props[\"side\"];\n sideOffset?: AutocompleteBase.Positioner.Props[\"sideOffset\"];\n}) {\n return (\n <AutocompleteBase.Portal>\n <AutocompleteBase.Positioner\n className=\"outline-none\"\n align={align}\n sideOffset={sideOffset}\n alignOffset={alignOffset}\n side={side}\n >\n <AutocompleteBase.Popup\n className={(state: AutocompleteBase.Popup.State) =>\n cn(\n \"flex flex-col\",\n \"max-h-[min(var(--available-height),24rem)] max-w-(--available-width) min-w-(--anchor-width) py-1.5\",\n \"bg-kumo-control text-kumo-default\",\n \"rounded-lg shadow-lg ring ring-kumo-line\",\n state.empty && \"hidden\",\n className,\n )\n }\n >\n {children}\n </AutocompleteBase.Popup>\n </AutocompleteBase.Positioner>\n </AutocompleteBase.Portal>\n );\n}\n\nfunction List({\n className,\n ...props\n}: AutocompleteBase.List.Props & { className?: string }) {\n return (\n <AutocompleteBase.List\n {...props}\n className={cn(\n \"min-h-0 flex-1 overflow-y-auto overscroll-contain scroll-pt-2 scroll-pb-2\",\n className,\n )}\n />\n );\n}\n\nfunction Item({ children, ...props }: AutocompleteBase.Item.Props) {\n return (\n <AutocompleteBase.Item\n {...props}\n className=\"group mx-1.5 grid cursor-pointer grid-cols-[1fr_16px] gap-2 rounded px-2 py-1.5 text-base data-highlighted:bg-kumo-overlay data-selected:font-medium\"\n >\n <div className=\"col-start-1\">{children}</div>\n <span className=\"col-start-2 hidden items-center group-data-selected:flex\">\n <CheckIcon size={14} />\n </span>\n </AutocompleteBase.Item>\n );\n}\n\nfunction GroupLabel(props: AutocompleteBase.GroupLabel.Props) {\n return (\n <AutocompleteBase.GroupLabel\n {...props}\n className={cn(\n \"mx-1.5 px-2 py-1.5 text-sm text-kumo-strong\",\n props.className,\n )}\n />\n );\n}\n\nfunction Group(props: AutocompleteBase.Group.Props) {\n return (\n <AutocompleteBase.Group\n {...props}\n className=\"border-t border-kumo-line mt-2 pt-2 first:border-t-0 first:mt-0 first:pt-0\"\n />\n );\n}\n\nfunction Separator(props: AutocompleteBase.Separator.Props) {\n return (\n <AutocompleteBase.Separator\n {...props}\n className={cn(\"mx-0 my-1 h-px bg-kumo-line\", props.className)}\n />\n );\n}\n\nRoot.displayName = \"Autocomplete.Root\";\nInputGroup.displayName = \"Autocomplete.InputGroup\";\nContent.displayName = \"Autocomplete.Content\";\nItem.displayName = \"Autocomplete.Item\";\nGroupLabel.displayName = \"Autocomplete.GroupLabel\";\nGroup.displayName = \"Autocomplete.Group\";\nSeparator.displayName = \"Autocomplete.Separator\";\n\n/**\n * Autocomplete — free-form text input with an optional filtered suggestion list.\n *\n * Unlike Combobox, the input value is not restricted to items in the list.\n * Use Combobox when the selected value must come from the list.\n *\n * Compound component: `Autocomplete` (Root), `.InputGroup`, `.Content`, `.Item`,\n * `.GroupLabel`, `.Group`, `.Separator`, `.List`, `.Collection`.\n *\n * `InputGroup` renders the text input with Input component styling.\n * Pass a `size` prop to `InputGroup` to match the Input component sizes.\n *\n * @example\n * ```tsx\n * <Autocomplete items={fruits} label=\"Fruit\">\n * <Autocomplete.InputGroup size=\"base\" />\n * <Autocomplete.Content>\n * <Autocomplete.List>\n * {(item) => <Autocomplete.Item value={item}>{item}</Autocomplete.Item>}\n * </Autocomplete.List>\n * </Autocomplete.Content>\n * </Autocomplete>\n * ```\n *\n * @see https://base-ui.com/react/components/autocomplete\n */\nexport const Autocomplete = Object.assign(Root, {\n // Styled compound sub-components\n InputGroup,\n Content,\n Item,\n GroupLabel,\n Group,\n Separator,\n List,\n\n // Pass-through Base UI sub-components\n Empty: AutocompleteBase.Empty,\n Collection: AutocompleteBase.Collection,\n});\n"],"names":["KUMO_AUTOCOMPLETE_VARIANTS","KUMO_INPUT_VARIANTS","KUMO_AUTOCOMPLETE_DEFAULT_VARIANTS","autocompleteVariants","size","cn","Root","label","required","labelTooltip","description","error","children","props","control","jsx","AutocompleteBase.Root","Field","InputGroup","className","placeholder","AutocompleteBase.Input","inputVariants","Content","align","sideOffset","alignOffset","side","AutocompleteBase.Portal","AutocompleteBase.Positioner","AutocompleteBase.Popup","state","List","AutocompleteBase.List","Item","jsxs","AutocompleteBase.Item","CheckIcon","GroupLabel","AutocompleteBase.GroupLabel","Group","AutocompleteBase.Group","Separator","AutocompleteBase.Separator","Autocomplete","AutocompleteBase.Empty","AutocompleteBase.Collection"],"mappings":";;;;;;;AAQO,MAAMA,IAA6B;AAAA,EACxC,MAAMC,EAAoB;AAC5B,GAEaC,IAAqC;AAAA,EAChD,MAAM;AACR;AAiBO,SAASC,EAAqB;AAAA,EACnC,MAAAC,IAAOF,EAAmC;AAC5C,IAA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EAAG,+BAA+BQ,EAAM,SAAS;AAAA,IAAA;AAAA,EAAA;AAGlE;AAEAP,EAAK,cAAc;AACnBY,EAAW,cAAc;AACzBK,EAAQ,cAAc;AACtBW,EAAK,cAAc;AACnBI,EAAW,cAAc;AACzBE,EAAM,cAAc;AACpBE,EAAU,cAAc;AA4BjB,MAAME,IAAe,OAAO,OAAOtC,GAAM;AAAA;AAAA,EAE9C,YAAAY;AAAA,EACA,SAAAK;AAAA,EACA,MAAAW;AAAA,EACA,YAAAI;AAAA,EACA,OAAAE;AAAA,EACA,WAAAE;AAAA,EACA,MAAAV;AAAA;AAAA,EAGA,OAAOa;AAAAA,EACP,YAAYC;AACd,CAAC;"}
|
|
@@ -3,7 +3,7 @@ import { jsx as e, jsxs as x } from "react/jsx-runtime";
|
|
|
3
3
|
import { forwardRef as p, createContext as B, useContext as F } from "react";
|
|
4
4
|
import { MinusIcon as C, CheckIcon as v } from "@phosphor-icons/react";
|
|
5
5
|
import { c as i } from "./cn-ct4n7r74mh8y0f48.js";
|
|
6
|
-
import { L as E } from "./label-
|
|
6
|
+
import { L as E } from "./label-c3h9i3y4wiccelt7.js";
|
|
7
7
|
import { L as N, N as y, O as K, P as R, Q as w, C as _, U as G } from "./vendor-base-ui-ie71jahf0czyf58j.js";
|
|
8
8
|
const H = {
|
|
9
9
|
variant: {
|
|
@@ -207,4 +207,4 @@ export {
|
|
|
207
207
|
H as K,
|
|
208
208
|
X as a
|
|
209
209
|
};
|
|
210
|
-
//# sourceMappingURL=checkbox-
|
|
210
|
+
//# sourceMappingURL=checkbox-hvxfvhtx1qjo2mww.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox-eren6w2csum1xghg.js","sources":["../../src/components/checkbox/checkbox.tsx"],"sourcesContent":["import { forwardRef, createContext, useContext, type ReactNode } from \"react\";\nimport { CheckIcon, MinusIcon } from \"@phosphor-icons/react\";\nimport { cn } from \"../../utils/cn\";\nimport { Label } from \"../label\";\nimport { Fieldset } from \"@base-ui/react/fieldset\";\nimport { Field as FieldBase } from \"@base-ui/react/field\";\nimport { CheckboxGroup as BaseCheckboxGroup } from \"@base-ui/react/checkbox-group\";\nimport { Checkbox as BaseCheckbox } from \"@base-ui/react/checkbox\";\n\n/** Event details passed to onCheckedChange callback. Re-exported from Base UI. */\nexport type CheckboxChangeEventDetails = Parameters<\n NonNullable<BaseCheckbox.Root.Props[\"onCheckedChange\"]>\n>[1];\n\n/** Checkbox variant definitions mapping variant names to their Tailwind classes. */\nexport const KUMO_CHECKBOX_VARIANTS = {\n variant: {\n default: {\n classes:\n \"[&:focus-within>span]:ring-kumo-focus [&:hover>span]:ring-kumo-hairline\",\n description: \"Default checkbox appearance\",\n },\n error: {\n classes: \"[&>span]:ring-kumo-danger\",\n description: \"Error state for validation failures\",\n },\n },\n} as const;\n\nexport const KUMO_CHECKBOX_DEFAULT_VARIANTS = {\n variant: \"default\",\n} as const;\n\n// Derived types from KUMO_CHECKBOX_VARIANTS\nexport type KumoCheckboxVariant = keyof typeof KUMO_CHECKBOX_VARIANTS.variant;\n\nexport interface KumoCheckboxVariantsProps {\n /**\n * Visual variant.\n * - `\"default\"` — Standard checkbox appearance\n * - `\"error\"` — Error state for validation failures\n * @default \"default\"\n */\n variant?: KumoCheckboxVariant;\n}\n\nexport function checkboxVariants({\n variant = KUMO_CHECKBOX_DEFAULT_VARIANTS.variant,\n}: KumoCheckboxVariantsProps = {}) {\n return cn(KUMO_CHECKBOX_VARIANTS.variant[variant].classes);\n}\n\n// Legacy type alias for backwards compatibility\nexport type CheckboxVariant = KumoCheckboxVariant;\n\n// Context for passing controlFirst from Group to Items\nconst CheckboxGroupContext = createContext<{ controlFirst: boolean }>({\n controlFirst: true,\n});\n\n/**\n * Single checkbox component props with accessibility guidance.\n *\n * **Accessible Name Required:** Checkbox should have one of:\n * 1. `label` prop (recommended) - built-in Field wrapper with horizontal layout\n * 2. `aria-label` - for checkboxes without visible label\n * 3. `aria-labelledby` - for custom label association\n *\n * **Note:** When used inside Checkbox.Group or Dropdown, label is optional (parent provides context).\n *\n * Missing accessible names will trigger console warnings in development (unless inside a group).\n *\n * @example\n * // Recommended: Built-in Field wrapper with label\n * <Checkbox label=\"Accept terms and conditions\" />\n *\n * @example\n * // Control-first layout (checkbox before label)\n * <Checkbox label=\"Remember me\" controlFirst={true} />\n *\n * @example\n * // Label-first layout (label before checkbox)\n * <Checkbox label=\"Enable notifications\" controlFirst={false} />\n *\n * @example\n * // Error variant (visual only, no error text for single checkboxes)\n * <Checkbox label=\"Required field\" variant=\"error\" />\n *\n * @example\n * // Without visible label (aria-label required)\n * <Checkbox aria-label=\"Select all items\" />\n *\n * @example\n * // Custom label association\n * <label id=\"terms-label\">I accept the terms</label>\n * <Checkbox aria-labelledby=\"terms-label\" />\n *\n * @example\n * // Inside Checkbox.Group (label optional)\n * <Checkbox.Group legend=\"Preferences\">\n * <Checkbox.Item value=\"email\" label=\"Email notifications\" />\n * <Checkbox.Item value=\"sms\" label=\"SMS notifications\" />\n * </Checkbox.Group>\n */\nexport type CheckboxProps = {\n /** Visual variant: \"default\" or \"error\" for validation failures (visual only, no error text) */\n variant?: CheckboxVariant;\n /** Label content for the checkbox (enables built-in Field wrapper) - can be a string or any React node */\n label?: ReactNode;\n /** Tooltip content to display next to the label via an info icon */\n labelTooltip?: ReactNode;\n /** When true (default), checkbox appears before label. When false, label appears before checkbox. */\n controlFirst?: boolean;\n /** Whether the checkbox is checked (controlled) */\n checked?: boolean;\n /** Whether the checkbox is in indeterminate state */\n indeterminate?: boolean;\n /** Whether the checkbox is disabled */\n disabled?: boolean;\n /** Callback when the checked state changes */\n onCheckedChange?: BaseCheckbox.Root.Props[\"onCheckedChange\"];\n /** Name for form submission */\n name?: string;\n /** Whether the field is required */\n required?: boolean;\n /** Additional class name */\n className?: string;\n /** Accessible label when no visible label is provided */\n \"aria-label\"?: string;\n /** ID of element that labels this checkbox */\n \"aria-labelledby\"?: string;\n};\n\n/**\n * Checkbox group component props (with built-in Fieldset and CheckboxGroup)\n *\n * Usage:\n * ```tsx\n * <Checkbox.Group\n * legend=\"Choose preferences\"\n * defaultValue={['email']}\n * error=\"You must select at least one option\"\n * >\n * <Checkbox.Item label=\"Email notifications\" value=\"email\" />\n * <Checkbox.Item label=\"SMS notifications\" value=\"sms\" />\n * </Checkbox.Group>\n * ```\n */\n/**\n * Props for Checkbox.Legend — a composable sub-component for labeling a Checkbox.Group.\n *\n * Place as a direct child of `<Checkbox.Group>` to provide a styled, accessible legend.\n * Accepts `className` for full styling control (e.g. `className=\"sr-only\"` to visually hide).\n *\n * @example\n * ```tsx\n * <Checkbox.Group>\n * <Checkbox.Legend className=\"sr-only\">Preferences</Checkbox.Legend>\n * <Checkbox.Item label=\"Email\" value=\"email\" />\n * </Checkbox.Group>\n * ```\n */\nexport interface CheckboxLegendProps {\n /** Legend content */\n children: ReactNode;\n /** Additional CSS classes (e.g. \"sr-only\" to visually hide the legend) */\n className?: string;\n}\n\nexport interface CheckboxGroupProps {\n /**\n * Legend text for the group.\n * For more control over legend styling, omit this prop and use `<Checkbox.Legend>` as a child instead.\n */\n legend?: string;\n /** Child Checkbox.Item components (and optionally a Checkbox.Legend) */\n children: ReactNode;\n /** Error message for the group (only appears in groups, not single checkboxes) */\n error?: string;\n /** Helper text for the group */\n description?: ReactNode;\n /** Values of checkboxes that should be initially checked (uncontrolled) */\n defaultValue?: string[];\n /** Values of checkboxes that should be checked (controlled) */\n value?: string[];\n /** Event handler called when checkbox values change */\n onValueChange?: (value: string[]) => void;\n /** All possible checkbox values (required for parent checkbox pattern) */\n allValues?: string[];\n /** Whether all checkboxes in the group are disabled */\n disabled?: boolean;\n /** When true (default), checkbox appears before label. When false, label appears before checkbox. */\n controlFirst?: boolean;\n /** Additional CSS classes */\n className?: string;\n}\n\n/**\n * Individual checkbox item within a group\n */\nexport type CheckboxItemProps = {\n /** Visual variant: \"default\" or \"error\" for validation failures */\n variant?: CheckboxVariant;\n /** Label text displayed next to checkbox */\n label: string;\n /** Value of the checkbox (required when used in Checkbox.Group) */\n value?: string;\n /** Additional CSS classes for the label wrapper */\n className?: string;\n checked?: boolean;\n indeterminate?: boolean;\n disabled?: boolean;\n /** Callback when the checked state changes */\n onCheckedChange?: BaseCheckbox.Root.Props[\"onCheckedChange\"];\n name?: string;\n};\n\n// Single checkbox with built-in Field\nconst CheckboxBase = forwardRef<HTMLButtonElement, CheckboxProps>(\n (\n {\n className,\n checked,\n indeterminate,\n disabled,\n variant = \"default\",\n label,\n labelTooltip,\n controlFirst = true,\n onCheckedChange,\n required,\n name,\n ...props\n },\n ref,\n ) => {\n // A11y enforcement: warn in dev if no accessible name provided\n if (process.env.NODE_ENV !== \"production\") {\n const hasLabel = Boolean(label);\n const hasAriaLabel = Boolean(props[\"aria-label\"]);\n const hasAriaLabelledBy = Boolean(props[\"aria-labelledby\"]);\n\n if (!hasLabel && !hasAriaLabel && !hasAriaLabelledBy) {\n console.warn(\n \"[Kumo Checkbox]: Checkbox must have an accessible name. Provide either:\\n\" +\n \" - label prop: <Checkbox label='Accept terms' />\\n\" +\n \" - aria-label: <Checkbox aria-label='Select item' />\\n\" +\n \" - aria-labelledby for custom label association\\n\" +\n \" Note: When used inside Checkbox.Group, label is optional\",\n );\n }\n }\n\n const checkboxControl = (\n <BaseCheckbox.Root\n ref={ref}\n name={name}\n checked={checked}\n indeterminate={indeterminate}\n disabled={disabled}\n onCheckedChange={onCheckedChange}\n className={cn(\n \"relative flex h-4 w-4 items-center justify-center rounded-sm border-0 bg-kumo-base ring focus:outline-none after:absolute after:-inset-x-3 after:-inset-y-2\",\n variant === \"error\" ? \"ring-kumo-danger\" : \"ring-kumo-hairline\",\n !disabled &&\n \"hover:ring-kumo-hairline focus:ring-kumo-focus focus:ring-2 focus-visible:ring-2 focus-visible:ring-kumo-brand\",\n \"data-[checked]:bg-kumo-contrast data-[checked]:ring-kumo-contrast data-[indeterminate]:bg-kumo-contrast data-[indeterminate]:ring-kumo-contrast\",\n disabled && \"cursor-not-allowed opacity-50\",\n className,\n )}\n {...props}\n >\n <BaseCheckbox.Indicator\n keepMounted\n className=\"flex items-center justify-center text-kumo-inverse data-[unchecked]:invisible\"\n render={(renderProps, state) => (\n <span {...renderProps}>\n {state.indeterminate ? (\n <MinusIcon weight=\"bold\" size={12} />\n ) : (\n <CheckIcon weight=\"bold\" size={12} />\n )}\n </span>\n )}\n />\n </BaseCheckbox.Root>\n );\n\n // If no label provided, return bare checkbox (for use in other components like Dropdown)\n if (!label) {\n return checkboxControl;\n }\n\n // Use Field.Root + Field.Label enclosing pattern for proper a11y association\n // See: https://base-ui.com/react/components/field\n return (\n <FieldBase.Root className=\"inline-flex\">\n <FieldBase.Label\n className={cn(\n \"!m-0 !min-h-0 !text-base inline-flex items-center gap-2\",\n controlFirst ? \"flex-row\" : \"flex-row-reverse justify-end\",\n disabled ? \"cursor-not-allowed\" : \"cursor-pointer\",\n )}\n >\n {checkboxControl}\n <Label\n showOptional={required === false}\n tooltip={labelTooltip}\n asContent\n >\n {label}\n </Label>\n </FieldBase.Label>\n </FieldBase.Root>\n );\n },\n);\n\nCheckboxBase.displayName = \"Checkbox\";\n\n// Checkbox.Item for use within Checkbox.Group\nconst CheckboxItem = forwardRef<HTMLButtonElement, CheckboxItemProps>(\n (\n {\n className,\n checked,\n indeterminate,\n disabled,\n variant = \"default\",\n label,\n value,\n onCheckedChange,\n name,\n },\n ref,\n ) => {\n const { controlFirst } = useContext(CheckboxGroupContext);\n\n return (\n <label\n className={cn(\n \"m-0 relative inline-flex items-center gap-2\",\n // Control first (default): checkbox before label\n // Label first: label before checkbox using flex-row-reverse\n !controlFirst && \"flex-row-reverse justify-end\",\n disabled ? \"cursor-not-allowed opacity-50\" : \"cursor-pointer\",\n className,\n )}\n >\n <BaseCheckbox.Root\n ref={ref}\n value={value}\n name={name}\n checked={checked}\n indeterminate={indeterminate}\n disabled={disabled}\n onCheckedChange={onCheckedChange}\n className={cn(\n \"peer relative flex h-4 w-4 items-center justify-center rounded-sm border-0 bg-kumo-base ring after:absolute after:-inset-x-3 after:-inset-y-2\",\n variant === \"error\" ? \"ring-kumo-danger\" : \"ring-kumo-hairline\",\n !disabled &&\n \"group-hover:ring-kumo-hairline hover:ring-kumo-hairline focus:ring-kumo-focus focus:ring-2 focus-visible:ring-2 focus-visible:ring-kumo-brand\",\n \"data-[checked]:bg-kumo-contrast data-[checked]:ring-kumo-contrast data-[indeterminate]:bg-kumo-contrast data-[indeterminate]:ring-kumo-contrast\",\n )}\n >\n <BaseCheckbox.Indicator\n keepMounted\n className=\"flex items-center justify-center text-kumo-inverse data-[unchecked]:invisible\"\n render={(renderProps, state) => (\n <span {...renderProps}>\n {state.indeterminate ? (\n <MinusIcon weight=\"bold\" size={12} />\n ) : (\n <CheckIcon weight=\"bold\" size={12} />\n )}\n </span>\n )}\n />\n </BaseCheckbox.Root>\n <span className=\"text-base text-kumo-default\">{label}</span>\n </label>\n );\n },\n);\n\nCheckboxItem.displayName = \"Checkbox.Item\";\n\n// Checkbox.Legend — composable legend sub-component for Checkbox.Group\nfunction CheckboxLegend({ children, className }: CheckboxLegendProps) {\n return (\n <Fieldset.Legend\n className={cn(\"text-base font-medium text-kumo-default\", className)}\n >\n {children}\n </Fieldset.Legend>\n );\n}\n\nCheckboxLegend.displayName = \"Checkbox.Legend\";\n\n// Checkbox.Group with built-in Fieldset and CheckboxGroup\nfunction CheckboxGroup({\n legend,\n children,\n error,\n description,\n defaultValue,\n value,\n onValueChange,\n allValues,\n disabled,\n controlFirst = true,\n className,\n}: CheckboxGroupProps) {\n return (\n <CheckboxGroupContext.Provider value={{ controlFirst }}>\n <BaseCheckboxGroup\n defaultValue={defaultValue}\n value={value}\n onValueChange={onValueChange}\n allValues={allValues}\n disabled={disabled}\n >\n <Fieldset.Root className={cn(\"flex flex-col gap-4\", className)}>\n {legend && (\n <Fieldset.Legend className=\"text-base font-medium text-kumo-default\">\n {legend}\n </Fieldset.Legend>\n )}\n <div className=\"flex flex-col gap-2\">{children}</div>\n {error && <p className=\"text-sm text-kumo-danger\">{error}</p>}\n {description && (\n <p className=\"text-sm text-kumo-subtle\">{description}</p>\n )}\n </Fieldset.Root>\n </BaseCheckboxGroup>\n </CheckboxGroupContext.Provider>\n );\n}\n\n// Compound component\nexport const Checkbox = Object.assign(CheckboxBase, {\n Item: CheckboxItem,\n Group: CheckboxGroup,\n Legend: CheckboxLegend,\n});\n\nCheckbox.displayName = \"Checkbox\";\n"],"names":["KUMO_CHECKBOX_VARIANTS","KUMO_CHECKBOX_DEFAULT_VARIANTS","CheckboxGroupContext","createContext","CheckboxBase","forwardRef","className","checked","indeterminate","disabled","variant","label","labelTooltip","controlFirst","onCheckedChange","required","name","props","ref","hasLabel","hasAriaLabel","hasAriaLabelledBy","checkboxControl","jsx","BaseCheckbox.Root","cn","BaseCheckbox.Indicator","renderProps","state","MinusIcon","CheckIcon","FieldBase.Root","jsxs","FieldBase.Label","Label","CheckboxItem","value","useContext","CheckboxLegend","children","Fieldset.Legend","CheckboxGroup","legend","error","description","defaultValue","onValueChange","allValues","BaseCheckboxGroup","Fieldset.Root","Checkbox"],"mappings":";;;;;;;AAeO,MAAMA,IAAyB;AAAA,EACpC,SAAS;AAAA,IACP,SAAS;AAAA,MACP,SACE;AAAA,MACF,aAAa;AAAA,IAAA;AAAA,IAEf,OAAO;AAAA,MACL,SAAS;AAAA,MACT,aAAa;AAAA,IAAA;AAAA,EACf;AAEJ,GAEaC,IAAiC;AAAA,EAC5C,SAAS;AACX,GAyBMC,IAAuBC,EAAyC;AAAA,EACpE,cAAc;AAChB,CAAC,GAgKKC,IAAeC;AAAA,EACnB,CACE;AAAA,IACE,WAAAC;AAAA,IACA,SAAAC;AAAA,IACA,eAAAC;AAAA,IACA,UAAAC;AAAA,IACA,SAAAC,IAAU;AAAA,IACV,OAAAC;AAAA,IACA,cAAAC;AAAA,IACA,cAAAC,IAAe;AAAA,IACf,iBAAAC;AAAA,IACA,UAAAC;AAAA,IACA,MAAAC;AAAA,IACA,GAAGC;AAAA,EAA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AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;AAGO,MAAMM,IAAW,OAAO,OAAO9C,GAAc;AAAA,EAClD,MAAM+B;AAAA,EACN,OAAOM;AAAA,EACP,QAAQH;AACV,CAAC;AAEDY,EAAS,cAAc;"}
|
|
1
|
+
{"version":3,"file":"checkbox-hvxfvhtx1qjo2mww.js","sources":["../../src/components/checkbox/checkbox.tsx"],"sourcesContent":["import { forwardRef, createContext, useContext, type ReactNode } from \"react\";\nimport { CheckIcon, MinusIcon } from \"@phosphor-icons/react\";\nimport { cn } from \"../../utils/cn\";\nimport { Label } from \"../label\";\nimport { Fieldset } from \"@base-ui/react/fieldset\";\nimport { Field as FieldBase } from \"@base-ui/react/field\";\nimport { CheckboxGroup as BaseCheckboxGroup } from \"@base-ui/react/checkbox-group\";\nimport { Checkbox as BaseCheckbox } from \"@base-ui/react/checkbox\";\n\n/** Event details passed to onCheckedChange callback. Re-exported from Base UI. */\nexport type CheckboxChangeEventDetails = Parameters<\n NonNullable<BaseCheckbox.Root.Props[\"onCheckedChange\"]>\n>[1];\n\n/** Checkbox variant definitions mapping variant names to their Tailwind classes. */\nexport const KUMO_CHECKBOX_VARIANTS = {\n variant: {\n default: {\n classes:\n \"[&:focus-within>span]:ring-kumo-focus [&:hover>span]:ring-kumo-hairline\",\n description: \"Default checkbox appearance\",\n },\n error: {\n classes: \"[&>span]:ring-kumo-danger\",\n description: \"Error state for validation failures\",\n },\n },\n} as const;\n\nexport const KUMO_CHECKBOX_DEFAULT_VARIANTS = {\n variant: \"default\",\n} as const;\n\n// Derived types from KUMO_CHECKBOX_VARIANTS\nexport type KumoCheckboxVariant = keyof typeof KUMO_CHECKBOX_VARIANTS.variant;\n\nexport interface KumoCheckboxVariantsProps {\n /**\n * Visual variant.\n * - `\"default\"` — Standard checkbox appearance\n * - `\"error\"` — Error state for validation failures\n * @default \"default\"\n */\n variant?: KumoCheckboxVariant;\n}\n\nexport function checkboxVariants({\n variant = KUMO_CHECKBOX_DEFAULT_VARIANTS.variant,\n}: KumoCheckboxVariantsProps = {}) {\n return cn(KUMO_CHECKBOX_VARIANTS.variant[variant].classes);\n}\n\n// Legacy type alias for backwards compatibility\nexport type CheckboxVariant = KumoCheckboxVariant;\n\n// Context for passing controlFirst from Group to Items\nconst CheckboxGroupContext = createContext<{ controlFirst: boolean }>({\n controlFirst: true,\n});\n\n/**\n * Single checkbox component props with accessibility guidance.\n *\n * **Accessible Name Required:** Checkbox should have one of:\n * 1. `label` prop (recommended) - built-in Field wrapper with horizontal layout\n * 2. `aria-label` - for checkboxes without visible label\n * 3. `aria-labelledby` - for custom label association\n *\n * **Note:** When used inside Checkbox.Group or Dropdown, label is optional (parent provides context).\n *\n * Missing accessible names will trigger console warnings in development (unless inside a group).\n *\n * @example\n * // Recommended: Built-in Field wrapper with label\n * <Checkbox label=\"Accept terms and conditions\" />\n *\n * @example\n * // Control-first layout (checkbox before label)\n * <Checkbox label=\"Remember me\" controlFirst={true} />\n *\n * @example\n * // Label-first layout (label before checkbox)\n * <Checkbox label=\"Enable notifications\" controlFirst={false} />\n *\n * @example\n * // Error variant (visual only, no error text for single checkboxes)\n * <Checkbox label=\"Required field\" variant=\"error\" />\n *\n * @example\n * // Without visible label (aria-label required)\n * <Checkbox aria-label=\"Select all items\" />\n *\n * @example\n * // Custom label association\n * <label id=\"terms-label\">I accept the terms</label>\n * <Checkbox aria-labelledby=\"terms-label\" />\n *\n * @example\n * // Inside Checkbox.Group (label optional)\n * <Checkbox.Group legend=\"Preferences\">\n * <Checkbox.Item value=\"email\" label=\"Email notifications\" />\n * <Checkbox.Item value=\"sms\" label=\"SMS notifications\" />\n * </Checkbox.Group>\n */\nexport type CheckboxProps = {\n /** Visual variant: \"default\" or \"error\" for validation failures (visual only, no error text) */\n variant?: CheckboxVariant;\n /** Label content for the checkbox (enables built-in Field wrapper) - can be a string or any React node */\n label?: ReactNode;\n /** Tooltip content to display next to the label via an info icon */\n labelTooltip?: ReactNode;\n /** When true (default), checkbox appears before label. When false, label appears before checkbox. */\n controlFirst?: boolean;\n /** Whether the checkbox is checked (controlled) */\n checked?: boolean;\n /** Whether the checkbox is in indeterminate state */\n indeterminate?: boolean;\n /** Whether the checkbox is disabled */\n disabled?: boolean;\n /** Callback when the checked state changes */\n onCheckedChange?: BaseCheckbox.Root.Props[\"onCheckedChange\"];\n /** Name for form submission */\n name?: string;\n /** Whether the field is required */\n required?: boolean;\n /** Additional class name */\n className?: string;\n /** Accessible label when no visible label is provided */\n \"aria-label\"?: string;\n /** ID of element that labels this checkbox */\n \"aria-labelledby\"?: string;\n};\n\n/**\n * Checkbox group component props (with built-in Fieldset and CheckboxGroup)\n *\n * Usage:\n * ```tsx\n * <Checkbox.Group\n * legend=\"Choose preferences\"\n * defaultValue={['email']}\n * error=\"You must select at least one option\"\n * >\n * <Checkbox.Item label=\"Email notifications\" value=\"email\" />\n * <Checkbox.Item label=\"SMS notifications\" value=\"sms\" />\n * </Checkbox.Group>\n * ```\n */\n/**\n * Props for Checkbox.Legend — a composable sub-component for labeling a Checkbox.Group.\n *\n * Place as a direct child of `<Checkbox.Group>` to provide a styled, accessible legend.\n * Accepts `className` for full styling control (e.g. `className=\"sr-only\"` to visually hide).\n *\n * @example\n * ```tsx\n * <Checkbox.Group>\n * <Checkbox.Legend className=\"sr-only\">Preferences</Checkbox.Legend>\n * <Checkbox.Item label=\"Email\" value=\"email\" />\n * </Checkbox.Group>\n * ```\n */\nexport interface CheckboxLegendProps {\n /** Legend content */\n children: ReactNode;\n /** Additional CSS classes (e.g. \"sr-only\" to visually hide the legend) */\n className?: string;\n}\n\nexport interface CheckboxGroupProps {\n /**\n * Legend text for the group.\n * For more control over legend styling, omit this prop and use `<Checkbox.Legend>` as a child instead.\n */\n legend?: string;\n /** Child Checkbox.Item components (and optionally a Checkbox.Legend) */\n children: ReactNode;\n /** Error message for the group (only appears in groups, not single checkboxes) */\n error?: string;\n /** Helper text for the group */\n description?: ReactNode;\n /** Values of checkboxes that should be initially checked (uncontrolled) */\n defaultValue?: string[];\n /** Values of checkboxes that should be checked (controlled) */\n value?: string[];\n /** Event handler called when checkbox values change */\n onValueChange?: (value: string[]) => void;\n /** All possible checkbox values (required for parent checkbox pattern) */\n allValues?: string[];\n /** Whether all checkboxes in the group are disabled */\n disabled?: boolean;\n /** When true (default), checkbox appears before label. When false, label appears before checkbox. */\n controlFirst?: boolean;\n /** Additional CSS classes */\n className?: string;\n}\n\n/**\n * Individual checkbox item within a group\n */\nexport type CheckboxItemProps = {\n /** Visual variant: \"default\" or \"error\" for validation failures */\n variant?: CheckboxVariant;\n /** Label text displayed next to checkbox */\n label: string;\n /** Value of the checkbox (required when used in Checkbox.Group) */\n value?: string;\n /** Additional CSS classes for the label wrapper */\n className?: string;\n checked?: boolean;\n indeterminate?: boolean;\n disabled?: boolean;\n /** Callback when the checked state changes */\n onCheckedChange?: BaseCheckbox.Root.Props[\"onCheckedChange\"];\n name?: string;\n};\n\n// Single checkbox with built-in Field\nconst CheckboxBase = forwardRef<HTMLButtonElement, CheckboxProps>(\n (\n {\n className,\n checked,\n indeterminate,\n disabled,\n variant = \"default\",\n label,\n labelTooltip,\n controlFirst = true,\n onCheckedChange,\n required,\n name,\n ...props\n },\n ref,\n ) => {\n // A11y enforcement: warn in dev if no accessible name provided\n if (process.env.NODE_ENV !== \"production\") {\n const hasLabel = Boolean(label);\n const hasAriaLabel = Boolean(props[\"aria-label\"]);\n const hasAriaLabelledBy = Boolean(props[\"aria-labelledby\"]);\n\n if (!hasLabel && !hasAriaLabel && !hasAriaLabelledBy) {\n console.warn(\n \"[Kumo Checkbox]: Checkbox must have an accessible name. Provide either:\\n\" +\n \" - label prop: <Checkbox label='Accept terms' />\\n\" +\n \" - aria-label: <Checkbox aria-label='Select item' />\\n\" +\n \" - aria-labelledby for custom label association\\n\" +\n \" Note: When used inside Checkbox.Group, label is optional\",\n );\n }\n }\n\n const checkboxControl = (\n <BaseCheckbox.Root\n ref={ref}\n name={name}\n checked={checked}\n indeterminate={indeterminate}\n disabled={disabled}\n onCheckedChange={onCheckedChange}\n className={cn(\n \"relative flex h-4 w-4 items-center justify-center rounded-sm border-0 bg-kumo-base ring focus:outline-none after:absolute after:-inset-x-3 after:-inset-y-2\",\n variant === \"error\" ? \"ring-kumo-danger\" : \"ring-kumo-hairline\",\n !disabled &&\n \"hover:ring-kumo-hairline focus:ring-kumo-focus focus:ring-2 focus-visible:ring-2 focus-visible:ring-kumo-brand\",\n \"data-[checked]:bg-kumo-contrast data-[checked]:ring-kumo-contrast data-[indeterminate]:bg-kumo-contrast data-[indeterminate]:ring-kumo-contrast\",\n disabled && \"cursor-not-allowed opacity-50\",\n className,\n )}\n {...props}\n >\n <BaseCheckbox.Indicator\n keepMounted\n className=\"flex items-center justify-center text-kumo-inverse data-[unchecked]:invisible\"\n render={(renderProps, state) => (\n <span {...renderProps}>\n {state.indeterminate ? (\n <MinusIcon weight=\"bold\" size={12} />\n ) : (\n <CheckIcon weight=\"bold\" size={12} />\n )}\n </span>\n )}\n />\n </BaseCheckbox.Root>\n );\n\n // If no label provided, return bare checkbox (for use in other components like Dropdown)\n if (!label) {\n return checkboxControl;\n }\n\n // Use Field.Root + Field.Label enclosing pattern for proper a11y association\n // See: https://base-ui.com/react/components/field\n return (\n <FieldBase.Root className=\"inline-flex\">\n <FieldBase.Label\n className={cn(\n \"!m-0 !min-h-0 !text-base inline-flex items-center gap-2\",\n controlFirst ? \"flex-row\" : \"flex-row-reverse justify-end\",\n disabled ? \"cursor-not-allowed\" : \"cursor-pointer\",\n )}\n >\n {checkboxControl}\n <Label\n showOptional={required === false}\n tooltip={labelTooltip}\n asContent\n >\n {label}\n </Label>\n </FieldBase.Label>\n </FieldBase.Root>\n );\n },\n);\n\nCheckboxBase.displayName = \"Checkbox\";\n\n// Checkbox.Item for use within Checkbox.Group\nconst CheckboxItem = forwardRef<HTMLButtonElement, CheckboxItemProps>(\n (\n {\n className,\n checked,\n indeterminate,\n disabled,\n variant = \"default\",\n label,\n value,\n onCheckedChange,\n name,\n },\n ref,\n ) => {\n const { controlFirst } = useContext(CheckboxGroupContext);\n\n return (\n <label\n className={cn(\n \"m-0 relative inline-flex items-center gap-2\",\n // Control first (default): checkbox before label\n // Label first: label before checkbox using flex-row-reverse\n !controlFirst && \"flex-row-reverse justify-end\",\n disabled ? \"cursor-not-allowed opacity-50\" : \"cursor-pointer\",\n className,\n )}\n >\n <BaseCheckbox.Root\n ref={ref}\n value={value}\n name={name}\n checked={checked}\n indeterminate={indeterminate}\n disabled={disabled}\n onCheckedChange={onCheckedChange}\n className={cn(\n \"peer relative flex h-4 w-4 items-center justify-center rounded-sm border-0 bg-kumo-base ring after:absolute after:-inset-x-3 after:-inset-y-2\",\n variant === \"error\" ? \"ring-kumo-danger\" : \"ring-kumo-hairline\",\n !disabled &&\n \"group-hover:ring-kumo-hairline hover:ring-kumo-hairline focus:ring-kumo-focus focus:ring-2 focus-visible:ring-2 focus-visible:ring-kumo-brand\",\n \"data-[checked]:bg-kumo-contrast data-[checked]:ring-kumo-contrast data-[indeterminate]:bg-kumo-contrast data-[indeterminate]:ring-kumo-contrast\",\n )}\n >\n <BaseCheckbox.Indicator\n keepMounted\n className=\"flex items-center justify-center text-kumo-inverse data-[unchecked]:invisible\"\n render={(renderProps, state) => (\n <span {...renderProps}>\n {state.indeterminate ? (\n <MinusIcon weight=\"bold\" size={12} />\n ) : (\n <CheckIcon weight=\"bold\" size={12} />\n )}\n </span>\n )}\n />\n </BaseCheckbox.Root>\n <span className=\"text-base text-kumo-default\">{label}</span>\n </label>\n );\n },\n);\n\nCheckboxItem.displayName = \"Checkbox.Item\";\n\n// Checkbox.Legend — composable legend sub-component for Checkbox.Group\nfunction CheckboxLegend({ children, className }: CheckboxLegendProps) {\n return (\n <Fieldset.Legend\n className={cn(\"text-base font-medium text-kumo-default\", className)}\n >\n {children}\n </Fieldset.Legend>\n );\n}\n\nCheckboxLegend.displayName = \"Checkbox.Legend\";\n\n// Checkbox.Group with built-in Fieldset and CheckboxGroup\nfunction CheckboxGroup({\n legend,\n children,\n error,\n description,\n defaultValue,\n value,\n onValueChange,\n allValues,\n disabled,\n controlFirst = true,\n className,\n}: CheckboxGroupProps) {\n return (\n <CheckboxGroupContext.Provider value={{ controlFirst }}>\n <BaseCheckboxGroup\n defaultValue={defaultValue}\n value={value}\n onValueChange={onValueChange}\n allValues={allValues}\n disabled={disabled}\n >\n <Fieldset.Root className={cn(\"flex flex-col gap-4\", className)}>\n {legend && (\n <Fieldset.Legend className=\"text-base font-medium text-kumo-default\">\n {legend}\n </Fieldset.Legend>\n )}\n <div className=\"flex flex-col gap-2\">{children}</div>\n {error && <p className=\"text-sm text-kumo-danger\">{error}</p>}\n {description && (\n <p className=\"text-sm text-kumo-subtle\">{description}</p>\n )}\n </Fieldset.Root>\n </BaseCheckboxGroup>\n </CheckboxGroupContext.Provider>\n );\n}\n\n// Compound component\nexport const Checkbox = Object.assign(CheckboxBase, {\n Item: CheckboxItem,\n Group: CheckboxGroup,\n Legend: CheckboxLegend,\n});\n\nCheckbox.displayName = \"Checkbox\";\n"],"names":["KUMO_CHECKBOX_VARIANTS","KUMO_CHECKBOX_DEFAULT_VARIANTS","CheckboxGroupContext","createContext","CheckboxBase","forwardRef","className","checked","indeterminate","disabled","variant","label","labelTooltip","controlFirst","onCheckedChange","required","name","props","ref","hasLabel","hasAriaLabel","hasAriaLabelledBy","checkboxControl","jsx","BaseCheckbox.Root","cn","BaseCheckbox.Indicator","renderProps","state","MinusIcon","CheckIcon","FieldBase.Root","jsxs","FieldBase.Label","Label","CheckboxItem","value","useContext","CheckboxLegend","children","Fieldset.Legend","CheckboxGroup","legend","error","description","defaultValue","onValueChange","allValues","BaseCheckboxGroup","Fieldset.Root","Checkbox"],"mappings":";;;;;;;AAeO,MAAMA,IAAyB;AAAA,EACpC,SAAS;AAAA,IACP,SAAS;AAAA,MACP,SACE;AAAA,MACF,aAAa;AAAA,IAAA;AAAA,IAEf,OAAO;AAAA,MACL,SAAS;AAAA,MACT,aAAa;AAAA,I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BAAAuB,EAACiB,GAAA,EAAc,WAAWxB,EAAG,uBAAuBnB,CAAS,GAC1D,UAAA;AAAA,QAAAoC,uBACEF,GAAA,EAAgB,WAAU,2CACxB,UAAAE,GACH;AAAA,QAEF,gBAAAnB,EAAC,OAAA,EAAI,WAAU,uBAAuB,UAAAgB,EAAA,CAAS;AAAA,QAC9CI,KAAS,gBAAApB,EAAC,KAAA,EAAE,WAAU,4BAA4B,UAAAoB,GAAM;AAAA,QACxDC,KACC,gBAAArB,EAAC,KAAA,EAAE,WAAU,4BAA4B,UAAAqB,EAAA,CAAY;AAAA,MAAA,EAAA,CAEzD;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;AAGO,MAAMM,IAAW,OAAO,OAAO9C,GAAc;AAAA,EAClD,MAAM+B;AAAA,EACN,OAAOM;AAAA,EACP,QAAQH;AACV,CAAC;AAEDY,EAAS,cAAc;"}
|
package/dist/chunks/{clipboard-text-f9q753udny1uyxr5.js → clipboard-text-hswydzx3iql369sd.js}
RENAMED
|
@@ -3,7 +3,7 @@ import { jsxs as c, jsx as e } from "react/jsx-runtime";
|
|
|
3
3
|
import { CheckIcon as R, CopyIcon as A } from "@phosphor-icons/react";
|
|
4
4
|
import { forwardRef as S, useState as P, useRef as _, useCallback as I } from "react";
|
|
5
5
|
import { B as O } from "./button-6by9ntsa3nj553mq.js";
|
|
6
|
-
import { i as M } from "./input-
|
|
6
|
+
import { i as M } from "./input-ncfowphv81yq7fyy.js";
|
|
7
7
|
import { c as s } from "./cn-ct4n7r74mh8y0f48.js";
|
|
8
8
|
import { V, W as j, X as B, Y as D, Z as E, _ as L, $ as U, a0 as X, a1 as K, a2 as W, a3 as F, a4 as Y, a5 as Z } from "./vendor-base-ui-ie71jahf0czyf58j.js";
|
|
9
9
|
const T = V(), y = {
|
|
@@ -187,4 +187,4 @@ H.displayName = "ClipboardText";
|
|
|
187
187
|
export {
|
|
188
188
|
H as C
|
|
189
189
|
};
|
|
190
|
-
//# sourceMappingURL=clipboard-text-
|
|
190
|
+
//# sourceMappingURL=clipboard-text-hswydzx3iql369sd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clipboard-text-f9q753udny1uyxr5.js","sources":["../../src/components/clipboard-text/clipboard-text.tsx"],"sourcesContent":["import { CheckIcon, CopyIcon } from \"@phosphor-icons/react\";\nimport { forwardRef, useCallback, useRef, useState } from \"react\";\nimport { Toast } from \"@base-ui/react/toast\";\nimport { Tooltip } from \"@base-ui/react/tooltip\";\nimport { Button } from \"../button\";\nimport { inputVariants } from \"../input\";\nimport { cn } from \"../../utils/cn\";\n\n// Create a toast manager for anchored \"Copied\" toasts\nconst clipboardToastManager = Toast.createToastManager();\n\n/** ClipboardText size variant definitions mapping sizes to their Tailwind classes. */\nexport const KUMO_CLIPBOARD_TEXT_VARIANTS = {\n size: {\n sm: {\n classes: \"text-xs\",\n buttonSize: \"sm\" as const,\n description: \"Small clipboard text for compact UIs\",\n },\n base: {\n classes: \"text-sm\",\n buttonSize: \"base\" as const,\n description: \"Default clipboard text size\",\n },\n lg: {\n classes: \"text-sm\",\n buttonSize: \"lg\" as const,\n description: \"Large clipboard text for prominent display\",\n },\n },\n} as const;\n\nexport const KUMO_CLIPBOARD_TEXT_DEFAULT_VARIANTS = {\n size: \"lg\",\n} as const;\n\nconst clipboardTextAnimations = {\n slide: {\n initial:\n \"pointer-events-none absolute inset-0 flex items-center justify-center opacity-0 translate-y-full\",\n animate: \"translate-y-0 opacity-100\",\n end: \"pointer-events-none absolute inset-0 flex items-center justify-center opacity-0 -translate-y-full\",\n },\n} as const;\n\n// Derived types from KUMO_CLIPBOARD_TEXT_VARIANTS\nexport type KumoClipboardTextSize =\n keyof typeof KUMO_CLIPBOARD_TEXT_VARIANTS.size;\n\nexport interface KumoClipboardTextVariantsProps {\n /**\n * Size of the clipboard text field.\n * - `\"sm\"` — Small clipboard text for compact UIs\n * - `\"base\"` — Default clipboard text size\n * - `\"lg\"` — Large clipboard text for prominent display\n * @default \"lg\"\n */\n size?: KumoClipboardTextSize;\n}\n\nexport function clipboardTextVariants({\n size = KUMO_CLIPBOARD_TEXT_DEFAULT_VARIANTS.size,\n}: KumoClipboardTextVariantsProps = {}) {\n return cn(\n // Base styles\n \"flex items-center overflow-hidden bg-kumo-base px-0 font-mono\",\n // Apply size styles from KUMO_CLIPBOARD_TEXT_VARIANTS\n KUMO_CLIPBOARD_TEXT_VARIANTS.size[size].classes,\n );\n}\n\n// Legacy type alias for backwards compatibility\nexport type ClipboardTextSize = KumoClipboardTextSize;\n\n/**\n * ClipboardText component props.\n *\n * @example\n * ```tsx\n * <ClipboardText text=\"sk_live_abc123\" />\n * <ClipboardText text=\"npm install @cloudflare/kumo\" size=\"sm\" />\n * ```\n */\nexport interface ClipboardTextProps extends KumoClipboardTextVariantsProps {\n /** The text to display and copy to clipboard. */\n text: string;\n /** If provided, this text will be copied to clipboard instead of the `text` prop. */\n textToCopy?: string;\n /** Additional CSS classes merged via `cn()`. */\n className?: string;\n /** Callback fired after text is copied to clipboard. */\n onCopy?: () => void;\n /**\n * Tooltip config. Shows tooltip on hover, anchored toast on click.\n * @example\n * ```tsx\n * <ClipboardText\n * text=\"abc123\"\n * tooltip={{ text: \"Copy\", copiedText: \"Copied!\", side: \"top\" }}\n * />\n * ```\n */\n tooltip?: {\n /** Text shown in tooltip on hover. @default \"Copy\" */\n text?: string;\n /** Text shown in toast after copying. @default \"Copied\" */\n copiedText?: string;\n /** Tooltip/toast placement. @default \"top\" */\n side?: \"top\" | \"bottom\" | \"left\" | \"right\";\n };\n /** Accessible labels for i18n. */\n labels?: {\n /** @default \"Copy to clipboard\" */\n copyAction?: string;\n };\n}\n\n/**\n * Anchored toasts viewport - renders \"Copied\" toasts anchored to buttons\n */\nfunction AnchoredToasts() {\n const { toasts } = Toast.useToastManager();\n return (\n <Toast.Viewport className=\"pointer-events-none fixed inset-0 isolate\">\n {toasts.map((toast) => (\n <Toast.Positioner key={toast.id} toast={toast} className=\"absolute\">\n <Toast.Root\n toast={toast}\n className={cn(\n \"flex origin-[var(--transform-origin)] flex-col rounded-md bg-kumo-base px-3 py-1.5 text-xs text-kumo-default font-sans\",\n \"shadow-lg shadow-kumo-tip-shadow outline outline-kumo-fill\",\n )}\n >\n <Toast.Description />\n </Toast.Root>\n </Toast.Positioner>\n ))}\n </Toast.Viewport>\n );\n}\n\n/**\n * Internal wrapper that provides Toast context when tooltip is enabled.\n */\nfunction TooltipWrapper({ children }: { children: React.ReactNode }) {\n return (\n <Tooltip.Provider>\n <Toast.Provider toastManager={clipboardToastManager}>\n <AnchoredToasts />\n {children}\n </Toast.Provider>\n </Tooltip.Provider>\n );\n}\n\n/**\n * Read-only text field with a one-click copy-to-clipboard button.\n *\n * @example\n * ```tsx\n * <ClipboardText text=\"0c239dd2\" />\n * ```\n */\nexport const ClipboardText = forwardRef<HTMLDivElement, ClipboardTextProps>(\n (\n {\n text,\n textToCopy,\n className,\n size = KUMO_CLIPBOARD_TEXT_DEFAULT_VARIANTS.size,\n onCopy,\n tooltip,\n labels: { copyAction = \"Copy to clipboard\" } = {},\n },\n ref,\n ) => {\n const [copied, setCopied] = useState(false);\n const buttonRef = useRef<HTMLButtonElement | null>(null);\n const sizeConfig = KUMO_CLIPBOARD_TEXT_VARIANTS.size[size];\n\n // Destructure tooltip config with defaults\n const {\n text: tooltipText = \"Copy\",\n copiedText = \"Copied\",\n side: tooltipSide = \"top\",\n } = tooltip ?? {};\n\n const copyToClipboard = useCallback(async () => {\n try {\n if (\n typeof navigator !== \"undefined\" &&\n navigator.clipboard &&\n typeof navigator.clipboard.writeText === \"function\"\n ) {\n await navigator.clipboard.writeText(textToCopy ?? text);\n } else if (typeof document !== \"undefined\") {\n // Fallback for older browsers\n const textarea = document.createElement(\"textarea\");\n textarea.value = textToCopy ?? text;\n textarea.setAttribute(\"readonly\", \"\");\n textarea.style.position = \"absolute\";\n textarea.style.left = \"-9999px\";\n document.body.appendChild(textarea);\n const selection = document.getSelection();\n const previousRange = selection?.rangeCount\n ? selection.getRangeAt(0)\n : null;\n textarea.select();\n try {\n document.execCommand(\"copy\");\n } finally {\n document.body.removeChild(textarea);\n if (previousRange) {\n selection?.removeAllRanges();\n selection?.addRange(previousRange);\n }\n }\n }\n\n setCopied(true);\n\n // Show anchored toast if tooltip mode is enabled\n if (tooltip) {\n clipboardToastManager.add({\n description: copiedText,\n positionerProps: {\n anchor: buttonRef.current,\n side: tooltipSide,\n sideOffset: 8,\n },\n timeout: 1500,\n onClose() {\n setCopied(false);\n },\n });\n } else {\n // Reset copied state after delay when no tooltip\n setTimeout(() => setCopied(false), 1500);\n }\n\n onCopy?.();\n } catch (error) {\n console.warn(\"Clipboard copy failed\", error);\n }\n }, [text, onCopy, tooltip, copiedText, tooltipSide]);\n\n const copyButton = (\n <Button\n ref={buttonRef}\n size={sizeConfig.buttonSize}\n variant=\"ghost\"\n className={cn(\n \"rounded-l-none rounded-r-[inherit] border-l! border-kumo-line! px-3 relative isolate overflow-hidden transition-all duration-200\",\n \"focus:ring-inset focus:ring-kumo-focus/50\",\n \"focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-kumo-brand\",\n )}\n onClick={copyToClipboard}\n aria-label={copyAction}\n >\n <span\n className={cn(\n \"flex items-center gap-1 transition-all duration-200\",\n copied\n ? clipboardTextAnimations.slide.animate\n : clipboardTextAnimations.slide.initial,\n )}\n >\n <CheckIcon />\n </span>\n <span\n className={cn(\n \"flex items-center justify-center transition-all duration-200\",\n copied\n ? clipboardTextAnimations.slide.end\n : clipboardTextAnimations.slide.animate,\n )}\n >\n <CopyIcon />\n </span>\n </Button>\n );\n\n return (\n <div\n ref={ref}\n className={cn(\n inputVariants({ size: sizeConfig.buttonSize }),\n clipboardTextVariants({ size }),\n className,\n )}\n >\n <span className=\"grow truncate ps-4 pe-2\">{text}</span>\n {tooltip ? (\n <TooltipWrapper>\n <Tooltip.Root\n disabled={copied}\n onOpenChange={(open, eventDetails) => {\n // Prevent tooltip from closing when button is clicked\n if (eventDetails.reason === \"trigger-press\") {\n eventDetails.cancel();\n }\n }}\n >\n <Tooltip.Trigger render={copyButton} />\n <Tooltip.Portal>\n <Tooltip.Positioner side={tooltipSide} sideOffset={8}>\n <Tooltip.Popup\n className={cn(\n \"flex origin-[var(--transform-origin)] flex-col rounded-md bg-kumo-base px-3 py-1.5 text-xs text-kumo-default\",\n \"shadow-lg shadow-kumo-tip-shadow outline outline-kumo-fill\",\n )}\n >\n {tooltipText}\n </Tooltip.Popup>\n </Tooltip.Positioner>\n </Tooltip.Portal>\n </Tooltip.Root>\n </TooltipWrapper>\n ) : (\n copyButton\n )}\n <span className=\"sr-only\" aria-live=\"polite\">\n {copied ? copiedText : \"\"}\n </span>\n </div>\n );\n },\n);\n\nClipboardText.displayName = \"ClipboardText\";\n"],"names":["clipboardToastManager","Toast.createToastManager","KUMO_CLIPBOARD_TEXT_VARIANTS","KUMO_CLIPBOARD_TEXT_DEFAULT_VARIANTS","clipboardTextAnimations","clipboardTextVariants","size","cn","AnchoredToasts","toasts","Toast.useToastManager","Toast.Viewport","toast","Toast.Positioner","jsx","Toast.Root","Toast.Description","TooltipWrapper","children","Tooltip.Provider","Toast.Provider","ClipboardText","forwardRef","text","textToCopy","className","onCopy","tooltip","copyAction","ref","copied","setCopied","useState","buttonRef","useRef","sizeConfig","tooltipText","copiedText","tooltipSide","copyToClipboard","useCallback","textarea","selection","previousRange","error","copyButton","jsxs","Button","CheckIcon","CopyIcon","inputVariants","Tooltip.Root","open","eventDetails","Tooltip.Trigger","Tooltip.Portal","Tooltip.Positioner","Tooltip.Popup"],"mappings":";;;;;;;;AASA,MAAMA,IAAwBC,EAAM,GAGvBC,IAA+B;AAAA,EAC1C,MAAM;AAAA,IACJ,IAAI;AAAA,MACF,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,aAAa;AAAA,IAAA;AAAA,IAEf,MAAM;AAAA,MACJ,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,aAAa;AAAA,IAAA;AAAA,IAEf,IAAI;AAA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A,EAAa,OAAA;AAAA,cAEjB;AAAA,cAEA,UAAA;AAAA,gBAAA,gBAAAvC,EAACwC,GAAA,EAAgB,QAAQT,EAAA,CAAY;AAAA,gBACrC,gBAAA/B,EAACyC,GAAA,EACC,UAAA,gBAAAzC,EAAC0C,GAAA,EAAmB,MAAMlB,GAAa,YAAY,GACjD,UAAA,gBAAAxB;AAAA,kBAAC2C;AAAAA,kBAAA;AAAA,oBACC,WAAWlD;AAAA,sBACT;AAAA,sBACA;AAAA,oBAAA;AAAA,oBAGD,UAAA6B;AAAA,kBAAA;AAAA,gBAAA,GAEL,EAAA,CACF;AAAA,cAAA;AAAA,YAAA;AAAA,UAAA,GAEJ,IAEAS;AAAA,UAEF,gBAAA/B,EAAC,UAAK,WAAU,WAAU,aAAU,UACjC,UAAAgB,IAASO,IAAa,GAAA,CACzB;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;AAEAhB,EAAc,cAAc;"}
|
|
1
|
+
{"version":3,"file":"clipboard-text-hswydzx3iql369sd.js","sources":["../../src/components/clipboard-text/clipboard-text.tsx"],"sourcesContent":["import { CheckIcon, CopyIcon } from \"@phosphor-icons/react\";\nimport { forwardRef, useCallback, useRef, useState } from \"react\";\nimport { Toast } from \"@base-ui/react/toast\";\nimport { Tooltip } from \"@base-ui/react/tooltip\";\nimport { Button } from \"../button\";\nimport { inputVariants } from \"../input\";\nimport { cn } from \"../../utils/cn\";\n\n// Create a toast manager for anchored \"Copied\" toasts\nconst clipboardToastManager = Toast.createToastManager();\n\n/** ClipboardText size variant definitions mapping sizes to their Tailwind classes. */\nexport const KUMO_CLIPBOARD_TEXT_VARIANTS = {\n size: {\n sm: {\n classes: \"text-xs\",\n buttonSize: \"sm\" as const,\n description: \"Small clipboard text for compact UIs\",\n },\n base: {\n classes: \"text-sm\",\n buttonSize: \"base\" as const,\n description: \"Default clipboard text size\",\n },\n lg: {\n classes: \"text-sm\",\n buttonSize: \"lg\" as const,\n description: \"Large clipboard text for prominent display\",\n },\n },\n} as const;\n\nexport const KUMO_CLIPBOARD_TEXT_DEFAULT_VARIANTS = {\n size: \"lg\",\n} as const;\n\nconst clipboardTextAnimations = {\n slide: {\n initial:\n \"pointer-events-none absolute inset-0 flex items-center justify-center opacity-0 translate-y-full\",\n animate: \"translate-y-0 opacity-100\",\n end: \"pointer-events-none absolute inset-0 flex items-center justify-center opacity-0 -translate-y-full\",\n },\n} as const;\n\n// Derived types from KUMO_CLIPBOARD_TEXT_VARIANTS\nexport type KumoClipboardTextSize =\n keyof typeof KUMO_CLIPBOARD_TEXT_VARIANTS.size;\n\nexport interface KumoClipboardTextVariantsProps {\n /**\n * Size of the clipboard text field.\n * - `\"sm\"` — Small clipboard text for compact UIs\n * - `\"base\"` — Default clipboard text size\n * - `\"lg\"` — Large clipboard text for prominent display\n * @default \"lg\"\n */\n size?: KumoClipboardTextSize;\n}\n\nexport function clipboardTextVariants({\n size = KUMO_CLIPBOARD_TEXT_DEFAULT_VARIANTS.size,\n}: KumoClipboardTextVariantsProps = {}) {\n return cn(\n // Base styles\n \"flex items-center overflow-hidden bg-kumo-base px-0 font-mono\",\n // Apply size styles from KUMO_CLIPBOARD_TEXT_VARIANTS\n KUMO_CLIPBOARD_TEXT_VARIANTS.size[size].classes,\n );\n}\n\n// Legacy type alias for backwards compatibility\nexport type ClipboardTextSize = KumoClipboardTextSize;\n\n/**\n * ClipboardText component props.\n *\n * @example\n * ```tsx\n * <ClipboardText text=\"sk_live_abc123\" />\n * <ClipboardText text=\"npm install @cloudflare/kumo\" size=\"sm\" />\n * ```\n */\nexport interface ClipboardTextProps extends KumoClipboardTextVariantsProps {\n /** The text to display and copy to clipboard. */\n text: string;\n /** If provided, this text will be copied to clipboard instead of the `text` prop. */\n textToCopy?: string;\n /** Additional CSS classes merged via `cn()`. */\n className?: string;\n /** Callback fired after text is copied to clipboard. */\n onCopy?: () => void;\n /**\n * Tooltip config. Shows tooltip on hover, anchored toast on click.\n * @example\n * ```tsx\n * <ClipboardText\n * text=\"abc123\"\n * tooltip={{ text: \"Copy\", copiedText: \"Copied!\", side: \"top\" }}\n * />\n * ```\n */\n tooltip?: {\n /** Text shown in tooltip on hover. @default \"Copy\" */\n text?: string;\n /** Text shown in toast after copying. @default \"Copied\" */\n copiedText?: string;\n /** Tooltip/toast placement. @default \"top\" */\n side?: \"top\" | \"bottom\" | \"left\" | \"right\";\n };\n /** Accessible labels for i18n. */\n labels?: {\n /** @default \"Copy to clipboard\" */\n copyAction?: string;\n };\n}\n\n/**\n * Anchored toasts viewport - renders \"Copied\" toasts anchored to buttons\n */\nfunction AnchoredToasts() {\n const { toasts } = Toast.useToastManager();\n return (\n <Toast.Viewport className=\"pointer-events-none fixed inset-0 isolate\">\n {toasts.map((toast) => (\n <Toast.Positioner key={toast.id} toast={toast} className=\"absolute\">\n <Toast.Root\n toast={toast}\n className={cn(\n \"flex origin-[var(--transform-origin)] flex-col rounded-md bg-kumo-base px-3 py-1.5 text-xs text-kumo-default font-sans\",\n \"shadow-lg shadow-kumo-tip-shadow outline outline-kumo-fill\",\n )}\n >\n <Toast.Description />\n </Toast.Root>\n </Toast.Positioner>\n ))}\n </Toast.Viewport>\n );\n}\n\n/**\n * Internal wrapper that provides Toast context when tooltip is enabled.\n */\nfunction TooltipWrapper({ children }: { children: React.ReactNode }) {\n return (\n <Tooltip.Provider>\n <Toast.Provider toastManager={clipboardToastManager}>\n <AnchoredToasts />\n {children}\n </Toast.Provider>\n </Tooltip.Provider>\n );\n}\n\n/**\n * Read-only text field with a one-click copy-to-clipboard button.\n *\n * @example\n * ```tsx\n * <ClipboardText text=\"0c239dd2\" />\n * ```\n */\nexport const ClipboardText = forwardRef<HTMLDivElement, ClipboardTextProps>(\n (\n {\n text,\n textToCopy,\n className,\n size = KUMO_CLIPBOARD_TEXT_DEFAULT_VARIANTS.size,\n onCopy,\n tooltip,\n labels: { copyAction = \"Copy to clipboard\" } = {},\n },\n ref,\n ) => {\n const [copied, setCopied] = useState(false);\n const buttonRef = useRef<HTMLButtonElement | null>(null);\n const sizeConfig = KUMO_CLIPBOARD_TEXT_VARIANTS.size[size];\n\n // Destructure tooltip config with defaults\n const {\n text: tooltipText = \"Copy\",\n copiedText = \"Copied\",\n side: tooltipSide = \"top\",\n } = tooltip ?? {};\n\n const copyToClipboard = useCallback(async () => {\n try {\n if (\n typeof navigator !== \"undefined\" &&\n navigator.clipboard &&\n typeof navigator.clipboard.writeText === \"function\"\n ) {\n await navigator.clipboard.writeText(textToCopy ?? text);\n } else if (typeof document !== \"undefined\") {\n // Fallback for older browsers\n const textarea = document.createElement(\"textarea\");\n textarea.value = textToCopy ?? text;\n textarea.setAttribute(\"readonly\", \"\");\n textarea.style.position = \"absolute\";\n textarea.style.left = \"-9999px\";\n document.body.appendChild(textarea);\n const selection = document.getSelection();\n const previousRange = selection?.rangeCount\n ? selection.getRangeAt(0)\n : null;\n textarea.select();\n try {\n document.execCommand(\"copy\");\n } finally {\n document.body.removeChild(textarea);\n if (previousRange) {\n selection?.removeAllRanges();\n selection?.addRange(previousRange);\n }\n }\n }\n\n setCopied(true);\n\n // Show anchored toast if tooltip mode is enabled\n if (tooltip) {\n clipboardToastManager.add({\n description: copiedText,\n positionerProps: {\n anchor: buttonRef.current,\n side: tooltipSide,\n sideOffset: 8,\n },\n timeout: 1500,\n onClose() {\n setCopied(false);\n },\n });\n } else {\n // Reset copied state after delay when no tooltip\n setTimeout(() => setCopied(false), 1500);\n }\n\n onCopy?.();\n } catch (error) {\n console.warn(\"Clipboard copy failed\", error);\n }\n }, [text, onCopy, tooltip, copiedText, tooltipSide]);\n\n const copyButton = (\n <Button\n ref={buttonRef}\n size={sizeConfig.buttonSize}\n variant=\"ghost\"\n className={cn(\n \"rounded-l-none rounded-r-[inherit] border-l! border-kumo-line! px-3 relative isolate overflow-hidden transition-all duration-200\",\n \"focus:ring-inset focus:ring-kumo-focus/50\",\n \"focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-kumo-brand\",\n )}\n onClick={copyToClipboard}\n aria-label={copyAction}\n >\n <span\n className={cn(\n \"flex items-center gap-1 transition-all duration-200\",\n copied\n ? clipboardTextAnimations.slide.animate\n : clipboardTextAnimations.slide.initial,\n )}\n >\n <CheckIcon />\n </span>\n <span\n className={cn(\n \"flex items-center justify-center transition-all duration-200\",\n copied\n ? clipboardTextAnimations.slide.end\n : clipboardTextAnimations.slide.animate,\n )}\n >\n <CopyIcon />\n </span>\n </Button>\n );\n\n return (\n <div\n ref={ref}\n className={cn(\n inputVariants({ size: sizeConfig.buttonSize }),\n clipboardTextVariants({ size }),\n className,\n )}\n >\n <span className=\"grow truncate ps-4 pe-2\">{text}</span>\n {tooltip ? (\n <TooltipWrapper>\n <Tooltip.Root\n disabled={copied}\n onOpenChange={(open, eventDetails) => {\n // Prevent tooltip from closing when button is clicked\n if (eventDetails.reason === \"trigger-press\") {\n eventDetails.cancel();\n }\n }}\n >\n <Tooltip.Trigger render={copyButton} />\n <Tooltip.Portal>\n <Tooltip.Positioner side={tooltipSide} sideOffset={8}>\n <Tooltip.Popup\n className={cn(\n \"flex origin-[var(--transform-origin)] flex-col rounded-md bg-kumo-base px-3 py-1.5 text-xs text-kumo-default\",\n \"shadow-lg shadow-kumo-tip-shadow outline outline-kumo-fill\",\n )}\n >\n {tooltipText}\n </Tooltip.Popup>\n </Tooltip.Positioner>\n </Tooltip.Portal>\n </Tooltip.Root>\n </TooltipWrapper>\n ) : (\n copyButton\n )}\n <span className=\"sr-only\" aria-live=\"polite\">\n {copied ? copiedText : \"\"}\n </span>\n </div>\n );\n },\n);\n\nClipboardText.displayName = \"ClipboardText\";\n"],"names":["clipboardToastManager","Toast.createToastManager","KUMO_CLIPBOARD_TEXT_VARIANTS","KUMO_CLIPBOARD_TEXT_DEFAULT_VARIANTS","clipboardTextAnimations","clipboardTextVariants","size","cn","AnchoredToasts","toasts","Toast.useToastManager","Toast.Viewport","toast","Toast.Positioner","jsx","Toast.Root","Toast.Description","TooltipWrapper","children","Tooltip.Provider","Toast.Provider","ClipboardText","forwardRef","text","textToCopy","className","onCopy","tooltip","copyAction","ref","copied","setCopied","useState","buttonRef","useRef","sizeConfig","tooltipText","copiedText","tooltipSide","copyToClipboard","useCallback","textarea","selection","previousRange","error","copyButton","jsxs","Button","CheckIcon","CopyIcon","inputVariants","Tooltip.Root","open","eventDetails","Tooltip.Trigger","Tooltip.Portal","Tooltip.Positioner","Tooltip.Popup"],"mappings":";;;;;;;;AASA,MAAMA,IAAwBC,EAAM,GAGvBC,IAA+B;AAAA,EAC1C,MAAM;AAAA,IACJ,IAAI;AAAA,MACF,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,aAAa;AAAA,IAAA;AAAA,IAEf,MAAM;AAAA,MACJ,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,aAAa;AAAA,IAAA;AAAA,IAEf,IAAI;AAAA,MACF,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,aAAa;AAAA,IAAA;AAAA,EACf;AAEJ,GAEaC,IAAuC;AAAA,EAClD,MAAM;AACR,GAEMC,IAA0B;AAAA,EAC9B,OAAO;AAAA,IACL,SACE;AAAA,IACF,SAAS;AAAA,IACT,KAAK;AAAA,EAAA;AAET;AAiBO,SAASC,EAAsB;AAAA,EACpC,MAAAC,IAAOH,EAAqC;AAC9C,IAAoC,IAAI;AACtC,SAAOI;AAAA;AAAA,IAEL;AAAA;AAAA,IAEAL,EAA6B,KAAKI,CAAI,EAAE;AAAA,EAAA;AAE5C;AAmDA,SAASE,IAAiB;AACxB,QAAM,EAAE,QAAAC,EAAA,IAAWC,EAAM;AACzB,2BACGC,GAAA,EAAe,WAAU,6CACvB,UAAAF,EAAO,IAAI,CAACG,wBACVC,GAAA,EAAgC,OAAAD,GAAc,WAAU,YACvD,UAAA,gBAAAE;AAAA,IAACC;AAAAA,IAAA;AAAA,MACC,OAAAH;AAAA,MACA,WAAWL;AAAA,QACT;AAAA,QACA;AAAA,MAAA;AAAA,MAGF,UAAA,gBAAAO,EAACE,GAAA,CAAA,C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