@ifhover/leaf-ui 0.12.0 → 0.13.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 (252) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/badge/badge.cjs +2 -1
  3. package/dist/cjs/badge/badge.cjs.map +1 -1
  4. package/dist/cjs/badge/badge.d.cts +4 -2
  5. package/dist/cjs/badge/badge.d.cts.map +1 -1
  6. package/dist/cjs/browser/modules/badge/badge.cjs +2 -1
  7. package/dist/cjs/browser/modules/badge/badge.cjs.map +1 -1
  8. package/dist/cjs/browser/modules/colors.cjs +5 -5
  9. package/dist/cjs/browser/modules/colors.cjs.map +1 -1
  10. package/dist/cjs/browser/modules/menu/menu.cjs +15 -7
  11. package/dist/cjs/browser/modules/menu/menu.cjs.map +1 -1
  12. package/dist/cjs/browser/modules/table/table.cjs +2 -7
  13. package/dist/cjs/browser/modules/table/table.cjs.map +1 -1
  14. package/dist/cjs/browser/modules/tabletanstack/tabletanstack.cjs +4 -6
  15. package/dist/cjs/browser/modules/tabletanstack/tabletanstack.cjs.map +1 -1
  16. package/dist/cjs/browser/modules/tag/group.cjs +4 -4
  17. package/dist/cjs/browser/modules/tag/group.cjs.map +1 -1
  18. package/dist/cjs/browser/modules/tag/tag.cjs +8 -11
  19. package/dist/cjs/browser/modules/tag/tag.cjs.map +1 -1
  20. package/dist/cjs/colors.cjs +5 -5
  21. package/dist/cjs/colors.cjs.map +1 -1
  22. package/dist/cjs/colors.d.cts.map +1 -1
  23. package/dist/cjs/menu/menu.cjs +15 -7
  24. package/dist/cjs/menu/menu.cjs.map +1 -1
  25. package/dist/cjs/menu/menu.d.cts.map +1 -1
  26. package/dist/cjs/styles/alert.css +1 -1
  27. package/dist/cjs/styles/anchor.css +1 -1
  28. package/dist/cjs/styles/autocomplete.css +1 -1
  29. package/dist/cjs/styles/avatar.css +1 -1
  30. package/dist/cjs/styles/backtop.css +1 -1
  31. package/dist/cjs/styles/badge.css +1 -1
  32. package/dist/cjs/styles/breadcrumb.css +1 -1
  33. package/dist/cjs/styles/button.css +1 -1
  34. package/dist/cjs/styles/calendar.css +1 -1
  35. package/dist/cjs/styles/card.css +1 -1
  36. package/dist/cjs/styles/carousel.css +1 -1
  37. package/dist/cjs/styles/cascader.css +1 -1
  38. package/dist/cjs/styles/checkbox.css +1 -1
  39. package/dist/cjs/styles/collapse.css +1 -1
  40. package/dist/cjs/styles/colorpicker.css +1 -1
  41. package/dist/cjs/styles/components/badge.css +1 -1
  42. package/dist/cjs/styles/components/calendar.css +1 -1
  43. package/dist/cjs/styles/components/card.css +1 -1
  44. package/dist/cjs/styles/components/menu.css +1 -1
  45. package/dist/cjs/styles/components/table.css +1 -1
  46. package/dist/cjs/styles/components/tabletanstack.css +1 -1
  47. package/dist/cjs/styles/components/tag.css +1 -1
  48. package/dist/cjs/styles/config-provider.css +1 -1
  49. package/dist/cjs/styles/confirm.css +1 -1
  50. package/dist/cjs/styles/datepicker.css +1 -1
  51. package/dist/cjs/styles/daterangepicker.css +1 -1
  52. package/dist/cjs/styles/descriptions.css +1 -1
  53. package/dist/cjs/styles/divider.css +1 -1
  54. package/dist/cjs/styles/drawer.css +1 -1
  55. package/dist/cjs/styles/dropdown.css +1 -1
  56. package/dist/cjs/styles/empty.css +1 -1
  57. package/dist/cjs/styles/errorboundary.css +1 -1
  58. package/dist/cjs/styles/filelist.css +1 -1
  59. package/dist/cjs/styles/flex.css +1 -1
  60. package/dist/cjs/styles/floatbutton.css +1 -1
  61. package/dist/cjs/styles/form.css +1 -1
  62. package/dist/cjs/styles/foundation.css +1 -1
  63. package/dist/cjs/styles/grid.css +1 -1
  64. package/dist/cjs/styles/image.css +1 -1
  65. package/dist/cjs/styles/index.css +308 -390
  66. package/dist/cjs/styles/index.css.map +1 -1
  67. package/dist/cjs/styles/infinitescroll.css +1 -1
  68. package/dist/cjs/styles/input.css +1 -1
  69. package/dist/cjs/styles/inputmask.css +1 -1
  70. package/dist/cjs/styles/inputnumber.css +1 -1
  71. package/dist/cjs/styles/inputotp.css +1 -1
  72. package/dist/cjs/styles/layout.css +1 -1
  73. package/dist/cjs/styles/loading.css +1 -1
  74. package/dist/cjs/styles/loadingbar.css +1 -1
  75. package/dist/cjs/styles/masonry.css +1 -1
  76. package/dist/cjs/styles/mentions.css +1 -1
  77. package/dist/cjs/styles/menu.css +1 -1
  78. package/dist/cjs/styles/message.css +1 -1
  79. package/dist/cjs/styles/modal.css +1 -1
  80. package/dist/cjs/styles/notification.css +1 -1
  81. package/dist/cjs/styles/pagination.css +1 -1
  82. package/dist/cjs/styles/popconfirm.css +1 -1
  83. package/dist/cjs/styles/popover.css +1 -1
  84. package/dist/cjs/styles/progress.css +1 -1
  85. package/dist/cjs/styles/qrcode.css +1 -1
  86. package/dist/cjs/styles/radio.css +1 -1
  87. package/dist/cjs/styles/rate.css +1 -1
  88. package/dist/cjs/styles/result.css +1 -1
  89. package/dist/cjs/styles/scrollarea.css +1 -1
  90. package/dist/cjs/styles/scrollbar.css +1 -1
  91. package/dist/cjs/styles/select.css +1 -1
  92. package/dist/cjs/styles/skeleton.css +1 -1
  93. package/dist/cjs/styles/slider.css +1 -1
  94. package/dist/cjs/styles/space.css +1 -1
  95. package/dist/cjs/styles/splitter.css +1 -1
  96. package/dist/cjs/styles/statistic.css +1 -1
  97. package/dist/cjs/styles/steps.css +1 -1
  98. package/dist/cjs/styles/switch.css +1 -1
  99. package/dist/cjs/styles/tabletanstack.css +1 -1
  100. package/dist/cjs/styles/tabs.css +1 -1
  101. package/dist/cjs/styles/tag.css +1 -1
  102. package/dist/cjs/styles/textarea.css +1 -1
  103. package/dist/cjs/styles/timeline.css +1 -1
  104. package/dist/cjs/styles/tooltip.css +1 -1
  105. package/dist/cjs/styles/tour.css +1 -1
  106. package/dist/cjs/styles/transfer.css +1 -1
  107. package/dist/cjs/styles/tree.css +1 -1
  108. package/dist/cjs/styles/treeselect.css +1 -1
  109. package/dist/cjs/styles/typography.css +1 -1
  110. package/dist/cjs/styles/upload.css +1 -1
  111. package/dist/cjs/styles/virtuallist.css +1 -1
  112. package/dist/cjs/table/table.cjs +2 -7
  113. package/dist/cjs/table/table.cjs.map +1 -1
  114. package/dist/cjs/table/table.d.cts +1 -3
  115. package/dist/cjs/table/table.d.cts.map +1 -1
  116. package/dist/cjs/tabletanstack/defaults.d.cts +3 -5
  117. package/dist/cjs/tabletanstack/defaults.d.cts.map +1 -1
  118. package/dist/cjs/tabletanstack/tabletanstack.cjs +4 -6
  119. package/dist/cjs/tabletanstack/tabletanstack.cjs.map +1 -1
  120. package/dist/cjs/tabletanstack/tabletanstack.d.cts.map +1 -1
  121. package/dist/cjs/tag/group.cjs +4 -4
  122. package/dist/cjs/tag/group.cjs.map +1 -1
  123. package/dist/cjs/tag/tag.cjs +8 -11
  124. package/dist/cjs/tag/tag.cjs.map +1 -1
  125. package/dist/cjs/tag/tag.d.cts +2 -3
  126. package/dist/cjs/tag/tag.d.cts.map +1 -1
  127. package/dist/esm/badge/badge.d.ts +4 -2
  128. package/dist/esm/badge/badge.d.ts.map +1 -1
  129. package/dist/esm/badge/badge.js +2 -1
  130. package/dist/esm/badge/badge.js.map +1 -1
  131. package/dist/esm/browser/modules/badge/badge.js +2 -1
  132. package/dist/esm/browser/modules/badge/badge.js.map +1 -1
  133. package/dist/esm/browser/modules/colors.js +5 -5
  134. package/dist/esm/browser/modules/colors.js.map +1 -1
  135. package/dist/esm/browser/modules/menu/menu.js +16 -8
  136. package/dist/esm/browser/modules/menu/menu.js.map +1 -1
  137. package/dist/esm/browser/modules/table/table.js +2 -7
  138. package/dist/esm/browser/modules/table/table.js.map +1 -1
  139. package/dist/esm/browser/modules/tabletanstack/tabletanstack.js +4 -6
  140. package/dist/esm/browser/modules/tabletanstack/tabletanstack.js.map +1 -1
  141. package/dist/esm/browser/modules/tag/group.js +4 -4
  142. package/dist/esm/browser/modules/tag/group.js.map +1 -1
  143. package/dist/esm/browser/modules/tag/tag.js +8 -11
  144. package/dist/esm/browser/modules/tag/tag.js.map +1 -1
  145. package/dist/esm/colors.d.ts.map +1 -1
  146. package/dist/esm/colors.js +5 -5
  147. package/dist/esm/colors.js.map +1 -1
  148. package/dist/esm/menu/menu.d.ts.map +1 -1
  149. package/dist/esm/menu/menu.js +16 -8
  150. package/dist/esm/menu/menu.js.map +1 -1
  151. package/dist/esm/styles/alert.css +1 -1
  152. package/dist/esm/styles/anchor.css +1 -1
  153. package/dist/esm/styles/autocomplete.css +1 -1
  154. package/dist/esm/styles/avatar.css +1 -1
  155. package/dist/esm/styles/backtop.css +1 -1
  156. package/dist/esm/styles/badge.css +1 -1
  157. package/dist/esm/styles/breadcrumb.css +1 -1
  158. package/dist/esm/styles/button.css +1 -1
  159. package/dist/esm/styles/calendar.css +1 -1
  160. package/dist/esm/styles/card.css +1 -1
  161. package/dist/esm/styles/carousel.css +1 -1
  162. package/dist/esm/styles/cascader.css +1 -1
  163. package/dist/esm/styles/checkbox.css +1 -1
  164. package/dist/esm/styles/collapse.css +1 -1
  165. package/dist/esm/styles/colorpicker.css +1 -1
  166. package/dist/esm/styles/components/badge.css +1 -1
  167. package/dist/esm/styles/components/calendar.css +1 -1
  168. package/dist/esm/styles/components/card.css +1 -1
  169. package/dist/esm/styles/components/menu.css +1 -1
  170. package/dist/esm/styles/components/table.css +1 -1
  171. package/dist/esm/styles/components/tabletanstack.css +1 -1
  172. package/dist/esm/styles/components/tag.css +1 -1
  173. package/dist/esm/styles/config-provider.css +1 -1
  174. package/dist/esm/styles/confirm.css +1 -1
  175. package/dist/esm/styles/datepicker.css +1 -1
  176. package/dist/esm/styles/daterangepicker.css +1 -1
  177. package/dist/esm/styles/descriptions.css +1 -1
  178. package/dist/esm/styles/divider.css +1 -1
  179. package/dist/esm/styles/drawer.css +1 -1
  180. package/dist/esm/styles/dropdown.css +1 -1
  181. package/dist/esm/styles/empty.css +1 -1
  182. package/dist/esm/styles/errorboundary.css +1 -1
  183. package/dist/esm/styles/filelist.css +1 -1
  184. package/dist/esm/styles/flex.css +1 -1
  185. package/dist/esm/styles/floatbutton.css +1 -1
  186. package/dist/esm/styles/form.css +1 -1
  187. package/dist/esm/styles/foundation.css +1 -1
  188. package/dist/esm/styles/grid.css +1 -1
  189. package/dist/esm/styles/image.css +1 -1
  190. package/dist/esm/styles/index.css +308 -390
  191. package/dist/esm/styles/index.css.map +1 -1
  192. package/dist/esm/styles/infinitescroll.css +1 -1
  193. package/dist/esm/styles/input.css +1 -1
  194. package/dist/esm/styles/inputmask.css +1 -1
  195. package/dist/esm/styles/inputnumber.css +1 -1
  196. package/dist/esm/styles/inputotp.css +1 -1
  197. package/dist/esm/styles/layout.css +1 -1
  198. package/dist/esm/styles/loading.css +1 -1
  199. package/dist/esm/styles/loadingbar.css +1 -1
  200. package/dist/esm/styles/masonry.css +1 -1
  201. package/dist/esm/styles/mentions.css +1 -1
  202. package/dist/esm/styles/menu.css +1 -1
  203. package/dist/esm/styles/message.css +1 -1
  204. package/dist/esm/styles/modal.css +1 -1
  205. package/dist/esm/styles/notification.css +1 -1
  206. package/dist/esm/styles/pagination.css +1 -1
  207. package/dist/esm/styles/popconfirm.css +1 -1
  208. package/dist/esm/styles/popover.css +1 -1
  209. package/dist/esm/styles/progress.css +1 -1
  210. package/dist/esm/styles/qrcode.css +1 -1
  211. package/dist/esm/styles/radio.css +1 -1
  212. package/dist/esm/styles/rate.css +1 -1
  213. package/dist/esm/styles/result.css +1 -1
  214. package/dist/esm/styles/scrollarea.css +1 -1
  215. package/dist/esm/styles/scrollbar.css +1 -1
  216. package/dist/esm/styles/select.css +1 -1
  217. package/dist/esm/styles/skeleton.css +1 -1
  218. package/dist/esm/styles/slider.css +1 -1
  219. package/dist/esm/styles/space.css +1 -1
  220. package/dist/esm/styles/splitter.css +1 -1
  221. package/dist/esm/styles/statistic.css +1 -1
  222. package/dist/esm/styles/steps.css +1 -1
  223. package/dist/esm/styles/switch.css +1 -1
  224. package/dist/esm/styles/tabletanstack.css +1 -1
  225. package/dist/esm/styles/tabs.css +1 -1
  226. package/dist/esm/styles/tag.css +1 -1
  227. package/dist/esm/styles/textarea.css +1 -1
  228. package/dist/esm/styles/timeline.css +1 -1
  229. package/dist/esm/styles/tooltip.css +1 -1
  230. package/dist/esm/styles/tour.css +1 -1
  231. package/dist/esm/styles/transfer.css +1 -1
  232. package/dist/esm/styles/tree.css +1 -1
  233. package/dist/esm/styles/treeselect.css +1 -1
  234. package/dist/esm/styles/typography.css +1 -1
  235. package/dist/esm/styles/upload.css +1 -1
  236. package/dist/esm/styles/virtuallist.css +1 -1
  237. package/dist/esm/table/table.d.ts +1 -3
  238. package/dist/esm/table/table.d.ts.map +1 -1
  239. package/dist/esm/table/table.js +2 -7
  240. package/dist/esm/table/table.js.map +1 -1
  241. package/dist/esm/tabletanstack/defaults.d.ts +3 -5
  242. package/dist/esm/tabletanstack/defaults.d.ts.map +1 -1
  243. package/dist/esm/tabletanstack/tabletanstack.d.ts.map +1 -1
  244. package/dist/esm/tabletanstack/tabletanstack.js +4 -6
  245. package/dist/esm/tabletanstack/tabletanstack.js.map +1 -1
  246. package/dist/esm/tag/group.js +4 -4
  247. package/dist/esm/tag/group.js.map +1 -1
  248. package/dist/esm/tag/tag.d.ts +2 -3
  249. package/dist/esm/tag/tag.d.ts.map +1 -1
  250. package/dist/esm/tag/tag.js +8 -11
  251. package/dist/esm/tag/tag.js.map +1 -1
  252. package/package.json +2 -2
