@krizaka/ui 4.5.0 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/account-settings.js +56 -43
  2. package/dist/account-settings.js.map +1 -1
  3. package/dist/{chunk-CZHPWLNW.js → chunk-WKQ5CB3I.js} +18 -5
  4. package/dist/chunk-WKQ5CB3I.js.map +1 -0
  5. package/dist/columns.js +3 -1
  6. package/dist/columns.js.map +1 -1
  7. package/dist/comparison-table.js +3 -3
  8. package/dist/comparison-table.js.map +1 -1
  9. package/dist/filter-bar.d.ts +3 -3
  10. package/dist/kind-config-editor.js +1 -1
  11. package/dist/nav-bar.d.ts +1 -1
  12. package/dist/notification-preferences.js +1 -1
  13. package/dist/router.js +2 -2
  14. package/dist/router.js.map +1 -1
  15. package/dist/schema-form.js +1 -1
  16. package/dist/shop-composer.d.ts +2 -2
  17. package/dist/site-cahier.d.ts +2 -0
  18. package/dist/site-cahier.js +2 -1
  19. package/dist/site-cahier.js.map +1 -1
  20. package/dist/site-footer.d.ts +52 -6
  21. package/dist/site-footer.js +98 -60
  22. package/dist/site-footer.js.map +1 -1
  23. package/dist/{sites-iJkCPeiH.d.ts → sites-BPshUouf.d.ts} +2 -2
  24. package/dist/switch.d.ts +25 -3
  25. package/dist/switch.js +1 -1
  26. package/dist/virtual.d.ts +3 -3
  27. package/package.json +11 -11
  28. package/registry/app-frame.json +1 -1
  29. package/registry/columns.json +1 -1
  30. package/registry/comparison-table.json +1 -1
  31. package/registry/examples/site-footer/family.d.ts +4 -0
  32. package/registry/examples/site-footer/family.js +25 -0
  33. package/registry/examples/site-footer/family.tsx +28 -0
  34. package/registry/examples/switch/row.d.ts +4 -0
  35. package/registry/examples/switch/row.js +14 -0
  36. package/registry/examples/switch/row.tsx +13 -0
  37. package/registry/index.json +9 -9
  38. package/registry/map.json +1 -1
  39. package/registry/nav-bar.json +1 -1
  40. package/registry/rail-nav.json +1 -1
  41. package/registry/router.json +1 -1
  42. package/registry/shop.json +1 -1
  43. package/registry/site-footer.json +306 -5
  44. package/registry/switch.json +43 -6
  45. package/dist/chunk-CZHPWLNW.js.map +0 -1
@@ -40,7 +40,7 @@
40
40
  ],
41
41
  "bestPractices": [
42
42
  "Name the setting, not the state: “Autoplay”, not “Turn autoplay on”.",
43
- "Put the label first and the switch at the end of the line (`Field.Label htmlFor`), with a hint when it helps."
43
+ "Give it `children` (and a `description`): the words at the start, the switch at the end, the whole row clickable. There is no alignment prop — start and end follow the reading direction."
44
44
  ],
45
45
  "accessibility": {
46
46
  "keyboard": [
@@ -51,6 +51,7 @@
51
51
  ],
52
52
  "notes": [
53
53
  "Radix Switch: `role=\"switch\"` with `aria-checked`.",
54
+ "With `children` the row is a `<label>`: one control, named by the words, hinted by `description` (`aria-describedby`), never read twice.",
54
55
  "`label` names it when no visible label does; otherwise use `Field.Label htmlFor` and `aria-describedby` for the hint."
55
56
  ]
56
57
  },