@@ -45,9 +45,9 @@ function CheckableTag(rawProps) {
45
45
  return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
46
46
  ...props,
47
47
  type: props.type ?? 'button',
48
- className: (0, classes_cjs_namespaceObject.classes)('leaf-tag', `leaf-tag--${current ? 'soft' : 'outline'}`, `leaf-tag--${size}`, 'leaf-checkable-tag', className),
48
+ className: (0, classes_cjs_namespaceObject.classes)('leaf-tag', `leaf-tag--${current ? 'solid' : 'soft'}`, `leaf-tag--${size}`, 'leaf-checkable-tag', className),
49
49
  "aria-pressed": current,
50
- "data-color": "primary",
50
+ "data-color": current ? 'primary' : 'default',
51
51
  onClick: (event)=>{
52
52
  onClick?.(event);
53
53
  if (!event.defaultPrevented) change(!current);
@@ -71,8 +71,8 @@ function TagGroup(rawProps) {
71
71
  return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
72
72
  ref: 0 === index ? trigger : void 0,
73
73
  type: "button",
74
- className: (0, classes_cjs_namespaceObject.classes)('leaf-tag', `leaf-tag--${selected ? 'soft' : 'outline'}`, `leaf-tag--${size ?? 'md'}`, 'leaf-checkable-tag'),
75
- "data-color": "primary",
74
+ className: (0, classes_cjs_namespaceObject.classes)('leaf-tag', `leaf-tag--${selected ? 'solid' : 'soft'}`, `leaf-tag--${size ?? 'md'}`, 'leaf-checkable-tag'),
75
+ "data-color": selected ? 'primary' : 'default',
76
76
  "data-motion-key": option.value,
77
77
  "aria-pressed": selected,
78
78
  disabled: disabled || option.disabled,
@@ -1 +1 @@
1
- {"version":3,"file":"tag/group.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../../../src/tag/group.tsx"],"sourcesContent":["__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { type ButtonHTMLAttributes, type HTMLAttributes, type ReactNode, useRef } from 'react';\nimport { useComponentProps } from '../config-provider/component-defaults';\nimport { classes } from '../shared/classes';\nimport { FormValue, useFieldValue } from '../shared/field';\nimport { useListMotion } from '../shared/motion';\nimport type { ControlSize } from '../shared/types';\nimport { useControllable } from '../shared/use-controllable';\nexport interface CheckableTagProps\n extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onChange'> {\n checked?: boolean;\n defaultChecked?: boolean;\n onChange?: (checked: boolean) => void;\n size?: ControlSize;\n}\nexport function CheckableTag(rawProps: CheckableTagProps) {\n const {\n checked,\n defaultChecked = false,\n onChange,\n size = 'md',\n children,\n className,\n onClick,\n ...props\n } = useComponentProps('CheckableTag', rawProps);\n const [current, change] = useControllable(checked, defaultChecked, onChange);\n return (\n <button\n {...props}\n type={props.type ?? 'button'}\n className={classes(\n 'leaf-tag',\n `leaf-tag--${current ? 'soft' : 'outline'}`,\n `leaf-tag--${size}`,\n 'leaf-checkable-tag',\n className,\n )}\n aria-pressed={current}\n data-color=\"primary\"\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) change(!current);\n }}\n >\n {children}\n </button>\n );\n}\nexport interface TagOption {\n value: string;\n label: ReactNode;\n disabled?: boolean;\n}\nexport interface TagGroupProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {\n options: readonly TagOption[];\n value?: readonly string[];\n defaultValue?: readonly string[];\n onChange?: (values: string[]) => void;\n disabled?: boolean;\n size?: ControlSize;\n name?: string;\n form?: string;\n required?: boolean;\n}\nexport function TagGroup(rawProps: TagGroupProps) {\n const {\n options,\n value,\n defaultValue = [],\n onChange,\n disabled,\n size,\n name,\n form,\n required,\n className,\n ...props\n } = useComponentProps('TagGroup', rawProps);\n const trigger = useRef<HTMLButtonElement>(null);\n const root = useRef<HTMLDivElement>(null);\n const [current, setCurrent] = useFieldValue(value, defaultValue, trigger, form);\n useListMotion(\n root,\n JSON.stringify(options.map((option) => option.value)),\n '.leaf-checkable-tag[data-motion-key]',\n );\n return (\n <div {...props} ref={root} className={classes('leaf-tag-group', className)}>\n {options.map((option, index) => {\n const selected = current.includes(option.value);\n return (\n <button\n key={option.value}\n ref={index === 0 ? trigger : undefined}\n type=\"button\"\n className={classes(\n 'leaf-tag',\n `leaf-tag--${selected ? 'soft' : 'outline'}`,\n `leaf-tag--${size ?? 'md'}`,\n 'leaf-checkable-tag',\n )}\n data-color=\"primary\"\n data-motion-key={option.value}\n aria-pressed={selected}\n disabled={disabled || option.disabled}\n onClick={() => {\n const next = selected\n ? current.filter((key) => key !== option.value)\n : [...current, option.value];\n setCurrent(next);\n onChange?.(next);\n }}\n >\n {option.label}\n </button>\n );\n })}\n <FormValue\n name={name}\n form={form}\n required={required}\n disabled={disabled}\n value={current.length ? JSON.stringify(current) : ''}\n triggerRef={trigger}\n />\n </div>\n );\n}\n"],"names":["__webpack_require__","getters","values","define","defs","kind","key","Object","obj","prop","Symbol","CheckableTag","rawProps","checked","defaultChecked","onChange","size","children","className","onClick","props","useComponentProps","current","change","useControllable","classes","event","TagGroup","options","value","defaultValue","disabled","name","form","required","trigger","useRef","root","setCurrent","useFieldValue","useListMotion","JSON","option","index","selected","undefined","next","FormValue"],"mappings":";;;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC,SAASC;QAC1C,IAAIC,SAAS,CAACC,MAAMC;YACnB,IAAI,IAAIC,OAAOF,KACd,IAAGJ,oBAAoB,CAAC,CAACI,MAAME,QAAQ,CAACN,oBAAoB,CAAC,CAAC,UAASM,MACtEC,OAAO,cAAc,CAAC,UAASD,KAAK;gBAAE,YAAY;gBAAM,CAACD,KAAK,EAAED,IAAI,CAACE,IAAI;YAAC;QAG7E;QACAH,OAAOF,SAAS;QAChBE,OAAOD,QAAQ;IAChB;;;ICVAF,oBAAoB,CAAC,GAAG,CAACQ,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFT,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,MAAlB,OAAOU,UAA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time/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../../../src/tag/group.tsx"],"sourcesContent":["__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { type ButtonHTMLAttributes, type HTMLAttributes, type ReactNode, useRef } from 'react';\nimport { useComponentProps } from '../config-provider/component-defaults';\nimport { classes } from '../shared/classes';\nimport { FormValue, useFieldValue } from '../shared/field';\nimport { useListMotion } from '../shared/motion';\nimport type { ControlSize } from '../shared/types';\nimport { useControllable } from '../shared/use-controllable';\nexport interface CheckableTagProps\n extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onChange'> {\n checked?: boolean;\n defaultChecked?: boolean;\n onChange?: (checked: boolean) => void;\n size?: ControlSize;\n}\nexport function CheckableTag(rawProps: CheckableTagProps) {\n const {\n checked,\n defaultChecked = false,\n onChange,\n size = 'md',\n children,\n className,\n onClick,\n ...props\n } = useComponentProps('CheckableTag', rawProps);\n const [current, change] = useControllable(checked, defaultChecked, onChange);\n return (\n <button\n {...props}\n type={props.type ?? 'button'}\n className={classes(\n 'leaf-tag',\n `leaf-tag--${current ? 'solid' : 'soft'}`,\n `leaf-tag--${size}`,\n 'leaf-checkable-tag',\n className,\n )}\n aria-pressed={current}\n data-color={current ? 'primary' : 'default'}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) change(!current);\n }}\n >\n {children}\n </button>\n );\n}\nexport interface TagOption {\n value: string;\n label: ReactNode;\n disabled?: boolean;\n}\nexport interface TagGroupProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {\n options: readonly TagOption[];\n value?: readonly string[];\n defaultValue?: readonly string[];\n onChange?: (values: string[]) => void;\n disabled?: boolean;\n size?: ControlSize;\n name?: string;\n form?: string;\n required?: boolean;\n}\nexport function TagGroup(rawProps: TagGroupProps) {\n const {\n options,\n value,\n defaultValue = [],\n onChange,\n disabled,\n size,\n name,\n form,\n required,\n className,\n ...props\n } = useComponentProps('TagGroup', rawProps);\n const trigger = useRef<HTMLButtonElement>(null);\n const root = useRef<HTMLDivElement>(null);\n const [current, setCurrent] = useFieldValue(value, defaultValue, trigger, form);\n useListMotion(\n root,\n JSON.stringify(options.map((option) => option.value)),\n '.leaf-checkable-tag[data-motion-key]',\n );\n return (\n <div {...props} ref={root} className={classes('leaf-tag-group', className)}>\n {options.map((option, index) => {\n const selected = current.includes(option.value);\n return (\n <button\n key={option.value}\n ref={index === 0 ? trigger : undefined}\n type=\"button\"\n className={classes(\n 'leaf-tag',\n `leaf-tag--${selected ? 'solid' : 'soft'}`,\n `leaf-tag--${size ?? 'md'}`,\n 'leaf-checkable-tag',\n )}\n data-color={selected ? 'primary' : 'default'}\n data-motion-key={option.value}\n aria-pressed={selected}\n disabled={disabled || option.disabled}\n onClick={() => {\n const next = selected\n ? current.filter((key) => key !== option.value)\n : [...current, option.value];\n setCurrent(next);\n onChange?.(next);\n }}\n >\n {option.label}\n </button>\n );\n })}\n <FormValue\n name={name}\n form={form}\n required={required}\n disabled={disabled}\n value={current.length ? JSON.stringify(current) : ''}\n triggerRef={trigger}\n />\n </div>\n );\n}\n"],"names":["__webpack_require__","getters","values","define","defs","kind","key","Object","obj","prop","Symbol","CheckableTag","rawProps","checked","defaultChecked","onChange","size","children","className","onClick","props","useComponentProps","current","change","useControllable","classes","event","TagGroup","options","value","defaultValue","disabled","name","form","required","trigger","useRef","root","setCurrent","useFieldValue","useListMotion","JSON","option","index","selected","undefined","next","FormValue"],"mappings":";;;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC,SAASC;QAC1C,IAAIC,SAAS,CAACC,MAAMC;YACnB,IAAI,IAAIC,OAAOF,KACd,IAAGJ,oBAAoB,CAAC,CAACI,MAAME,QAAQ,CAACN,oBAAoB,CAAC,CAAC,UAASM,MACtEC,OAAO,cAAc,CAAC,UAASD,KAAK;gBAAE,YAAY;gBAAM,CAACD,KAAK,EAAED,IAAI,CAACE,IAAI;YAAC;QAG7E;QACAH,OAAOF,SAAS;QAChBE,OAAOD,QAAQ;IAChB;;;ICVAF,oBAAoB,CAAC,GAAG,CAACQ,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFT,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,MAAlB,OAAOU,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;;;ACQO,SAASI,aAAaC,QAA2B;IACtD,MAAM,EACJC,OAAO,EACPC,iBAAiB,KAAK,EACtBC,QAAQ,EACRC,OAAO,IAAI,EACXC,QAAQ,EACRC,SAAS,EACTC,OAAO,EACP,GAAGC,OACJ,GAAGC,AAAAA,IAAAA,uCAAAA,iBAAAA,AAAAA,EAAkB,gBAAgBT;IACtC,MAAM,CAACU,SAASC,OAAO,GAAGC,AAAAA,IAAAA,qCAAAA,eAAAA,AAAAA,EAAgBX,SAASC,gBAAgBC;IACnE,OACE,AADK,WAAP,GACE,qCAAC;QACE,GAAGK,KAAK;QACT,MAAMA,MAAM,IAAI,IAAI;QACpB,WAAWK,AAAAA,IAAAA,4BAAAA,OAA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,EACT,YACA,CAAC,UAAU,EAAEmB,WAAW,UAAU,QAAQ,EAC1C,CAAC,UAAU,EAAE5B,QAAQ,MAAM,EAC3B;oBAEF,cAAY4B,WAAW,YAAY;oBACnC,mBAAiBF,OAAO,KAAK;oBAC7B,gBAAcE;oBACd,UAAUb,YAAYW,OAAO,QAAQ;oBACrC,SAAS;wBACP,MAAMI,OAAOF,WACTtB,QAAQ,MAAM,CAAC,CAAChB,MAAQA,QAAQoC,OAAO,KAAK,IAC5C;+BAAIpB;4BAASoB,OAAO,KAAK;yBAAC;wBAC9BJ,WAAWQ;wBACX/B,WAAW+B;oBACb;8BAECJ,OAAO,KAAK;mBArBRA,OAAO,KAAK;YAwBvB;0BACA,qCAACK,0BAAAA,SAASA,EAAAA;gBACR,MAAMf;gBACN,MAAMC;gBACN,UAAUC;gBACV,UAAUH;gBACV,OAAOT,QAAQ,MAAM,GAAGmB,KAAK,SAAS,CAACnB,WAAW;gBAClD,YAAYa;;;;AAIpB"}
@@ -42,11 +42,9 @@ const inert_cjs_namespaceObject = require("../shared/inert.cjs");
42
42
  const presence_cjs_namespaceObject = require("../shared/presence.cjs");
43
43
  const presets = [
44
44
  'default',
45
- 'primary',
46
45
  'success',
47
46
  'warning',
48
47
  'danger',
49
- 'error',
50
48
  'info'
51
49
  ];
52
50
  function tagVariables(appearance, seed, background, muted, neutral) {
@@ -68,27 +66,29 @@ function tagVariables(appearance, seed, background, muted, neutral) {
68
66
  '--leaf-tag-color': seed,
69
67
  '--leaf-tag-color-alpha-10': values['--leaf-color-primary-soft-hover'],
70
68
  '--leaf-tag-color-surface-8': values['--leaf-color-primary-soft'],
71
- '--leaf-tag-ink': values['--leaf-color-primary-ink']
69
+ '--leaf-tag-ink': values['--leaf-color-primary-ink'],
70
+ '--leaf-tag-solid-foreground': 'var(--leaf-color-on-primary)'
72
71
  };
73
72
  }
74
73
  function Tag(rawProps) {
75
- const { color = 'primary', variant = 'soft', size = 'md', dot = true, icon, closable = false, onClose, className, style, children, ...props } = (0, component_defaults_cjs_namespaceObject.useComponentProps)('Tag', rawProps);
74
+ const { color = 'default', variant = 'soft', size = 'md', icon, closable = false, onClose, className, style, children, ...props } = (0, component_defaults_cjs_namespaceObject.useComponentProps)('Tag', rawProps);
76
75
  const { messages, theme } = (0, context_cjs_namespaceObject.useLeafConfig)();
77
76
  const [closed, setClosed] = (0, external_react_namespaceObject.useState)(false);
78
77
  const root = (0, external_react_namespaceObject.useRef)(null);
79
78
  const present = (0, presence_cjs_namespaceObject.usePresence)(!closed, root);
80
- const custom = !presets.includes(color);
81
- const presetColor = 'default' === color ? 'primary' : 'error' === color ? 'danger' : color;
79
+ const normalizedColor = 'primary' === color ? 'default' : 'error' === color ? 'danger' : color;
80
+ const custom = !presets.includes(normalizedColor);
81
+ const presetColor = normalizedColor;
82
82
  const appearance = theme.appearance ?? 'light';
83
83
  const surface = theme.tokens?.surfaceColor;
84
84
  const mutedSurface = theme.tokens?.mutedSurfaceColor;
85
85
  const neutral = theme.tokens?.neutralColor;
86
- const customVariables = (0, external_react_namespaceObject.useMemo)(()=>custom ? tagVariables(appearance, color, surface, mutedSurface, neutral) : {}, [
86
+ const customVariables = (0, external_react_namespaceObject.useMemo)(()=>custom ? tagVariables(appearance, normalizedColor, surface, mutedSurface, neutral) : {}, [
87
87
  appearance,
88
- color,
89
88
  custom,
90
89
  mutedSurface,
91
90
  neutral,
91
+ normalizedColor,
92
92
  surface
93
93
  ]);
94
94
  if (!present) return null;
@@ -109,9 +109,6 @@ function Tag(rawProps) {
109
109
  className: "leaf-tag__icon",
110
110
  "aria-hidden": "true",
111
111
  children: icon
112
- }) : dot ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
113
- className: "leaf-tag__dot",
114
- "aria-hidden": "true"
115
112
  }) : null,
116
113
  /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
117
114
  children: children
@@ -1 +1 @@
1
- {"version":3,"file":"tag/tag.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../../../src/tag/tag.tsx"],"sourcesContent":["__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { X } from 'lucide-react';\nimport {\n type HTMLAttributes,\n type MouseEvent,\n type ReactNode,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { resolveColorRoles } from '../colors';\nimport { useComponentProps } from '../config-provider/component-defaults';\nimport { useLeafConfig } from '../config-provider/context';\nimport { classes } from '../shared/classes';\nimport { inertProps } from '../shared/inert';\nimport { usePresence } from '../shared/presence';\nimport type { ControlSize } from '../shared/types';\n\nexport interface TagProps extends HTMLAttributes<HTMLSpanElement> {\n color?:\n | 'default'\n | 'primary'\n | 'success'\n | 'warning'\n | 'danger'\n | 'error'\n | 'info'\n | (string & {});\n variant?: 'soft' | 'outline';\n size?: ControlSize;\n dot?: boolean;\n icon?: ReactNode;\n closable?: boolean;\n onClose?: (event: MouseEvent<HTMLButtonElement>) => void;\n}\nconst presets = ['default', 'primary', 'success', 'warning', 'danger', 'error', 'info'];\nfunction tagVariables(\n appearance: 'light' | 'dark',\n seed: string,\n background?: string,\n muted?: string,\n neutral?: string,\n) {\n const { values } = resolveColorRoles(\n appearance,\n {\n primary: seed,\n ...(background ? { surface: background } : {}),\n ...(muted ? { 'surface-muted': muted } : {}),\n ...(neutral ? { neutral } : {}),\n },\n ['primary'],\n );\n // Retain local styling hooks, but derive their values from the shared roles.\n return {\n '--leaf-tag-color': seed,\n '--leaf-tag-color-alpha-10': values['--leaf-color-primary-soft-hover'],\n '--leaf-tag-color-surface-8': values['--leaf-color-primary-soft'],\n '--leaf-tag-ink': values['--leaf-color-primary-ink'],\n };\n}\nexport function Tag(rawProps: TagProps) {\n const {\n color = 'primary',\n variant = 'soft',\n size = 'md',\n dot = true,\n icon,\n closable = false,\n onClose,\n className,\n style,\n children,\n ...props\n } = useComponentProps('Tag', rawProps);\n const { messages, theme } = useLeafConfig();\n const [closed, setClosed] = useState(false);\n const root = useRef<HTMLSpanElement>(null);\n const present = usePresence(!closed, root);\n const custom = !presets.includes(color);\n const presetColor = color === 'default' ? 'primary' : color === 'error' ? 'danger' : color;\n const appearance = theme.appearance ?? 'light';\n const surface = theme.tokens?.surfaceColor;\n const mutedSurface = theme.tokens?.mutedSurfaceColor;\n const neutral = theme.tokens?.neutralColor;\n const customVariables = useMemo(\n () => (custom ? tagVariables(appearance, color, surface, mutedSurface, neutral) : {}),\n [appearance, color, custom, mutedSurface, neutral, surface],\n );\n if (!present) return null;\n return (\n <span\n {...props}\n {...inertProps(closed)}\n ref={root}\n data-state={closed ? 'closing' : undefined}\n aria-hidden={closed || props['aria-hidden']}\n className={classes('leaf-tag', `leaf-tag--${variant}`, `leaf-tag--${size}`, className)}\n data-color={custom ? undefined : presetColor}\n style={{ ...customVariables, ...style }}\n >\n {icon != null && icon !== false ? (\n <span className=\"leaf-tag__icon\" aria-hidden=\"true\">\n {icon}\n </span>\n ) : dot ? (\n <span className=\"leaf-tag__dot\" aria-hidden=\"true\" />\n ) : null}\n <span>{children}</span>\n {closable && (\n <button\n type=\"button\"\n className=\"leaf-tag__close\"\n aria-label={messages.common.remove}\n onClick={(event) => {\n onClose?.(event);\n if (!event.defaultPrevented) {\n const node = root.current;\n if (node) {\n node.style.setProperty(\n '--leaf-tag-width',\n `${node.getBoundingClientRect().width}px`,\n );\n void node.offsetWidth;\n if (node.contains(document.activeElement)) {\n const buttons = Array.from(\n node.parentElement?.querySelectorAll<HTMLButtonElement>('.leaf-tag__close') ??\n [],\n );\n const index = buttons.indexOf(event.currentTarget);\n (buttons[index + 1] ?? buttons[index - 1])?.focus();\n }\n }\n setClosed(true);\n }\n }}\n >\n <X size={12} aria-hidden=\"true\" />\n </button>\n )}\n </span>\n );\n}\n"],"names":["__webpack_require__","getters","values","define","defs","kind","key","Object","obj","prop","Symbol","presets","tagVariables","appearance","seed","background","muted","neutral","resolveColorRoles","Tag","rawProps","color","variant","size","dot","icon","closable","onClose","className","style","children","props","useComponentProps","messages","theme","useLeafConfig","closed","setClosed","useState","root","useRef","present","usePresence","custom","presetColor","surface","mutedSurface","customVariables","useMemo","inertProps","undefined","classes","event","node","document","buttons","Array","index","X"],"mappings":";;;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC,SAASC;QAC1C,IAAIC,SAAS,CAACC,MAAMC;YACnB,IAAI,IAAIC,OAAOF,KACd,IAAGJ,oBAAoB,CAAC,CAACI,MAAME,QAAQ,CAACN,oBAAoB,CAAC,CAAC,UAASM,MACtEC,OAAO,cAAc,CAAC,UAASD,KAAK;gBAAE,YAAY;gBAAM,CAACD,KAAK,EAAED,IAAI,CAACE,IAAI;YAAC;QAG7E;QACAH,OAAOF,SAAS;QAChBE,OAAOD,QAAQ;IAChB;;;ICVAF,oBAAoB,CAAC,GAAG,CAACQ,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFT,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,MAAlB,OAAOU,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;;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AAgB,EAAE;wBAC3B,MAAMC,OAAOd,KAAK,OAAO;wBACzB,IAAIc,MAAM;4BACRA,KAAK,KAAK,CAAC,WAAW,CACpB,oBACA,GAAGA,KAAK,qBAAqB,GAAG,KAAK,CAAC,EAAE,CAAC;4BAEtCA,KAAK,WAAW;4BACrB,IAAIA,KAAK,QAAQ,CAACC,SAAS,aAAa,GAAG;gCACzC,MAAMC,UAAUC,MAAM,IAAI,CACxBH,KAAK,aAAa,EAAE,iBAAoC,uBACtD,EAAE;gCAEN,MAAMI,QAAQF,QAAQ,OAAO,CAACH,MAAM,aAAa;gCAChDG,CAAAA,OAAO,CAACE,QAAQ,EAAE,IAAIF,OAAO,CAACE,QAAQ,EAAC,GAAI;4BAC9C;wBACF;wBACApB,UAAU;oBACZ;gBACF;0BAEA,mDAACqB,sCAAAA,CAACA,EAAAA;oBAAC,MAAM;oBAAI,eAAY;;;;;AAKnC"}
1
+ {"version":3,"file":"tag/tag.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../../../src/tag/tag.tsx"],"sourcesContent":["__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { X } from 'lucide-react';\nimport {\n type HTMLAttributes,\n type MouseEvent,\n type ReactNode,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { resolveColorRoles } from '../colors';\nimport { useComponentProps } from '../config-provider/component-defaults';\nimport { useLeafConfig } from '../config-provider/context';\nimport { classes } from '../shared/classes';\nimport { inertProps } from '../shared/inert';\nimport { usePresence } from '../shared/presence';\nimport type { ControlSize } from '../shared/types';\n\nexport interface TagProps extends HTMLAttributes<HTMLSpanElement> {\n color?: 'default' | 'success' | 'warning' | 'danger' | 'info' | (string & {});\n variant?: 'soft' | 'solid';\n size?: ControlSize;\n icon?: ReactNode;\n closable?: boolean;\n onClose?: (event: MouseEvent<HTMLButtonElement>) => void;\n}\nconst presets = ['default', 'success', 'warning', 'danger', 'info'];\nfunction tagVariables(\n appearance: 'light' | 'dark',\n seed: string,\n background?: string,\n muted?: string,\n neutral?: string,\n) {\n const { values } = resolveColorRoles(\n appearance,\n {\n primary: seed,\n ...(background ? { surface: background } : {}),\n ...(muted ? { 'surface-muted': muted } : {}),\n ...(neutral ? { neutral } : {}),\n },\n ['primary'],\n );\n // Retain local styling hooks, but derive their values from the shared roles.\n return {\n '--leaf-tag-color': seed,\n '--leaf-tag-color-alpha-10': values['--leaf-color-primary-soft-hover'],\n '--leaf-tag-color-surface-8': values['--leaf-color-primary-soft'],\n '--leaf-tag-ink': values['--leaf-color-primary-ink'],\n '--leaf-tag-solid-foreground': 'var(--leaf-color-on-primary)',\n };\n}\nexport function Tag(rawProps: TagProps) {\n const {\n color = 'default',\n variant = 'soft',\n size = 'md',\n icon,\n closable = false,\n onClose,\n className,\n style,\n children,\n ...props\n } = useComponentProps('Tag', rawProps);\n const { messages, theme } = useLeafConfig();\n const [closed, setClosed] = useState(false);\n const root = useRef<HTMLSpanElement>(null);\n const present = usePresence(!closed, root);\n // Keep removed semantic aliases predictable while the public presets stay neutral plus four statuses.\n const normalizedColor = color === 'primary' ? 'default' : color === 'error' ? 'danger' : color;\n const custom = !presets.includes(normalizedColor);\n const presetColor = normalizedColor;\n const appearance = theme.appearance ?? 'light';\n const surface = theme.tokens?.surfaceColor;\n const mutedSurface = theme.tokens?.mutedSurfaceColor;\n const neutral = theme.tokens?.neutralColor;\n const customVariables = useMemo(\n () => (custom ? tagVariables(appearance, normalizedColor, surface, mutedSurface, neutral) : {}),\n [appearance, custom, mutedSurface, neutral, normalizedColor, surface],\n );\n if (!present) return null;\n return (\n <span\n {...props}\n {...inertProps(closed)}\n ref={root}\n data-state={closed ? 'closing' : undefined}\n aria-hidden={closed || props['aria-hidden']}\n className={classes('leaf-tag', `leaf-tag--${variant}`, `leaf-tag--${size}`, className)}\n data-color={custom ? undefined : presetColor}\n style={{ ...customVariables, ...style }}\n >\n {icon != null && icon !== false ? (\n <span className=\"leaf-tag__icon\" aria-hidden=\"true\">\n {icon}\n </span>\n ) : null}\n <span>{children}</span>\n {closable && (\n <button\n type=\"button\"\n className=\"leaf-tag__close\"\n aria-label={messages.common.remove}\n onClick={(event) => {\n onClose?.(event);\n if (!event.defaultPrevented) {\n const node = root.current;\n if (node) {\n node.style.setProperty(\n '--leaf-tag-width',\n `${node.getBoundingClientRect().width}px`,\n );\n void node.offsetWidth;\n if (node.contains(document.activeElement)) {\n const buttons = Array.from(\n node.parentElement?.querySelectorAll<HTMLButtonElement>('.leaf-tag__close') ??\n [],\n );\n const index = buttons.indexOf(event.currentTarget);\n (buttons[index + 1] ?? buttons[index - 1])?.focus();\n }\n }\n setClosed(true);\n }\n }}\n >\n <X size={12} aria-hidden=\"true\" />\n </button>\n )}\n </span>\n );\n}\n"],"names":["__webpack_require__","getters","values","define","defs","kind","key","Object","obj","prop","Symbol","presets","tagVariables","appearance","seed","background","muted","neutral","resolveColorRoles","Tag","rawProps","color","variant","size","icon","closable","onClose","className","style","children","props","useComponentProps","messages","theme","useLeafConfig","closed","setClosed","useState","root","useRef","present","usePresence","normalizedColor","custom","presetColor","surface","mutedSurface","customVariables","useMemo","inertProps","undefined","classes","event","node","document","buttons","Array","index","X"],"mappings":";;;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC,SAASC;QAC1C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AYH,SAAS,YAAYe;QACjC,eAAaf,UAAUL,KAAK,CAAC,cAAc;QAC3C,WAAWqB,AAAAA,IAAAA,4BAAAA,OAAAA,AAAAA,EAAQ,YAAY,CAAC,UAAU,EAAE7B,SAAS,EAAE,CAAC,UAAU,EAAEC,MAAM,EAAEI;QAC5E,cAAYgB,SAASO,SAAYN;QACjC,OAAO;YAAE,GAAGG,eAAe;YAAE,GAAGnB,KAAK;QAAC;;YAE7B,QAARJ,QAAgBA,AAAS,UAATA,OACf,AADgC,WAAR,GACxB,qCAAC;gBAAK,WAAU;gBAAiB,eAAY;0BAC1CA;iBAED;0BACJ,qCAAC;0BAAMK;;YACNJ,YACC,AADW,WAAZA,GACC,qCAAC;gBACC,MAAK;gBACL,WAAU;gBACV,cAAYO,SAAS,MAAM,CAAC,MAAM;gBAClC,SAAS,CAACoB;oBACR1B,UAAU0B;oBACV,IAAI,CAACA,MAAM,gBAAgB,EAAE;wBAC3B,MAAMC,OAAOf,KAAK,OAAO;wBACzB,IAAIe,MAAM;4BACRA,KAAK,KAAK,CAAC,WAAW,CACpB,oBACA,GAAGA,KAAK,qBAAqB,GAAG,KAAK,CAAC,EAAE,CAAC;4BAEtCA,KAAK,WAAW;4BACrB,IAAIA,KAAK,QAAQ,CAACC,SAAS,aAAa,GAAG;gCACzC,MAAMC,UAAUC,MAAM,IAAI,CACxBH,KAAK,aAAa,EAAE,iBAAoC,uBACtD,EAAE;gCAEN,MAAMI,QAAQF,QAAQ,OAAO,CAACH,MAAM,aAAa;gCAChDG,CAAAA,OAAO,CAACE,QAAQ,EAAE,IAAIF,OAAO,CAACE,QAAQ,EAAC,GAAI;4BAC9C;wBACF;wBACArB,UAAU;oBACZ;gBACF;0BAEA,mDAACsB,sCAAAA,CAACA,EAAAA;oBAAC,MAAM;oBAAI,eAAY;;;;;AAKnC"}
@@ -1,10 +1,9 @@
1
1
  import { type HTMLAttributes, type MouseEvent, type ReactNode } from 'react';
2
2
  import type { ControlSize } from '../shared/types.cjs';
3
3
  export interface TagProps extends HTMLAttributes<HTMLSpanElement> {
4
- color?: 'default' | 'primary' | 'success' | 'warning' | 'danger' | 'error' | 'info' | (string & {});
5
- variant?: 'soft' | 'outline';
4
+ color?: 'default' | 'success' | 'warning' | 'danger' | 'info' | (string & {});
5
+ variant?: 'soft' | 'solid';
6
6
  size?: ControlSize;
7
- dot?: boolean;
8
7
  icon?: ReactNode;
9
8
  closable?: boolean;
10
9
  onClose?: (event: MouseEvent<HTMLButtonElement>) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"tag.d.cts","sourceRoot":"","sources":["../../../src/tag/tag.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AAOf,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,WAAW,QAAS,SAAQ,cAAc,CAAC,eAAe,CAAC;IAC/D,KAAK,CAAC,EACF,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,QAAQ,GACR,OAAO,GACP,MAAM,GACN,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;CAC1D;AA2BD,wBAAgB,GAAG,CAAC,QAAQ,EAAE,QAAQ,sCAiFrC"}
1
+ {"version":3,"file":"tag.d.cts","sourceRoot":"","sources":["../../../src/tag/tag.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AAOf,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,WAAW,QAAS,SAAQ,cAAc,CAAC,eAAe,CAAC;IAC/D,KAAK,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAC9E,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;CAC1D;AA4BD,wBAAgB,GAAG,CAAC,QAAQ,EAAE,QAAQ,sCAgFrC"}
@@ -1,5 +1,7 @@
1
- import { type HTMLAttributes } from 'react';
1
+ import { type HTMLAttributes, type ReactNode } from 'react';
2
2
  export interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
3
+ /** The element the indicator is attached to. Standalone badges are not rendered. */
4
+ children: ReactNode;
3
5
  count?: number | string;
4
6
  max?: number;
5
7
  showZero?: boolean;
@@ -8,5 +10,5 @@ export interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
8
10
  placement?: 'outside' | 'inside';
9
11
  color?: string;
10
12
  }
11
- export declare function Badge(rawProps: BadgeProps): import("react").JSX.Element;
13
+ export declare function Badge(rawProps: BadgeProps): import("react").JSX.Element | null;
12
14
  //# sourceMappingURL=badge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"badge.d.ts","sourceRoot":"","sources":["../../../src/badge/badge.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,cAAc,EAAU,MAAM,OAAO,CAAC;AAK9D,MAAM,WAAW,UAAW,SAAQ,cAAc,CAAC,eAAe,CAAC;IACjE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,4DAA4D;IAC5D,SAAS,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAUD,wBAAgB,KAAK,CAAC,QAAQ,EAAE,UAAU,+BAwDzC"}
1
+ {"version":3,"file":"badge.d.ts","sourceRoot":"","sources":["../../../src/badge/badge.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,cAAc,EAAE,KAAK,SAAS,EAAU,MAAM,OAAO,CAAC;AAK9E,MAAM,WAAW,UAAW,SAAQ,cAAc,CAAC,eAAe,CAAC;IACjE,oFAAoF;IACpF,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,4DAA4D;IAC5D,SAAS,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAUD,wBAAgB,KAAK,CAAC,QAAQ,EAAE,UAAU,sCAqDzC"}
@@ -21,9 +21,10 @@ function Badge(rawProps) {
21
21
  const visible = dot || hasCount;
22
22
  const display = 'number' == typeof count && count > max ? `${max}+` : count;
23
23
  useContentTransition(number, display ?? '');
24
+ if (!attached) return null;
24
25
  return /*#__PURE__*/ jsxs("span", {
25
26
  ...props,
26
- className: classes('leaf-badge', attached ? 'leaf-badge--attached' : 'leaf-badge--standalone', className),
27
+ className: classes('leaf-badge', 'leaf-badge--attached', className),
27
28
  "data-placement": placement,
28
29
  style: {
29
30
  ...color ? {
@@ -1 +1 @@
1
- {"version":3,"file":"badge/badge.js","sources":["../../../src/badge/badge.tsx"],"sourcesContent":["import { Children, type HTMLAttributes, useRef } from 'react';\nimport { useComponentProps } from '../config-provider/component-defaults';\nimport { classes } from '../shared/classes';\nimport { useContentTransition } from '../shared/presence';\n\nexport interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {\n count?: number | string;\n max?: number;\n showZero?: boolean;\n dot?: boolean;\n /** Position of an attached indicator. @default 'outside' */\n placement?: 'outside' | 'inside';\n color?: string;\n}\n\nconst familyForegrounds: Record<string, string> = {\n primary: 'var(--leaf-color-on-primary)',\n success: 'var(--leaf-color-on-success)',\n danger: 'var(--leaf-color-on-danger)',\n warning: 'var(--leaf-color-on-warning)',\n info: 'var(--leaf-color-on-info)',\n};\n\nexport function Badge(rawProps: BadgeProps) {\n const {\n count,\n max = 99,\n showZero = false,\n dot = false,\n placement = 'outside',\n color,\n children,\n className,\n style,\n ...props\n } = useComponentProps('Badge', rawProps);\n const family = color?.match(/^var\\(--leaf-color-(primary|success|danger|warning|info)\\)$/)?.[1];\n // Semantic family colors follow their own on*Color; custom colors use the primary foreground.\n const foreground = (family && familyForegrounds[family]) || 'var(--leaf-color-on-primary)';\n const attached = Children.toArray(children).length > 0;\n const number = useRef<HTMLSpanElement>(null);\n const hasCount = count !== undefined && count !== '' && (count !== 0 || showZero);\n const visible = dot || hasCount;\n const display = typeof count === 'number' && count > max ? `${max}+` : count;\n useContentTransition(number, display ?? '');\n return (\n <span\n {...props}\n className={classes(\n 'leaf-badge',\n attached ? 'leaf-badge--attached' : 'leaf-badge--standalone',\n className,\n )}\n data-placement={placement}\n style={{\n ...(color ? { '--leaf-badge-color': color } : {}),\n ...(color ? { '--leaf-badge-on-color': foreground } : {}),\n ...style,\n }}\n >\n {children}\n {visible && (\n <span\n className={classes('leaf-badge__indicator', dot && 'leaf-badge__indicator--dot')}\n role=\"status\"\n aria-label={\n props['aria-label'] ?? (!dot && count !== undefined ? String(count) : undefined)\n }\n title={count === undefined ? undefined : String(count)}\n >\n {!dot && (\n <span ref={number} className=\"leaf-badge__count\">\n {display}\n </span>\n )}\n </span>\n )}\n </span>\n );\n}\n"],"names":["familyForegrounds","Badge","rawProps","count","max","showZero","dot","placement","color","children","className","style","props","useComponentProps","family","foreground","attached","Children","number","useRef","hasCount","undefined","visible","display","useContentTransition","classes","String"],"mappings":";;;;;;AAeA,MAAMA,oBAA4C;IAChD,SAAS;IACT,SAAS;IACT,QAAQ;IACR,SAAS;IACT,MAAM;AACR;AAEO,SAASC,MAAMC,QAAoB;IACxC,MAAM,EACJC,KAAK,EACLC,MAAM,EAAE,EACRC,WAAW,KAAK,EAChBC,MAAM,KAAK,EACXC,YAAY,SAAS,EACrBC,KAAK,EACLC,QAAQ,EACRC,SAAS,EACTC,KAAK,EACL,GAAGC,OACJ,GAAGC,kBAAkB,SAASX;IAC/B,MAAMY,SAASN,OAAO,MAAM,gEAAgE,CAAC,EAAE;IAE/F,MAAMO,aAAcD,UAAUd,iBAAiB,CAACc,OAAO,IAAK;IAC5D,MAAME,WAAWC,SAAS,OAAO,CAACR,UAAU,MAAM,GAAG;IACrD,MAAMS,SAASC,OAAwB;IACvC,MAAMC,WAAWjB,AAAUkB,WAAVlB,SAAuBA,AAAU,OAAVA,SAAiBA,CAAAA,AAAU,MAAVA,SAAeE,QAAO;IAC/E,MAAMiB,UAAUhB,OAAOc;IACvB,MAAMG,UAAU,AAAiB,YAAjB,OAAOpB,SAAsBA,QAAQC,MAAM,GAAGA,IAAI,CAAC,CAAC,GAAGD;IACvEqB,qBAAqBN,QAAQK,WAAW;IACxC,OAAO,WAAP,GACE,KAAC;QACE,GAAGX,KAAK;QACT,WAAWa,QACT,cACAT,WAAW,yBAAyB,0BACpCN;QAEF,kBAAgBH;QAChB,OAAO;YACL,GAAIC,QAAQ;gBAAE,sBAAsBA;YAAM,IAAI,CAAC,CAAC;YAChD,GAAIA,QAAQ;gBAAE,yBAAyBO;YAAW,IAAI,CAAC,CAAC;YACxD,GAAGJ,KAAK;QACV;;YAECF;YACAa,WAAW,WAAXA,GACC,IAAC;gBACC,WAAWG,QAAQ,yBAAyBnB,OAAO;gBACnD,MAAK;gBACL,cACEM,KAAK,CAAC,aAAa,IAAK,CAACN,OAAOH,AAAUkB,WAAVlB,QAAsCkB,SAAhBK,OAAOvB,MAAiB;gBAEhF,OAAOA,AAAUkB,WAAVlB,QAAsBkB,SAAYK,OAAOvB;0BAE/C,CAACG,OAAO,WAAPA,GACA,IAAC;oBAAK,KAAKY;oBAAQ,WAAU;8BAC1BK;;;;;AAOf"}
1
+ {"version":3,"file":"badge/badge.js","sources":["../../../src/badge/badge.tsx"],"sourcesContent":["import { Children, type HTMLAttributes, type ReactNode, useRef } from 'react';\nimport { useComponentProps } from '../config-provider/component-defaults';\nimport { classes } from '../shared/classes';\nimport { useContentTransition } from '../shared/presence';\n\nexport interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {\n /** The element the indicator is attached to. Standalone badges are not rendered. */\n children: ReactNode;\n count?: number | string;\n max?: number;\n showZero?: boolean;\n dot?: boolean;\n /** Position of an attached indicator. @default 'outside' */\n placement?: 'outside' | 'inside';\n color?: string;\n}\n\nconst familyForegrounds: Record<string, string> = {\n primary: 'var(--leaf-color-on-primary)',\n success: 'var(--leaf-color-on-success)',\n danger: 'var(--leaf-color-on-danger)',\n warning: 'var(--leaf-color-on-warning)',\n info: 'var(--leaf-color-on-info)',\n};\n\nexport function Badge(rawProps: BadgeProps) {\n const {\n count,\n max = 99,\n showZero = false,\n dot = false,\n placement = 'outside',\n color,\n children,\n className,\n style,\n ...props\n } = useComponentProps('Badge', rawProps);\n const family = color?.match(/^var\\(--leaf-color-(primary|success|danger|warning|info)\\)$/)?.[1];\n // Semantic family colors follow their own on*Color; custom colors use the primary foreground.\n const foreground = (family && familyForegrounds[family]) || 'var(--leaf-color-on-primary)';\n const attached = Children.toArray(children).length > 0;\n const number = useRef<HTMLSpanElement>(null);\n const hasCount = count !== undefined && count !== '' && (count !== 0 || showZero);\n const visible = dot || hasCount;\n const display = typeof count === 'number' && count > max ? `${max}+` : count;\n useContentTransition(number, display ?? '');\n if (!attached) return null;\n return (\n <span\n {...props}\n className={classes('leaf-badge', 'leaf-badge--attached', className)}\n data-placement={placement}\n style={{\n ...(color ? { '--leaf-badge-color': color } : {}),\n ...(color ? { '--leaf-badge-on-color': foreground } : {}),\n ...style,\n }}\n >\n {children}\n {visible && (\n <span\n className={classes('leaf-badge__indicator', dot && 'leaf-badge__indicator--dot')}\n role=\"status\"\n aria-label={\n props['aria-label'] ?? (!dot && count !== undefined ? String(count) : undefined)\n }\n title={count === undefined ? undefined : String(count)}\n >\n {!dot && (\n <span ref={number} className=\"leaf-badge__count\">\n {display}\n </span>\n )}\n </span>\n )}\n </span>\n );\n}\n"],"names":["familyForegrounds","Badge","rawProps","count","max","showZero","dot","placement","color","children","className","style","props","useComponentProps","family","foreground","attached","Children","number","useRef","hasCount","undefined","visible","display","useContentTransition","classes","String"],"mappings":";;;;;;AAiBA,MAAMA,oBAA4C;IAChD,SAAS;IACT,SAAS;IACT,QAAQ;IACR,SAAS;IACT,MAAM;AACR;AAEO,SAASC,MAAMC,QAAoB;IACxC,MAAM,EACJC,KAAK,EACLC,MAAM,EAAE,EACRC,WAAW,KAAK,EAChBC,MAAM,KAAK,EACXC,YAAY,SAAS,EACrBC,KAAK,EACLC,QAAQ,EACRC,SAAS,EACTC,KAAK,EACL,GAAGC,OACJ,GAAGC,kBAAkB,SAASX;IAC/B,MAAMY,SAASN,OAAO,MAAM,gEAAgE,CAAC,EAAE;IAE/F,MAAMO,aAAcD,UAAUd,iBAAiB,CAACc,OAAO,IAAK;IAC5D,MAAME,WAAWC,SAAS,OAAO,CAACR,UAAU,MAAM,GAAG;IACrD,MAAMS,SAASC,OAAwB;IACvC,MAAMC,WAAWjB,AAAUkB,WAAVlB,SAAuBA,AAAU,OAAVA,SAAiBA,CAAAA,AAAU,MAAVA,SAAeE,QAAO;IAC/E,MAAMiB,UAAUhB,OAAOc;IACvB,MAAMG,UAAU,AAAiB,YAAjB,OAAOpB,SAAsBA,QAAQC,MAAM,GAAGA,IAAI,CAAC,CAAC,GAAGD;IACvEqB,qBAAqBN,QAAQK,WAAW;IACxC,IAAI,CAACP,UAAU,OAAO;IACtB,OAAO,WAAP,GACE,KAAC;QACE,GAAGJ,KAAK;QACT,WAAWa,QAAQ,cAAc,wBAAwBf;QACzD,kBAAgBH;QAChB,OAAO;YACL,GAAIC,QAAQ;gBAAE,sBAAsBA;YAAM,IAAI,CAAC,CAAC;YAChD,GAAIA,QAAQ;gBAAE,yBAAyBO;YAAW,IAAI,CAAC,CAAC;YACxD,GAAGJ,KAAK;QACV;;YAECF;YACAa,WAAW,WAAXA,GACC,IAAC;gBACC,WAAWG,QAAQ,yBAAyBnB,OAAO;gBACnD,MAAK;gBACL,cACEM,KAAK,CAAC,aAAa,IAAK,CAACN,OAAOH,AAAUkB,WAAVlB,QAAsCkB,SAAhBK,OAAOvB,MAAiB;gBAEhF,OAAOA,AAAUkB,WAAVlB,QAAsBkB,SAAYK,OAAOvB;0BAE/C,CAACG,OAAO,WAAPA,GACA,IAAC;oBAAK,KAAKY;oBAAQ,WAAU;8BAC1BK;;;;;AAOf"}
@@ -23,9 +23,10 @@ function Badge(rawProps) {
23
23
  const visible = dot || hasCount;
24
24
  const display = 'number' == typeof count && count > max ? `${max}+` : count;
25
25
  useContentTransition(number, display ?? '');
26
+ if (!attached) return null;
26
27
  return /*#__PURE__*/ jsxs("span", {
27
28
  ...props,
28
- className: classes('leaf-badge', attached ? 'leaf-badge--attached' : 'leaf-badge--standalone', className),
29
+ className: classes('leaf-badge', 'leaf-badge--attached', className),
29
30
  "data-placement": placement,
30
31
  style: {
31
32
  ...color ? {
@@ -1 +1 @@
1
- {"version":3,"file":"badge/badge.js","sources":["../../../../../src/badge/badge.tsx"],"sourcesContent":["import { Children, type HTMLAttributes, useRef } from 'react';\nimport { useComponentProps } from '../config-provider/component-defaults';\nimport { classes } from '../shared/classes';\nimport { useContentTransition } from '../shared/presence';\n\nexport interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {\n count?: number | string;\n max?: number;\n showZero?: boolean;\n dot?: boolean;\n /** Position of an attached indicator. @default 'outside' */\n placement?: 'outside' | 'inside';\n color?: string;\n}\n\nconst familyForegrounds: Record<string, string> = {\n primary: 'var(--leaf-color-on-primary)',\n success: 'var(--leaf-color-on-success)',\n danger: 'var(--leaf-color-on-danger)',\n warning: 'var(--leaf-color-on-warning)',\n info: 'var(--leaf-color-on-info)',\n};\n\nexport function Badge(rawProps: BadgeProps) {\n const {\n count,\n max = 99,\n showZero = false,\n dot = false,\n placement = 'outside',\n color,\n children,\n className,\n style,\n ...props\n } = useComponentProps('Badge', rawProps);\n const family = color?.match(/^var\\(--leaf-color-(primary|success|danger|warning|info)\\)$/)?.[1];\n // Semantic family colors follow their own on*Color; custom colors use the primary foreground.\n const foreground = (family && familyForegrounds[family]) || 'var(--leaf-color-on-primary)';\n const attached = Children.toArray(children).length > 0;\n const number = useRef<HTMLSpanElement>(null);\n const hasCount = count !== undefined && count !== '' && (count !== 0 || showZero);\n const visible = dot || hasCount;\n const display = typeof count === 'number' && count > max ? `${max}+` : count;\n useContentTransition(number, display ?? '');\n return (\n <span\n {...props}\n className={classes(\n 'leaf-badge',\n attached ? 'leaf-badge--attached' : 'leaf-badge--standalone',\n className,\n )}\n data-placement={placement}\n style={{\n ...(color ? { '--leaf-badge-color': color } : {}),\n ...(color ? { '--leaf-badge-on-color': foreground } : {}),\n ...style,\n }}\n >\n {children}\n {visible && (\n <span\n className={classes('leaf-badge__indicator', dot && 'leaf-badge__indicator--dot')}\n role=\"status\"\n aria-label={\n props['aria-label'] ?? (!dot && count !== undefined ? String(count) : undefined)\n }\n title={count === undefined ? undefined : String(count)}\n >\n {!dot && (\n <span ref={number} className=\"leaf-badge__count\">\n {display}\n </span>\n )}\n </span>\n )}\n </span>\n );\n}\n"],"names":["familyForegrounds","Badge","rawProps","count","max","showZero","dot","placement","color","children","className","style","props","useComponentProps","family","foreground","attached","Children","number","useRef","hasCount","undefined","visible","display","useContentTransition","classes","String"],"mappings":";;;;;;;;AAeA,MAAMA,oBAA4C;IAChD,SAAS;IACT,SAAS;IACT,QAAQ;IACR,SAAS;IACT,MAAM;AACR;AAEO,SAASC,MAAMC,QAAoB;IACxC,MAAM,EACJC,KAAK,EACLC,MAAM,EAAE,EACRC,WAAW,KAAK,EAChBC,MAAM,KAAK,EACXC,YAAY,SAAS,EACrBC,KAAK,EACLC,QAAQ,EACRC,SAAS,EACTC,KAAK,EACL,GAAGC,OACJ,GAAGC,kBAAkB,SAASX;IAC/B,MAAMY,SAASN,OAAO,MAAM,gEAAgE,CAAC,EAAE;IAE/F,MAAMO,aAAcD,UAAUd,iBAAiB,CAACc,OAAO,IAAK;IAC5D,MAAME,WAAWC,SAAS,OAAO,CAACR,UAAU,MAAM,GAAG;IACrD,MAAMS,SAASC,OAAwB;IACvC,MAAMC,WAAWjB,AAAUkB,WAAVlB,SAAuBA,AAAU,OAAVA,SAAiBA,CAAAA,AAAU,MAAVA,SAAeE,QAAO;IAC/E,MAAMiB,UAAUhB,OAAOc;IACvB,MAAMG,UAAU,AAAiB,YAAjB,OAAOpB,SAAsBA,QAAQC,MAAM,GAAGA,IAAI,CAAC,CAAC,GAAGD;IACvEqB,qBAAqBN,QAAQK,WAAW;IACxC,OAAO,WAAP,GACE,KAAC;QACE,GAAGX,KAAK;QACT,WAAWa,QACT,cACAT,WAAW,yBAAyB,0BACpCN;QAEF,kBAAgBH;QAChB,OAAO;YACL,GAAIC,QAAQ;gBAAE,sBAAsBA;YAAM,IAAI,CAAC,CAAC;YAChD,GAAIA,QAAQ;gBAAE,yBAAyBO;YAAW,IAAI,CAAC,CAAC;YACxD,GAAGJ,KAAK;QACV;;YAECF;YACAa,WAAW,WAAXA,GACC,IAAC;gBACC,WAAWG,QAAQ,yBAAyBnB,OAAO;gBACnD,MAAK;gBACL,cACEM,KAAK,CAAC,aAAa,IAAK,CAACN,OAAOH,AAAUkB,WAAVlB,QAAsCkB,SAAhBK,OAAOvB,MAAiB;gBAEhF,OAAOA,AAAUkB,WAAVlB,QAAsBkB,SAAYK,OAAOvB;0BAE/C,CAACG,OAAO,WAAPA,GACA,IAAC;oBAAK,KAAKY;oBAAQ,WAAU;8BAC1BK;;;;;AAOf"}
1
+ {"version":3,"file":"badge/badge.js","sources":["../../../../../src/badge/badge.tsx"],"sourcesContent":["import { Children, type HTMLAttributes, type ReactNode, useRef } from 'react';\nimport { useComponentProps } from '../config-provider/component-defaults';\nimport { classes } from '../shared/classes';\nimport { useContentTransition } from '../shared/presence';\n\nexport interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {\n /** The element the indicator is attached to. Standalone badges are not rendered. */\n children: ReactNode;\n count?: number | string;\n max?: number;\n showZero?: boolean;\n dot?: boolean;\n /** Position of an attached indicator. @default 'outside' */\n placement?: 'outside' | 'inside';\n color?: string;\n}\n\nconst familyForegrounds: Record<string, string> = {\n primary: 'var(--leaf-color-on-primary)',\n success: 'var(--leaf-color-on-success)',\n danger: 'var(--leaf-color-on-danger)',\n warning: 'var(--leaf-color-on-warning)',\n info: 'var(--leaf-color-on-info)',\n};\n\nexport function Badge(rawProps: BadgeProps) {\n const {\n count,\n max = 99,\n showZero = false,\n dot = false,\n placement = 'outside',\n color,\n children,\n className,\n style,\n ...props\n } = useComponentProps('Badge', rawProps);\n const family = color?.match(/^var\\(--leaf-color-(primary|success|danger|warning|info)\\)$/)?.[1];\n // Semantic family colors follow their own on*Color; custom colors use the primary foreground.\n const foreground = (family && familyForegrounds[family]) || 'var(--leaf-color-on-primary)';\n const attached = Children.toArray(children).length > 0;\n const number = useRef<HTMLSpanElement>(null);\n const hasCount = count !== undefined && count !== '' && (count !== 0 || showZero);\n const visible = dot || hasCount;\n const display = typeof count === 'number' && count > max ? `${max}+` : count;\n useContentTransition(number, display ?? '');\n if (!attached) return null;\n return (\n <span\n {...props}\n className={classes('leaf-badge', 'leaf-badge--attached', className)}\n data-placement={placement}\n style={{\n ...(color ? { '--leaf-badge-color': color } : {}),\n ...(color ? { '--leaf-badge-on-color': foreground } : {}),\n ...style,\n }}\n >\n {children}\n {visible && (\n <span\n className={classes('leaf-badge__indicator', dot && 'leaf-badge__indicator--dot')}\n role=\"status\"\n aria-label={\n props['aria-label'] ?? (!dot && count !== undefined ? String(count) : undefined)\n }\n title={count === undefined ? undefined : String(count)}\n >\n {!dot && (\n <span ref={number} className=\"leaf-badge__count\">\n {display}\n </span>\n )}\n </span>\n )}\n </span>\n );\n}\n"],"names":["familyForegrounds","Badge","rawProps","count","max","showZero","dot","placement","color","children","className","style","props","useComponentProps","family","foreground","attached","Children","number","useRef","hasCount","undefined","visible","display","useContentTransition","classes","String"],"mappings":";;;;;;;;AAiBA,MAAMA,oBAA4C;IAChD,SAAS;IACT,SAAS;IACT,QAAQ;IACR,SAAS;IACT,MAAM;AACR;AAEO,SAASC,MAAMC,QAAoB;IACxC,MAAM,EACJC,KAAK,EACLC,MAAM,EAAE,EACRC,WAAW,KAAK,EAChBC,MAAM,KAAK,EACXC,YAAY,SAAS,EACrBC,KAAK,EACLC,QAAQ,EACRC,SAAS,EACTC,KAAK,EACL,GAAGC,OACJ,GAAGC,kBAAkB,SAASX;IAC/B,MAAMY,SAASN,OAAO,MAAM,gEAAgE,CAAC,EAAE;IAE/F,MAAMO,aAAcD,UAAUd,iBAAiB,CAACc,OAAO,IAAK;IAC5D,MAAME,WAAWC,SAAS,OAAO,CAACR,UAAU,MAAM,GAAG;IACrD,MAAMS,SAASC,OAAwB;IACvC,MAAMC,WAAWjB,AAAUkB,WAAVlB,SAAuBA,AAAU,OAAVA,SAAiBA,CAAAA,AAAU,MAAVA,SAAeE,QAAO;IAC/E,MAAMiB,UAAUhB,OAAOc;IACvB,MAAMG,UAAU,AAAiB,YAAjB,OAAOpB,SAAsBA,QAAQC,MAAM,GAAGA,IAAI,CAAC,CAAC,GAAGD;IACvEqB,qBAAqBN,QAAQK,WAAW;IACxC,IAAI,CAACP,UAAU,OAAO;IACtB,OAAO,WAAP,GACE,KAAC;QACE,GAAGJ,KAAK;QACT,WAAWa,QAAQ,cAAc,wBAAwBf;QACzD,kBAAgBH;QAChB,OAAO;YACL,GAAIC,QAAQ;gBAAE,sBAAsBA;YAAM,IAAI,CAAC,CAAC;YAChD,GAAIA,QAAQ;gBAAE,yBAAyBO;YAAW,IAAI,CAAC,CAAC;YACxD,GAAGJ,KAAK;QACV;;YAECF;YACAa,WAAW,WAAXA,GACC,IAAC;gBACC,WAAWG,QAAQ,yBAAyBnB,OAAO;gBACnD,MAAK;gBACL,cACEM,KAAK,CAAC,aAAa,IAAK,CAACN,OAAOH,AAAUkB,WAAVlB,QAAsCkB,SAAhBK,OAAOvB,MAAiB;gBAEhF,OAAOA,AAAUkB,WAAVlB,QAAsBkB,SAAYK,OAAOvB;0BAE/C,CAACG,OAAO,WAAPA,GACA,IAAC;oBAAK,KAAKY;oBAAQ,WAAU;8BAC1BK;;;;;AAOf"}
@@ -16,16 +16,16 @@ const semanticColorFamilies = [
16
16
  ];
17
17
  const semanticSeeds = {
18
18
  primary: '#1e964f',
19
- success: '#1e964f',
20
- danger: '#dd3f2e',
21
- warning: '#d38b11',
19
+ success: '#52c41a',
20
+ danger: '#ff4d4f',
21
+ warning: '#faad14',
22
22
  info: '#1677ff'
23
23
  };
24
24
  const colorSeeds = {
25
25
  ...semanticSeeds,
26
- neutral: '#707070'
26
+ neutral: '#6c737e'
27
27
  };
28
- const neutralColorScale = generateColorScale('#707070');
28
+ const neutralColorScale = generateColorScale(colorSeeds.neutral);
29
29
  const defaultColors = {
30
30
  light: {
31
31
  ...semanticSeeds,
@@ -1 +1 @@
1
- {"version":3,"file":"colors.js","sources":["../../../../src/colors.ts"],"sourcesContent":["import { readability, TinyColor } from '@ctrl/tinycolor';\nimport { colorRecipes } from './color-recipes';\nimport {\n type ColorScale,\n type ColorScaleStep,\n colorScaleChromaFactors,\n colorScaleLightness,\n colorScaleSteps,\n generateColorScale,\n} from './color-scale';\nimport { type ColorShades, semanticColorShadeSteps } from './color-shades';\n\nconst solidForeground = { black: '#000000', white: '#ffffff' } as const;\nexport const semanticColorFamilies = ['primary', 'success', 'danger', 'warning', 'info'] as const;\nconst semanticSeeds = {\n primary: '#1e964f',\n success: '#1e964f',\n danger: '#dd3f2e',\n warning: '#d38b11',\n info: '#1677ff',\n};\nexport const colorSeeds = { ...semanticSeeds, neutral: '#707070' };\n\nexport const neutralColorScale = generateColorScale('#707070') as ColorScale;\n\nexport const defaultColors = {\n light: {\n ...semanticSeeds,\n neutral: colorSeeds.neutral,\n 'on-primary': solidForeground.white,\n 'on-danger': solidForeground.white,\n 'on-warning': solidForeground.white,\n 'on-info': solidForeground.white,\n 'on-success': solidForeground.white,\n text: neutralColorScale[900],\n 'text-muted': neutralColorScale[600],\n surface: solidForeground.white,\n 'surface-muted': neutralColorScale[100],\n border: neutralColorScale[200],\n },\n dark: {\n ...semanticSeeds,\n neutral: colorSeeds.neutral,\n 'on-primary': solidForeground.white,\n 'on-danger': solidForeground.white,\n 'on-warning': solidForeground.white,\n 'on-info': solidForeground.white,\n 'on-success': solidForeground.white,\n text: neutralColorScale[100],\n 'text-muted': neutralColorScale[400],\n surface: neutralColorScale[900],\n 'surface-muted': neutralColorScale[800],\n border: neutralColorScale[800],\n },\n};\n\nconst cssColorExpression = (color: string) =>\n /^(?:var|color-mix|light-dark|oklch|oklab|lab|lch|color|hwb)\\(/i.test(color);\n\n/** sRGB mixing with premultiplied alpha, matching CSS transparent-color semantics. */\nexport function mixColors(\n first: string | undefined,\n second: string | undefined,\n weight: number,\n): string | undefined {\n if (!first || !second) return undefined;\n const a = new TinyColor(first);\n const b = new TinyColor(second);\n if (cssColorExpression(first) || cssColorExpression(second) || !a.isValid || !b.isValid) {\n const cssColor = (value: string) => cssColorExpression(value) || new TinyColor(value).isValid;\n return cssColor(first) && cssColor(second)\n ? `color-mix(in srgb, ${first} ${Math.min(100, Math.max(0, weight))}%, ${second})`\n : undefined;\n }\n const x = a.toRgb();\n const y = b.toRgb();\n const ratio = Math.min(1, Math.max(0, weight / 100));\n const alpha = x.a * ratio + y.a * (1 - ratio);\n const channel = (key: 'r' | 'g' | 'b') =>\n alpha ? Math.round((x[key] * x.a * ratio + y[key] * y.a * (1 - ratio)) / alpha) : 0;\n return `rgba(${channel('r')}, ${channel('g')}, ${channel('b')}, ${Number(alpha.toFixed(4))})`;\n}\n\ntype ColorVariables = Record<`--leaf-${string}`, string>;\ntype RoleChoice = { value: string; source: string };\n\nconst colorVariable = (name: string): `--leaf-${string}` => `--leaf-color-${name}`;\nconst concreteOpaque = (value: string) => {\n const parsed = new TinyColor(value);\n return !cssColorExpression(value) && parsed.isValid && parsed.getAlpha() === 1;\n};\n\nfunction scaleForColor(color: string): ColorScale {\n const generated = generateColorScale(color);\n if (generated) return generated;\n // CSS expressions stay browser-native; no DOM reads or hydration color probes are needed.\n return Object.fromEntries(\n colorScaleSteps.map((step) => [\n step,\n `oklch(from ${color} ${colorScaleLightness[step]} calc(c * ${colorScaleChromaFactors[step]}) h)`,\n ]),\n ) as ColorScale;\n}\n\n/** Generate only the shared semantic shades; neutral lightness scales are independent. */\nexport function generateColorShades(color: string): ColorShades {\n return Object.fromEntries(\n semanticColorShadeSteps.map((step) => {\n const [direction, amount] = step.split('-');\n return [\n step,\n mixColors(\n color,\n direction === 'light' ? solidForeground.white : solidForeground.black,\n 100 - Number(amount) * 10,\n ) ?? color,\n ];\n }),\n ) as ColorShades;\n}\n\nfunction chooseReadableColor(\n family: string,\n shades: ColorShades,\n seed: string,\n source: string,\n darkSurface: boolean,\n backgrounds: string[],\n minimum: number,\n): RoleChoice {\n const ordered = [...semanticColorShadeSteps].sort((a, b) => {\n const preferred = darkSurface ? 'light' : 'dark';\n const priority = (step: string) =>\n (step.startsWith(preferred) ? 0 : 100) + Number(step.split('-')[1]);\n return priority(a) - priority(b);\n });\n const choice = (step: (typeof semanticColorShadeSteps)[number]) => ({\n value: shades[step],\n source: colorVariable(`${family}-${step}`),\n });\n // Expressions remain browser-native. Do not guess a different brand color during SSR.\n if (!backgrounds.every(concreteOpaque) || !concreteOpaque(seed)) return { value: seed, source };\n const matches = (value: string) =>\n backgrounds.every((background) => readability(value, background) >= minimum);\n if (matches(seed)) return { value: seed, source };\n for (const step of ordered) if (matches(shades[step])) return choice(step);\n for (const [source, value] of Object.entries(solidForeground))\n if (matches(value)) return { value, source };\n // Conflicting explicit surfaces can make a single accessible ink impossible.\n const score = (value: string) => Math.min(...backgrounds.map((bg) => readability(value, bg)));\n return [{ value: seed, source }, ...ordered.map(choice)].reduce((best, candidate) =>\n score(candidate.value) > score(best.value) ? candidate : best,\n );\n}\n\n/** Bases and their shades stay fixed across appearances; only role mappings switch. */\nexport function resolveColorRoles(\n appearance: 'light' | 'dark',\n overrides: Record<string, string> = {},\n families: readonly (typeof semanticColorFamilies)[number][] = semanticColorFamilies,\n): { values: ColorVariables; sources: Record<string, string> } {\n const colors: Record<string, string> = { ...defaultColors[appearance], ...overrides };\n const values: ColorVariables = {};\n const sources: Record<string, string> = {};\n const dark = appearance === 'dark';\n const assign = (name: string, value: string, source: string) => {\n const key = colorVariable(name);\n values[key] = overrides[name] ?? value;\n sources[key] = overrides[name] !== undefined ? 'override' : source;\n };\n const neutral = overrides.neutral ? scaleForColor(overrides.neutral) : neutralColorScale;\n assign('neutral', colors.neutral ?? colorSeeds.neutral, 'seed');\n for (const step of colorScaleSteps) values[colorVariable(`neutral-${step}`)] = neutral[step];\n const surfaceOverride = overrides.surface;\n const darkSurface =\n surfaceOverride && concreteOpaque(surfaceOverride)\n ? new TinyColor(surfaceOverride).getLuminance() < 0.18\n : dark;\n const neutralRoleSteps: Record<string, ColorScaleStep | 'white'> = {\n text: darkSurface ? 100 : 900,\n 'text-muted': darkSurface ? 400 : 600,\n 'text-subtle': darkSurface ? 400 : 600,\n surface: dark ? 900 : 'white',\n 'surface-muted': darkSurface ? 800 : 100,\n 'surface-raised': darkSurface ? 800 : 'white',\n border: darkSurface ? 800 : 200,\n 'border-hover': darkSurface ? 700 : 300,\n divider: darkSurface ? 800 : 200,\n 'option-hover': darkSurface ? 700 : 200,\n };\n for (const [name, step] of Object.entries(neutralRoleSteps))\n assign(\n name,\n step === 'white' ? solidForeground.white : neutral[step],\n step === 'white' ? 'white' : colorVariable(`neutral-${step}`),\n );\n\n const surface = values['--leaf-color-surface'] ?? colors.surface ?? '';\n const muted = values['--leaf-color-surface-muted'] ?? colors['surface-muted'] ?? '';\n const softStep = darkSurface ? 'dark-9' : 'light-9';\n const softHoverStep = darkSurface ? 'dark-7' : 'light-7';\n\n for (const family of families) {\n const seed = colors[family] ?? semanticSeeds[family];\n const shades = generateColorShades(seed);\n assign(family, seed, 'seed');\n for (const step of semanticColorShadeSteps)\n values[colorVariable(`${family}-${step}`)] = shades[step];\n assign(`${family}-soft`, shades[softStep], colorVariable(`${family}-${softStep}`));\n assign(\n `${family}-soft-hover`,\n shades[softHoverStep],\n colorVariable(`${family}-${softHoverStep}`),\n );\n assign(\n `${family}-soft-active`,\n shades[softHoverStep],\n colorVariable(`${family}-${softHoverStep}`),\n );\n assign(`${family}-border`, shades[softHoverStep], colorVariable(`${family}-${softHoverStep}`));\n const ink = chooseReadableColor(\n family,\n shades,\n seed,\n colorVariable(family),\n darkSurface,\n [surface, muted, values[colorVariable(`${family}-soft`)] ?? surface],\n 4.5,\n );\n assign(`${family}-ink`, ink.value, ink.source);\n // Solid labels default to white; on*Color tokens are the only way to switch them.\n assign(`on-${family}`, solidForeground.white, 'white');\n\n if (family === 'primary') {\n const indicator = chooseReadableColor(\n family,\n shades,\n seed,\n colorVariable(family),\n darkSurface,\n [surface, muted],\n 3,\n );\n assign('primary-indicator', indicator.value, indicator.source);\n const indicatorValue = values[colorVariable('primary-indicator')] ?? indicator.value;\n assign('primary-focus', indicatorValue, colorVariable('primary-indicator'));\n assign(\n 'primary-fill-border',\n indicatorValue === seed ? 'transparent' : indicatorValue,\n indicatorValue === seed ? 'transparent' : colorVariable('primary-indicator'),\n );\n }\n\n if (family === 'primary' || family === 'danger') {\n for (const state of ['active', 'hover'] as const) {\n const value =\n state === 'active'\n ? shades['dark-1']\n : (mixColors(seed, solidForeground.white, 90) ?? seed);\n assign(\n `${family}-${state}`,\n value,\n state === 'active' ? colorVariable(`${family}-dark-1`) : `mix(${family}, white, 90%)`,\n );\n if (family === 'primary') {\n const inkValue = values[colorVariable('primary-ink')] ?? ink.value;\n const stateBase =\n state === 'active'\n ? (mixColors(\n inkValue,\n darkSurface ? solidForeground.white : solidForeground.black,\n 90,\n ) ?? inkValue)\n : inkValue;\n const stateInk = chooseReadableColor(\n family,\n shades,\n stateBase,\n state === 'active'\n ? `mix(primary-ink, ${darkSurface ? 'white' : 'black'}, 90%)`\n : colorVariable('primary-ink'),\n darkSurface,\n [surface, muted],\n 4.5,\n );\n assign(`primary-ink-${state}`, stateInk.value, stateInk.source);\n }\n }\n }\n }\n return { values, sources };\n}\n\n/** Emit shared roles and only the optical recipes with actual consumers. */\nexport function deriveColors(appearance: 'light' | 'dark', overrides: Record<string, string> = {}) {\n const modern = resolveColorRoles(appearance, overrides);\n const colors: Record<string, string> = Object.fromEntries(\n Object.entries(modern.values).map(([key, value]) => [key.slice('--leaf-color-'.length), value]),\n );\n const result: ColorVariables = {};\n for (const [key, [first, second, ratio]] of Object.entries(colorRecipes)) {\n const other =\n second === 'alpha'\n ? 'transparent'\n : second === 'white'\n ? solidForeground.white\n : second === 'black'\n ? solidForeground.black\n : colors[second];\n const value = mixColors(colors[first], other, ratio);\n if (value) result[key as `--leaf-${string}`] = value;\n }\n return { ...result, ...modern.values };\n}\n"],"names":["solidForeground","semanticColorFamilies","semanticSeeds","colorSeeds","neutralColorScale","generateColorScale","defaultColors","cssColorExpression","color","mixColors","first","second","weight","a","TinyColor","b","cssColor","value","Math","undefined","x","y","ratio","alpha","channel","key","Number","colorVariable","name","concreteOpaque","parsed","scaleForColor","generated","Object","colorScaleSteps","step","colorScaleLightness","colorScaleChromaFactors","generateColorShades","semanticColorShadeSteps","direction","amount","chooseReadableColor","family","shades","seed","source","darkSurface","backgrounds","minimum","ordered","preferred","priority","choice","matches","background","readability","score","bg","best","candidate","resolveColorRoles","appearance","overrides","families","colors","values","sources","dark","assign","neutral","surfaceOverride","neutralRoleSteps","surface","muted","softStep","softHoverStep","ink","indicator","indicatorValue","state","inkValue","stateBase","stateInk","deriveColors","modern","result","colorRecipes","other"],"mappings":";;;;;AAYA,MAAMA,kBAAkB;IAAE,OAAO;IAAW,OAAO;AAAU;AACtD,MAAMC,wBAAwB;IAAC;IAAW;IAAW;IAAU;IAAW;CAAO;AACxF,MAAMC,gBAAgB;IACpB,SAAS;IACT,SAAS;IACT,QAAQ;IACR,SAAS;IACT,MAAM;AACR;AACO,MAAMC,aAAa;IAAE,GAAGD,aAAa;IAAE,SAAS;AAAU;AAE1D,MAAME,oBAAoBC,mBAAmB;AAE7C,MAAMC,gBAAgB;IAC3B,OAAO;QACL,GAAGJ,aAAa;QAChB,SAASC,WAAW,OAAO;QAC3B,cAAcH,gBAAgB,KAAK;QACnC,aAAaA,gBAAgB,KAAK;QAClC,cAAcA,gBAAgB,KAAK;QACnC,WAAWA,gBAAgB,KAAK;QAChC,cAAcA,gBAAgB,KAAK;QACnC,MAAMI,iBAAiB,CAAC,IAAI;QAC5B,cAAcA,iBAAiB,CAAC,IAAI;QACpC,SAASJ,gBAAgB,KAAK;QAC9B,iBAAiBI,iBAAiB,CAAC,IAAI;QACvC,QAAQA,iBAAiB,CAAC,IAAI;IAChC;IACA,MAAM;QACJ,GAAGF,aAAa;QAChB,SAASC,WAAW,OAAO;QAC3B,cAAcH,gBAAgB,KAAK;QACnC,aAAaA,gBAAgB,KAAK;QAClC,cAAcA,gBAAgB,KAAK;QACnC,WAAWA,gBAAgB,KAAK;QAChC,cAAcA,gBAAgB,KAAK;QACnC,MAAMI,iBAAiB,CAAC,IAAI;QAC5B,cAAcA,iBAAiB,CAAC,IAAI;QACpC,SAASA,iBAAiB,CAAC,IAAI;QAC/B,iBAAiBA,iBAAiB,CAA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AACoD,OAAO,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC5D,KAAKR,MAAM,GAAK;YAACQ,IAAI,KAAK,CAAC;YAAyBR;SAAM;IAEhG,MAAMqE,SAAyB,CAAC;IAChC,KAAK,MAAM,CAAC7D,KAAK,CAACf,OAAOC,QAAQW,MAAM,CAAC,IAAIW,OAAO,OAAO,CAACsD,cAAe;QACxE,MAAMC,QACJ7E,AAAW,YAAXA,SACI,gBACAA,AAAW,YAAXA,SACEX,gBAAgB,KAAK,GACrBW,AAAW,YAAXA,SACEX,gBAAgB,KAAK,GACrBiE,MAAM,CAACtD,OAAO;QACxB,MAAMM,QAAQR,UAAUwD,MAAM,CAACvD,MAAM,EAAE8E,OAAOlE;QAC9C,IAAIL,OAAOqE,MAAM,CAAC7D,IAA0B,GAAGR;IACjD;IACA,OAAO;QAAE,GAAGqE,MAAM;QAAE,GAAGD,OAAO,MAAM;IAAC;AACvC"}
1
+ {"version":3,"file":"colors.js","sources":["../../../../src/colors.ts"],"sourcesContent":["import { readability, TinyColor } from '@ctrl/tinycolor';\nimport { colorRecipes } from './color-recipes';\nimport {\n type ColorScale,\n type ColorScaleStep,\n colorScaleChromaFactors,\n colorScaleLightness,\n colorScaleSteps,\n generateColorScale,\n} from './color-scale';\nimport { type ColorShades, semanticColorShadeSteps } from './color-shades';\n\nconst solidForeground = { black: '#000000', white: '#ffffff' } as const;\nexport const semanticColorFamilies = ['primary', 'success', 'danger', 'warning', 'info'] as const;\nconst semanticSeeds = {\n primary: '#1e964f',\n success: '#52c41a',\n danger: '#ff4d4f',\n warning: '#faad14',\n info: '#1677ff',\n};\nexport const colorSeeds = { ...semanticSeeds, neutral: '#6c737e' };\n\nexport const neutralColorScale = generateColorScale(colorSeeds.neutral) as ColorScale;\n\nexport const defaultColors = {\n light: {\n ...semanticSeeds,\n neutral: colorSeeds.neutral,\n 'on-primary': solidForeground.white,\n 'on-danger': solidForeground.white,\n 'on-warning': solidForeground.white,\n 'on-info': solidForeground.white,\n 'on-success': solidForeground.white,\n text: neutralColorScale[900],\n 'text-muted': neutralColorScale[600],\n surface: solidForeground.white,\n 'surface-muted': neutralColorScale[100],\n border: neutralColorScale[200],\n },\n dark: {\n ...semanticSeeds,\n neutral: colorSeeds.neutral,\n 'on-primary': solidForeground.white,\n 'on-danger': solidForeground.white,\n 'on-warning': solidForeground.white,\n 'on-info': solidForeground.white,\n 'on-success': solidForeground.white,\n text: neutralColorScale[100],\n 'text-muted': neutralColorScale[400],\n surface: neutralColorScale[900],\n 'surface-muted': neutralColorScale[800],\n border: neutralColorScale[800],\n },\n};\n\nconst cssColorExpression = (color: string) =>\n /^(?:var|color-mix|light-dark|oklch|oklab|lab|lch|color|hwb)\\(/i.test(color);\n\n/** sRGB mixing with premultiplied alpha, matching CSS transparent-color semantics. */\nexport function mixColors(\n first: string | undefined,\n second: string | undefined,\n weight: number,\n): string | undefined {\n if (!first || !second) return undefined;\n const a = new TinyColor(first);\n const b = new TinyColor(second);\n if (cssColorExpression(first) || cssColorExpression(second) || !a.isValid || !b.isValid) {\n const cssColor = (value: string) => cssColorExpression(value) || new TinyColor(value).isValid;\n return cssColor(first) && cssColor(second)\n ? `color-mix(in srgb, ${first} ${Math.min(100, Math.max(0, weight))}%, ${second})`\n : undefined;\n }\n const x = a.toRgb();\n const y = b.toRgb();\n const ratio = Math.min(1, Math.max(0, weight / 100));\n const alpha = x.a * ratio + y.a * (1 - ratio);\n const channel = (key: 'r' | 'g' | 'b') =>\n alpha ? Math.round((x[key] * x.a * ratio + y[key] * y.a * (1 - ratio)) / alpha) : 0;\n return `rgba(${channel('r')}, ${channel('g')}, ${channel('b')}, ${Number(alpha.toFixed(4))})`;\n}\n\ntype ColorVariables = Record<`--leaf-${string}`, string>;\ntype RoleChoice = { value: string; source: string };\n\nconst colorVariable = (name: string): `--leaf-${string}` => `--leaf-color-${name}`;\nconst concreteOpaque = (value: string) => {\n const parsed = new TinyColor(value);\n return !cssColorExpression(value) && parsed.isValid && parsed.getAlpha() === 1;\n};\n\nfunction scaleForColor(color: string): ColorScale {\n const generated = generateColorScale(color);\n if (generated) return generated;\n // CSS expressions stay browser-native; no DOM reads or hydration color probes are needed.\n return Object.fromEntries(\n colorScaleSteps.map((step) => [\n step,\n `oklch(from ${color} ${colorScaleLightness[step]} calc(c * ${colorScaleChromaFactors[step]}) h)`,\n ]),\n ) as ColorScale;\n}\n\n/** Generate only the shared semantic shades; neutral lightness scales are independent. */\nexport function generateColorShades(color: string): ColorShades {\n return Object.fromEntries(\n semanticColorShadeSteps.map((step) => {\n const [direction, amount] = step.split('-');\n return [\n step,\n mixColors(\n color,\n direction === 'light' ? solidForeground.white : solidForeground.black,\n 100 - Number(amount) * 10,\n ) ?? color,\n ];\n }),\n ) as ColorShades;\n}\n\nfunction chooseReadableColor(\n family: string,\n shades: ColorShades,\n seed: string,\n source: string,\n darkSurface: boolean,\n backgrounds: string[],\n minimum: number,\n): RoleChoice {\n const ordered = [...semanticColorShadeSteps].sort((a, b) => {\n const preferred = darkSurface ? 'light' : 'dark';\n const priority = (step: string) =>\n (step.startsWith(preferred) ? 0 : 100) + Number(step.split('-')[1]);\n return priority(a) - priority(b);\n });\n const choice = (step: (typeof semanticColorShadeSteps)[number]) => ({\n value: shades[step],\n source: colorVariable(`${family}-${step}`),\n });\n // Expressions remain browser-native. Do not guess a different brand color during SSR.\n if (!backgrounds.every(concreteOpaque) || !concreteOpaque(seed)) return { value: seed, source };\n const matches = (value: string) =>\n backgrounds.every((background) => readability(value, background) >= minimum);\n if (matches(seed)) return { value: seed, source };\n for (const step of ordered) if (matches(shades[step])) return choice(step);\n for (const [source, value] of Object.entries(solidForeground))\n if (matches(value)) return { value, source };\n // Conflicting explicit surfaces can make a single accessible ink impossible.\n const score = (value: string) => Math.min(...backgrounds.map((bg) => readability(value, bg)));\n return [{ value: seed, source }, ...ordered.map(choice)].reduce((best, candidate) =>\n score(candidate.value) > score(best.value) ? candidate : best,\n );\n}\n\n/** Bases and their shades stay fixed across appearances; only role mappings switch. */\nexport function resolveColorRoles(\n appearance: 'light' | 'dark',\n overrides: Record<string, string> = {},\n families: readonly (typeof semanticColorFamilies)[number][] = semanticColorFamilies,\n): { values: ColorVariables; sources: Record<string, string> } {\n const colors: Record<string, string> = { ...defaultColors[appearance], ...overrides };\n const values: ColorVariables = {};\n const sources: Record<string, string> = {};\n const dark = appearance === 'dark';\n const assign = (name: string, value: string, source: string) => {\n const key = colorVariable(name);\n values[key] = overrides[name] ?? value;\n sources[key] = overrides[name] !== undefined ? 'override' : source;\n };\n const neutral = overrides.neutral ? scaleForColor(overrides.neutral) : neutralColorScale;\n assign('neutral', colors.neutral ?? colorSeeds.neutral, 'seed');\n for (const step of colorScaleSteps) values[colorVariable(`neutral-${step}`)] = neutral[step];\n const surfaceOverride = overrides.surface;\n const darkSurface =\n surfaceOverride && concreteOpaque(surfaceOverride)\n ? new TinyColor(surfaceOverride).getLuminance() < 0.18\n : dark;\n const neutralRoleSteps: Record<string, ColorScaleStep | 'white'> = {\n text: darkSurface ? 100 : 900,\n 'text-muted': darkSurface ? 400 : 600,\n 'text-subtle': darkSurface ? 400 : 600,\n surface: dark ? 900 : 'white',\n 'surface-muted': darkSurface ? 800 : 100,\n 'surface-raised': darkSurface ? 800 : 'white',\n border: darkSurface ? 800 : 200,\n 'border-hover': darkSurface ? 700 : 300,\n divider: darkSurface ? 800 : 200,\n 'option-hover': darkSurface ? 700 : 200,\n };\n for (const [name, step] of Object.entries(neutralRoleSteps))\n assign(\n name,\n step === 'white' ? solidForeground.white : neutral[step],\n step === 'white' ? 'white' : colorVariable(`neutral-${step}`),\n );\n\n const surface = values['--leaf-color-surface'] ?? colors.surface ?? '';\n const muted = values['--leaf-color-surface-muted'] ?? colors['surface-muted'] ?? '';\n const softStep = darkSurface ? 'dark-9' : 'light-9';\n const softHoverStep = darkSurface ? 'dark-7' : 'light-7';\n\n for (const family of families) {\n const seed = colors[family] ?? semanticSeeds[family];\n const shades = generateColorShades(seed);\n assign(family, seed, 'seed');\n for (const step of semanticColorShadeSteps)\n values[colorVariable(`${family}-${step}`)] = shades[step];\n assign(`${family}-soft`, shades[softStep], colorVariable(`${family}-${softStep}`));\n assign(\n `${family}-soft-hover`,\n shades[softHoverStep],\n colorVariable(`${family}-${softHoverStep}`),\n );\n assign(\n `${family}-soft-active`,\n shades[softHoverStep],\n colorVariable(`${family}-${softHoverStep}`),\n );\n assign(`${family}-border`, shades[softHoverStep], colorVariable(`${family}-${softHoverStep}`));\n const ink = chooseReadableColor(\n family,\n shades,\n seed,\n colorVariable(family),\n darkSurface,\n [surface, muted, values[colorVariable(`${family}-soft`)] ?? surface],\n 4.5,\n );\n assign(`${family}-ink`, ink.value, ink.source);\n // Solid labels default to white; on*Color tokens are the only way to switch them.\n assign(`on-${family}`, solidForeground.white, 'white');\n\n if (family === 'primary') {\n const indicator = chooseReadableColor(\n family,\n shades,\n seed,\n colorVariable(family),\n darkSurface,\n [surface, muted],\n 3,\n );\n assign('primary-indicator', indicator.value, indicator.source);\n const indicatorValue = values[colorVariable('primary-indicator')] ?? indicator.value;\n assign('primary-focus', indicatorValue, colorVariable('primary-indicator'));\n assign(\n 'primary-fill-border',\n indicatorValue === seed ? 'transparent' : indicatorValue,\n indicatorValue === seed ? 'transparent' : colorVariable('primary-indicator'),\n );\n }\n\n if (family === 'primary' || family === 'danger') {\n for (const state of ['active', 'hover'] as const) {\n const value =\n state === 'active'\n ? shades['dark-1']\n : (mixColors(seed, solidForeground.white, 90) ?? seed);\n assign(\n `${family}-${state}`,\n value,\n state === 'active' ? colorVariable(`${family}-dark-1`) : `mix(${family}, white, 90%)`,\n );\n if (family === 'primary') {\n const inkValue = values[colorVariable('primary-ink')] ?? ink.value;\n const stateBase =\n state === 'active'\n ? (mixColors(\n inkValue,\n darkSurface ? solidForeground.white : solidForeground.black,\n 90,\n ) ?? inkValue)\n : inkValue;\n const stateInk = chooseReadableColor(\n family,\n shades,\n stateBase,\n state === 'active'\n ? `mix(primary-ink, ${darkSurface ? 'white' : 'black'}, 90%)`\n : colorVariable('primary-ink'),\n darkSurface,\n [surface, muted],\n 4.5,\n );\n assign(`primary-ink-${state}`, stateInk.value, stateInk.source);\n }\n }\n }\n }\n return { values, sources };\n}\n\n/** Emit shared roles and only the optical recipes with actual consumers. */\nexport function deriveColors(appearance: 'light' | 'dark', overrides: Record<string, string> = {}) {\n const modern = resolveColorRoles(appearance, overrides);\n const colors: Record<string, string> = Object.fromEntries(\n Object.entries(modern.values).map(([key, value]) => [key.slice('--leaf-color-'.length), value]),\n );\n const result: ColorVariables = {};\n for (const [key, [first, second, ratio]] of Object.entries(colorRecipes)) {\n const other =\n second === 'alpha'\n ? 'transparent'\n : second === 'white'\n ? solidForeground.white\n : second === 'black'\n ? solidForeground.black\n : colors[second];\n const value = mixColors(colors[first], other, ratio);\n if (value) result[key as `--leaf-${string}`] = value;\n }\n return { ...result, ...modern.values };\n}\n"],"names":["solidForeground","semanticColorFamilies","semanticSeeds","colorSeeds","neutralColorScale","generateColorScale","defaultColors","cssColorExpression","color","mixColors","first","second","weight","a","TinyColor","b","cssColor","value","Math","undefined","x","y","ratio","alpha","channel","key","Number","colorVariable","name","concreteOpaque","parsed","scaleForColor","generated","Object","colorScaleSteps","step","colorScaleLightness","colorScaleChromaFactors","generateColorShades","semanticColorShadeSteps","direction","amount","chooseReadableColor","family","shades","seed","source","darkSurface","backgrounds","minimum","ordered","preferred","priority","choice","matches","background","readability","score","bg","best","candidate","resolveColorRoles","appearance","overrides","families","colors","values","sources","dark","assign","neutral","surfaceOverride","neutralRoleSteps","surface","muted","softStep","softHoverStep","ink","indicator","indicatorValue","state","inkValue","stateBase","stateInk","deriveColors","modern","result","colorRecipes","other"],"mappings":";;;;;AAYA,MAAMA,kBAAkB;IAAE,OAAO;IAAW,OAAO;AAAU;AACtD,MAAMC,wBAAwB;IAAC;IAAW;IAAW;IAAU;IAAW;CAAO;AACxF,MAAMC,gBAAgB;IACpB,SAAS;IACT,SAAS;IACT,QAAQ;IACR,SAAS;IACT,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UAAUwD,MAAM,CAACvD,MAAM,EAAE8E,OAAOlE;QAC9C,IAAIL,OAAOqE,MAAM,CAAC7D,IAA0B,GAAGR;IACjD;IACA,OAAO;QAAE,GAAGqE,MAAM;QAAE,GAAGD,OAAO,MAAM;IAAC;AACvC"}
@@ -3,7 +3,7 @@ import '../../../styles/foundation.css';
3
3
  import '../../../styles/components/menu.css';
4
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
5
  import { ChevronDown } from "lucide-react";
6
- import { forwardRef, useId, useRef, useState } from "react";
6
+ import { forwardRef, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
7
7
  import { useComponentProps } from "../config-provider/component-defaults.js";
8
8
  import { useLeafConfig } from "../config-provider/context.js";
9
9
  import { DropdownControl } from "../dropdown/dropdown.js";
@@ -11,6 +11,7 @@ import { classes } from "../shared/classes.js";
11
11
  import { inertProps } from "../shared/inert.js";
12
12
  import { useControllable } from "../shared/use-controllable.js";
13
13
  import { useText } from "../shared/use-text.js";
14
+ const useBrowserLayoutEffect = "u" < typeof window ? useEffect : useLayoutEffect;
14
15
  const menu_MenuGroupControl = /*#__PURE__*/ forwardRef(function({ title, children, className, ...props }, ref) {
15
16
  const titleId = useId();
16
17
  return /*#__PURE__*/ jsxs("div", {
@@ -37,20 +38,28 @@ const menu_MenuGroup = /*#__PURE__*/ forwardRef(function(rawProps, ref) {
37
38
  className: classes('leaf-menu-group', props.className)
38
39
  });
39
40
  });
40
- function MenuSubmenu({ open, id, label, lineOffset, children }) {
41
+ function MenuSubmenu({ open, id, label, children }) {
42
+ const panel = useRef(null);
43
+ const [expanded, setExpanded] = useState(open);
41
44
  const [visited, setVisited] = useState(open);
42
45
  if (open && !visited) setVisited(true);
46
+ useBrowserLayoutEffect(()=>{
47
+ if (expanded === open) return;
48
+ panel.current?.getBoundingClientRect();
49
+ setExpanded(open);
50
+ }, [
51
+ expanded,
52
+ open
53
+ ]);
43
54
  return /*#__PURE__*/ jsx("div", {
55
+ ref: panel,
44
56
  id: id,
45
57
  role: "menu",
46
58
  className: "leaf-menu__submenu",
47
59
  "aria-label": label,
48
60
  "aria-hidden": !open || void 0,
49
61
  ...inertProps(!open),
50
- "data-open": open || void 0,
51
- style: {
52
- '--leaf-menu-submenu-line-offset': lineOffset
53
- },
62
+ "data-open": expanded || void 0,
54
63
  children: /*#__PURE__*/ jsx("div", {
55
64
  className: "leaf-menu__submenu-inner",
56
65
  children: /*#__PURE__*/ jsx("div", {
@@ -154,7 +163,7 @@ function Menu(rawProps) {
154
163
  onFocus: ()=>setActive(item.key),
155
164
  title: collapsed && 'string' == typeof item.label ? item.label : void 0,
156
165
  style: {
157
- paddingInlineStart: depth ? `calc(${12 + 32 * depth}px - var(--leaf-menu-submenu-line-offset) - 9px)` : 12
166
+ paddingInlineStart: 12 + 32 * depth
158
167
  }
159
168
  };
160
169
  const activate = ()=>{
@@ -218,7 +227,6 @@ function Menu(rawProps) {
218
227
  id: `${id}-${item.key}`,
219
228
  open: expanded,
220
229
  label: 'string' == typeof item.label ? item.label : void 0,
221
- lineOffset: `calc(var(--leaf-spacing-md) + ${'rtl' === direction ? 10 : 6}px + ${32 * depth}px)`,
222
230
  children: ()=>renderItems(item.children ?? [], depth + 1)
223
231
  })
224
232
  ]