@@ -65,8 +66,22 @@
65
66
  "props": [
66
67
  {
67
68
  "component": "Switch",
68
- "description": "An on/off switch: `checked`/`defaultChecked` + `onCheckedChange`.",
69
+ "description": "An on/off switch: `checked`/`defaultChecked` + `onCheckedChange`. With `children` (and a `description`) it draws its\nown settings row: the words at the start, the switch at the end (mirrored under `dir=\"rtl\"`), the whole row\nclickable, 44 px high or more. It stays one control with one name (`children`) and one hint (`description`).",
69
70
  "props": [
71
+ {
72
+ "name": "children",
73
+ "type": "ReactNode",
74
+ "default": null,
75
+ "description": "The visible words, at the start of the row: they name the switch and the whole row toggles it.",
76
+ "required": false
77
+ },
78
+ {
79
+ "name": "description",
80
+ "type": "ReactNode",
81
+ "default": null,
82
+ "description": "A line under the words, read with the switch as its hint.",
83
+ "required": false
84
+ },
70
85
  {
71
86
  "name": "invalid",
72
87
  "type": "boolean",
@@ -127,10 +142,18 @@
127
142
  {
128
143
  "name": "with-label",
129
144
  "title": "With a visible label",
130
- "description": "A label and a hint on the same line.",
145
+ "description": "A `Field.Label` and a hint on the same line.",
131
146
  "path": "examples/switch/with-label.tsx",
132
147
  "module": "@krizaka/ui/registry/examples/switch/with-label",
133
148
  "code": "import { Field } from \"@krizaka/ui/field\";\nimport { Switch } from \"@krizaka/ui/switch\";\n\n// Named by a visible label (`Field.Label htmlFor`), with a hint.\nexport default function SwitchWithLabel() {\n return (\n <Field.Root className=\"w-80\">\n <div className=\"flex items-center justify-between gap-4\">\n <Field.Label htmlFor=\"digest\" className=\"text-sm text-fg\">\n Weekly digest\n </Field.Label>\n <Switch id=\"digest\" defaultChecked aria-describedby=\"digest-hint\" />\n </div>\n <Field.Hint id=\"digest-hint\">One email on Monday with what you missed.</Field.Hint>\n </Field.Root>\n );\n}\n"
149
+ },
150
+ {
151
+ "name": "row",
152
+ "title": "Settings row",
153
+ "description": "`children` and `description`: text at the start, switch at the end, the whole row clickable (44 px).",
154
+ "path": "examples/switch/row.tsx",
155
+ "module": "@krizaka/ui/registry/examples/switch/row",
156
+ "code": "import { Switch } from \"@krizaka/ui/switch\";\n\n// A settings row: `children` and `description` at the start, the switch at the end, the whole row clickable.\nexport default function SwitchRow() {\n return (\n <div className=\"flex w-80 flex-col\">\n <Switch defaultChecked description=\"One email on Monday with what you missed.\">\n Weekly digest\n </Switch>\n <Switch description=\"Plays the next video when this one ends.\">Autoplay</Switch>\n </div>\n );\n}\n"
134
157
  }
135
158
  ]
136
159
  },
@@ -259,11 +282,11 @@
259
282
  },
260
283
  {
261
284
  "path": "switch/meta.ts",
262
- "content": "import type { ComponentMeta } from \"../meta\";\n\nexport const meta = {\n title: \"Switch\",\n summary: \"An on/off setting that applies at once.\",\n status: \"beta\",\n category: \"forms\",\n domain: \"forms\",\n platforms: \"both\",\n parity: { desktop: \"web\" },\n whenToUse: [\"For a setting that takes effect immediately: autoplay, notifications, a weekly digest.\"],\n whenNotToUse: [\n { when: \"For a choice submitted with a form, or an agreement.\", use: \"checkbox\" },\n { when: \"For more than two states.\", use: \"radio-group\" },\n { when: \"To run an action.\", use: \"button\" },\n ],\n bestPractices: [\n \"Name the setting, not the state: “Autoplay”, not “Turn autoplay on”.\",\n \"Put the label first and the switch at the end of the line (`Field.Label htmlFor`), with a hint when it helps.\",\n ],\n accessibility: {\n keyboard: [{ keys: \"Space\", action: \"Toggles the switch.\" }],\n notes: [\n \"Radix Switch: `role=\\\"switch\\\"` with `aria-checked`.\",\n \"`label` names it when no visible label does; otherwise use `Field.Label htmlFor` and `aria-describedby` for the hint.\",\n ],\n },\n related: [\"checkbox\", \"field\", \"radio-group\"],\n web: {\n imports: [\"Switch\"],\n examples: [\n { name: \"off\", title: \"Off\", description: \"Named by `label`.\" },\n { name: \"on\", title: \"On\", description: \"`defaultChecked` (or `checked` + `onCheckedChange`).\" },\n { name: \"disabled\", title: \"Disabled\", description: \"Off and on.\" },\n { name: \"small\", title: \"Small\", description: \"`size=\\\"sm\\\"`.\" },\n { name: \"with-label\", title: \"With a visible label\", description: \"A label and a hint on the same line.\" },\n ],\n },\n native: {\n imports: [\"Switch\"],\n differences: [\n \"Drawn by the theme, not the system's: the same switch on iOS and Android, the accent when on, a `selection` haptic when it flips (the app's `haptics`).\",\n \"`showLabel` makes it a settings row: the label and its `description` beside the switch, the whole row pressable, the description read as the hint.\",\n \"`error` shows under the row and is announced.\",\n ],\n examples: [\n { name: \"settings\", title: \"Settings rows\", description: \"Notification preferences: rows with a description, one disabled while push is off.\" },\n { name: \"default\", title: \"Alone\", description: \"Named by `label`; md and sm.\" },\n ],\n },\n} satisfies ComponentMeta;\n"
285
+ "content": "import type { ComponentMeta } from \"../meta\";\n\nexport const meta = {\n title: \"Switch\",\n summary: \"An on/off setting that applies at once.\",\n status: \"beta\",\n category: \"forms\",\n domain: \"forms\",\n platforms: \"both\",\n parity: { desktop: \"web\" },\n whenToUse: [\"For a setting that takes effect immediately: autoplay, notifications, a weekly digest.\"],\n whenNotToUse: [\n { when: \"For a choice submitted with a form, or an agreement.\", use: \"checkbox\" },\n { when: \"For more than two states.\", use: \"radio-group\" },\n { when: \"To run an action.\", use: \"button\" },\n ],\n bestPractices: [\n \"Name the setting, not the state: “Autoplay”, not “Turn autoplay on”.\",\n \"Give it `children` (and a `description`): the words at the start, the switch at the end, the whole row clickable. There is no alignment prop — start and end follow the reading direction.\",\n ],\n accessibility: {\n keyboard: [{ keys: \"Space\", action: \"Toggles the switch.\" }],\n notes: [\n \"Radix Switch: `role=\\\"switch\\\"` with `aria-checked`.\",\n \"With `children` the row is a `<label>`: one control, named by the words, hinted by `description` (`aria-describedby`), never read twice.\",\n \"`label` names it when no visible label does; otherwise use `Field.Label htmlFor` and `aria-describedby` for the hint.\",\n ],\n },\n related: [\"checkbox\", \"field\", \"radio-group\"],\n web: {\n imports: [\"Switch\"],\n examples: [\n { name: \"off\", title: \"Off\", description: \"Named by `label`.\" },\n { name: \"on\", title: \"On\", description: \"`defaultChecked` (or `checked` + `onCheckedChange`).\" },\n { name: \"disabled\", title: \"Disabled\", description: \"Off and on.\" },\n { name: \"small\", title: \"Small\", description: \"`size=\\\"sm\\\"`.\" },\n { name: \"with-label\", title: \"With a visible label\", description: \"A `Field.Label` and a hint on the same line.\" },\n { name: \"row\", title: \"Settings row\", description: \"`children` and `description`: text at the start, switch at the end, the whole row clickable (44 px).\" },\n ],\n },\n native: {\n imports: [\"Switch\"],\n differences: [\n \"Drawn by the theme, not the system's: the same switch on iOS and Android, the accent when on, a `selection` haptic when it flips (the app's `haptics`).\",\n \"`showLabel` makes it a settings row: the label and its `description` beside the switch, the whole row pressable, the description read as the hint.\",\n \"`error` shows under the row and is announced.\",\n ],\n examples: [\n { name: \"settings\", title: \"Settings rows\", description: \"Notification preferences: rows with a description, one disabled while push is off.\" },\n { name: \"default\", title: \"Alone\", description: \"Named by `label`; md and sm.\" },\n ],\n },\n} satisfies ComponentMeta;\n"
263
286
  },
264
287
  {
265
288
  "path": "switch/switch.tsx",
266
- "content": "// Client. Radix Switch: role=\"switch\", aria-checked, Space and Enter toggle, a hidden input inside a form.\nimport { Switch as SwitchPrimitive } from \"radix-ui\";\nimport type * as React from \"react\";\nimport { tv, type VariantProps } from \"tailwind-variants\";\n\nexport const switchVariants = tv({\n slots: {\n root:\n \"peer relative inline-flex shrink-0 cursor-pointer items-center rounded-full border border-transparent bg-fg-muted transition-colors \" +\n \"focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-surface-0 \" +\n \"disabled:cursor-not-allowed disabled:opacity-40 data-[state=checked]:bg-accent aria-invalid:border-danger\",\n thumb:\n \"pointer-events-none block rounded-full bg-fg-on-media shadow-sm transition-transform data-[state=unchecked]:translate-x-0.5 motion-reduce:transition-none\",\n },\n variants: {\n size: {\n sm: { root: \"h-5 w-9\", thumb: \"h-4 w-4 data-[state=checked]:translate-x-[1.125rem]\" },\n md: { root: \"h-6 w-11\", thumb: \"h-5 w-5 data-[state=checked]:translate-x-[1.375rem]\" },\n },\n },\n defaultVariants: { size: \"md\" },\n});\n\nexport type SwitchVariants = VariantProps<typeof switchVariants>;\n\ntype Named =\n | {\n /** The accessible name — required when no visible label names it, passed translated. */\n label: string;\n }\n /** Named by a visible `<label htmlFor={id}>` (e.g. `Field.Label`). */\n | { label?: undefined; id: string }\n /** Named by another element. */\n | { label?: undefined; \"aria-labelledby\": string };\n\nexport type SwitchProps = Omit<React.ComponentProps<typeof SwitchPrimitive.Root>, \"children\"> &\n SwitchVariants &\n Named & {\n /**\n * sm · md.\n * @default \"md\"\n */\n size?: SwitchVariants[\"size\"];\n /** Marks it invalid: aria-invalid and data-invalid. */\n invalid?: boolean;\n };\n\n/** An on/off switch: `checked`/`defaultChecked` + `onCheckedChange`. */\nexport function Switch({ label, size, invalid, className, ...props }: SwitchProps) {\n const s = switchVariants({ size });\n return (\n <SwitchPrimitive.Root\n aria-label={label}\n aria-invalid={invalid || undefined}\n data-invalid={invalid ? \"\" : undefined}\n className={s.root({ className })}\n {...props}\n >\n <SwitchPrimitive.Thumb className={s.thumb()} />\n </SwitchPrimitive.Root>\n );\n}\n"
289
+ "content": "// Client. Radix Switch: role=\"switch\", aria-checked, Space and Enter toggle, a hidden input inside a form.\nimport { Switch as SwitchPrimitive } from \"radix-ui\";\nimport * as React from \"react\";\nimport { tv, type VariantProps } from \"tailwind-variants\";\n\nexport const switchVariants = tv({\n slots: {\n row: \"flex min-h-11 w-full items-center justify-between gap-4\",\n root:\n \"peer relative inline-flex shrink-0 cursor-pointer items-center rounded-full border border-transparent bg-fg-muted transition-colors \" +\n \"focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-surface-0 \" +\n \"disabled:cursor-not-allowed disabled:opacity-40 data-[state=checked]:bg-accent aria-invalid:border-danger\",\n thumb:\n \"pointer-events-none block rounded-full bg-fg-on-media shadow-sm transition-transform data-[state=unchecked]:translate-x-0.5 motion-reduce:transition-none\",\n },\n variants: {\n size: {\n sm: { root: \"h-5 w-9\", thumb: \"h-4 w-4 data-[state=checked]:translate-x-[1.125rem]\" },\n md: { root: \"h-6 w-11\", thumb: \"h-5 w-5 data-[state=checked]:translate-x-[1.375rem]\" },\n },\n },\n defaultVariants: { size: \"md\" },\n});\n\nexport type SwitchVariants = VariantProps<typeof switchVariants>;\n\ntype Named =\n | {\n /** The accessible name — required when no visible label names it, passed translated. */\n label: string;\n }\n /** Named by a visible `<label htmlFor={id}>` (e.g. `Field.Label`). */\n | { label?: undefined; id: string }\n /** Named by another element. */\n | { label?: undefined; \"aria-labelledby\": string }\n /** Named by its own settings row: `children` is the visible label. */\n | { label?: undefined; children: React.ReactNode };\n\n/** The settings row: the words at the start, the switch at the end, the whole row clickable. */\ntype Row =\n | { children?: undefined; description?: undefined }\n | {\n /** The visible words, at the start of the row: they name the switch and the whole row toggles it. */\n children: React.ReactNode;\n /** A line under the words, read with the switch as its hint. */\n description?: React.ReactNode;\n };\n\nexport type SwitchProps = Omit<React.ComponentProps<typeof SwitchPrimitive.Root>, \"children\"> &\n SwitchVariants &\n Named &\n Row & {\n /**\n * sm · md.\n * @default \"md\"\n */\n size?: SwitchVariants[\"size\"];\n /** Marks it invalid: aria-invalid and data-invalid. */\n invalid?: boolean;\n };\n\n/**\n * An on/off switch: `checked`/`defaultChecked` + `onCheckedChange`. With `children` (and a `description`) it draws its\n * own settings row: the words at the start, the switch at the end (mirrored under `dir=\"rtl\"`), the whole row\n * clickable, 44 px high or more. It stays one control with one name (`children`) and one hint (`description`).\n */\nexport function Switch({ label, size, invalid, className, children, description, ...props }: SwitchProps) {\n const s = switchVariants({ size });\n const id = React.useId();\n const row = children !== undefined;\n const control = (\n <SwitchPrimitive.Root\n aria-label={label}\n aria-invalid={invalid || undefined}\n data-invalid={invalid ? \"\" : undefined}\n aria-labelledby={row ? `${id}t` : undefined}\n aria-describedby={row && description ? `${id}h` : undefined}\n className={s.root({ className: row ? undefined : className })}\n {...props}\n >\n <SwitchPrimitive.Thumb className={s.thumb()} />\n </SwitchPrimitive.Root>\n );\n return row ? (\n <label className={s.row({ className })}>\n <span className=\"grid min-w-0\">\n <span id={`${id}t`} className=\"text-sm text-fg\">\n {children}\n </span>\n {description ? (\n <span id={`${id}h`} className=\"text-xs text-fg-muted\">\n {description}\n </span>\n ) : null}\n </span>\n {control}\n </label>\n ) : (\n control\n );\n}\n"
267
290
  }
268
291
  ],
269
292
  "dependencies": [
@@ -278,8 +301,22 @@
278
301
  "props": [
279
302
  {
280
303
  "component": "Switch",
281
- "description": "An on/off switch: `checked`/`defaultChecked` + `onCheckedChange`.",
304
+ "description": "An on/off switch: `checked`/`defaultChecked` + `onCheckedChange`. With `children` (and a `description`) it draws its\nown settings row: the words at the start, the switch at the end (mirrored under `dir=\"rtl\"`), the whole row\nclickable, 44 px high or more. It stays one control with one name (`children`) and one hint (`description`).",
282
305
  "props": [
306
+ {
307
+ "name": "children",
308
+ "type": "ReactNode",
309
+ "default": null,
310
+ "description": "The visible words, at the start of the row: they name the switch and the whole row toggles it.",
311
+ "required": false
312
+ },
313
+ {
314
+ "name": "description",
315
+ "type": "ReactNode",
316
+ "default": null,
317
+ "description": "A line under the words, read with the switch as its hint.",
318
+ "required": false
319
+ },
283
320
  {
284
321
  "name": "invalid",
285
322
  "type": "boolean",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/switch/switch.tsx"],"sourcesContent":["// Client. Radix Switch: role=\"switch\", aria-checked, Space and Enter toggle, a hidden input inside a form.\nimport { Switch as SwitchPrimitive } from \"radix-ui\";\nimport type * as React from \"react\";\nimport { tv, type VariantProps } from \"tailwind-variants\";\n\nexport const switchVariants = tv({\n slots: {\n root:\n \"peer relative inline-flex shrink-0 cursor-pointer items-center rounded-full border border-transparent bg-fg-muted transition-colors \" +\n \"focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-surface-0 \" +\n \"disabled:cursor-not-allowed disabled:opacity-40 data-[state=checked]:bg-accent aria-invalid:border-danger\",\n thumb:\n \"pointer-events-none block rounded-full bg-fg-on-media shadow-sm transition-transform data-[state=unchecked]:translate-x-0.5 motion-reduce:transition-none\",\n },\n variants: {\n size: {\n sm: { root: \"h-5 w-9\", thumb: \"h-4 w-4 data-[state=checked]:translate-x-[1.125rem]\" },\n md: { root: \"h-6 w-11\", thumb: \"h-5 w-5 data-[state=checked]:translate-x-[1.375rem]\" },\n },\n },\n defaultVariants: { size: \"md\" },\n});\n\nexport type SwitchVariants = VariantProps<typeof switchVariants>;\n\ntype Named =\n | {\n /** The accessible name — required when no visible label names it, passed translated. */\n label: string;\n }\n /** Named by a visible `<label htmlFor={id}>` (e.g. `Field.Label`). */\n | { label?: undefined; id: string }\n /** Named by another element. */\n | { label?: undefined; \"aria-labelledby\": string };\n\nexport type SwitchProps = Omit<React.ComponentProps<typeof SwitchPrimitive.Root>, \"children\"> &\n SwitchVariants &\n Named & {\n /**\n * sm · md.\n * @default \"md\"\n */\n size?: SwitchVariants[\"size\"];\n /** Marks it invalid: aria-invalid and data-invalid. */\n invalid?: boolean;\n };\n\n/** An on/off switch: `checked`/`defaultChecked` + `onCheckedChange`. */\nexport function Switch({ label, size, invalid, className, ...props }: SwitchProps) {\n const s = switchVariants({ size });\n return (\n <SwitchPrimitive.Root\n aria-label={label}\n aria-invalid={invalid || undefined}\n data-invalid={invalid ? \"\" : undefined}\n className={s.root({ className })}\n {...props}\n >\n <SwitchPrimitive.Thumb className={s.thumb()} />\n </SwitchPrimitive.Root>\n );\n}\n"],"mappings":";;;AACA,SAAS,UAAU,uBAAuB;AAE1C,SAAS,UAA6B;AAuDhC;AArDC,IAAM,iBAAiB,GAAG;AAAA,EAC/B,OAAO;AAAA,IACL,MACE;AAAA,IAGF,OACE;AAAA,EACJ;AAAA,EACA,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,IAAI,EAAE,MAAM,WAAW,OAAO,sDAAsD;AAAA,MACpF,IAAI,EAAE,MAAM,YAAY,OAAO,sDAAsD;AAAA,IACvF;AAAA,EACF;AAAA,EACA,iBAAiB,EAAE,MAAM,KAAK;AAChC,CAAC;AA2BM,SAAS,OAAO,EAAE,OAAO,MAAM,SAAS,WAAW,GAAG,MAAM,GAAgB;AACjF,QAAM,IAAI,eAAe,EAAE,KAAK,CAAC;AACjC,SACE;AAAA,IAAC,gBAAgB;AAAA,IAAhB;AAAA,MACC,cAAY;AAAA,MACZ,gBAAc,WAAW;AAAA,MACzB,gBAAc,UAAU,KAAK;AAAA,MAC7B,WAAW,EAAE,KAAK,EAAE,UAAU,CAAC;AAAA,MAC9B,GAAG;AAAA,MAEJ,8BAAC,gBAAgB,OAAhB,EAAsB,WAAW,EAAE,MAAM,GAAG;AAAA;AAAA,EAC/C;AAEJ;","names":[]}