@choco-vanille/components 0.1.0-dev.1 → 0.1.0-dev.2

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 (53) hide show
  1. package/README.md +19 -5
  2. package/dist/components/{navigation/_common/link-base/utils/getLinkBaseSlotChild.utils.cjs → _common/utils/get-label-slot-child/getLabelSlotChild.utils.cjs} +2 -2
  3. package/dist/components/_common/utils/get-label-slot-child/getLabelSlotChild.utils.cjs.map +1 -0
  4. package/dist/components/{navigation/_common/link-base/utils/getLinkBaseSlotChild.utils.js → _common/utils/get-label-slot-child/getLabelSlotChild.utils.js} +3 -3
  5. package/dist/components/_common/utils/get-label-slot-child/getLabelSlotChild.utils.js.map +1 -0
  6. package/dist/components/actions/_common/button-base/utils/getButtonBaseProps.utils.cjs +1 -1
  7. package/dist/components/actions/_common/button-base/utils/getButtonBaseProps.utils.cjs.map +1 -1
  8. package/dist/components/actions/_common/button-base/utils/getButtonBaseProps.utils.js +17 -11
  9. package/dist/components/actions/_common/button-base/utils/getButtonBaseProps.utils.js.map +1 -1
  10. package/dist/components/actions/button/Button.cjs +1 -1
  11. package/dist/components/actions/button/Button.cjs.map +1 -1
  12. package/dist/components/actions/button/Button.js +32 -28
  13. package/dist/components/actions/button/Button.js.map +1 -1
  14. package/dist/components/actions/button/utils/getButtonParts.utils.cjs +2 -0
  15. package/dist/components/actions/button/utils/getButtonParts.utils.cjs.map +1 -0
  16. package/dist/components/actions/button/utils/getButtonParts.utils.js +31 -0
  17. package/dist/components/actions/button/utils/getButtonParts.utils.js.map +1 -0
  18. package/dist/components/actions/icon-button/IconButton.cjs.map +1 -1
  19. package/dist/components/actions/icon-button/IconButton.js.map +1 -1
  20. package/dist/components/navigation/_common/link-base/utils/getLinkBaseParts.utils.cjs +1 -1
  21. package/dist/components/navigation/_common/link-base/utils/getLinkBaseParts.utils.cjs.map +1 -1
  22. package/dist/components/navigation/_common/link-base/utils/getLinkBaseParts.utils.js +6 -6
  23. package/dist/components/navigation/_common/link-base/utils/getLinkBaseParts.utils.js.map +1 -1
  24. package/dist/components/navigation/drawer/components/drawer-item/DrawerItem.cjs +1 -1
  25. package/dist/components/navigation/drawer/components/drawer-item/DrawerItem.cjs.map +1 -1
  26. package/dist/components/navigation/drawer/components/drawer-item/DrawerItem.css.cjs +1 -1
  27. package/dist/components/navigation/drawer/components/drawer-item/DrawerItem.css.js +3 -3
  28. package/dist/components/navigation/drawer/components/drawer-item/DrawerItem.js +12 -12
  29. package/dist/components/navigation/drawer/components/drawer-item/DrawerItem.js.map +1 -1
  30. package/dist/components/navigation/drawer/components/drawer-item/utils/getDrawerItemParts.utils.cjs.map +1 -1
  31. package/dist/components/navigation/drawer/components/drawer-item/utils/getDrawerItemParts.utils.js.map +1 -1
  32. package/dist/components/navigation/drawer/constants/index.cjs.map +1 -1
  33. package/dist/components/navigation/drawer/constants/index.js.map +1 -1
  34. package/dist/components/navigation/link/Link.cjs +1 -1
  35. package/dist/components/navigation/link/Link.cjs.map +1 -1
  36. package/dist/components/navigation/link/Link.js +9 -9
  37. package/dist/components/navigation/link/Link.js.map +1 -1
  38. package/dist/components/navigation/tabs/components/tabs-tab/utils/getTabsTabParts.utils.cjs +1 -1
  39. package/dist/components/navigation/tabs/components/tabs-tab/utils/getTabsTabParts.utils.cjs.map +1 -1
  40. package/dist/components/navigation/tabs/components/tabs-tab/utils/getTabsTabParts.utils.js +4 -4
  41. package/dist/components/navigation/tabs/components/tabs-tab/utils/getTabsTabParts.utils.js.map +1 -1
  42. package/dist/components/overlays/dropdown-menu/components/dropdown-menu-content/DropdownMenuContent.cjs +1 -1
  43. package/dist/components/overlays/dropdown-menu/components/dropdown-menu-content/DropdownMenuContent.cjs.map +1 -1
  44. package/dist/components/overlays/dropdown-menu/components/dropdown-menu-content/DropdownMenuContent.js +10 -10
  45. package/dist/components/overlays/tooltip/Tooltip.cjs +1 -1
  46. package/dist/components/overlays/tooltip/Tooltip.cjs.map +1 -1
  47. package/dist/components/overlays/tooltip/Tooltip.js +9 -9
  48. package/dist/index.d.cts +69 -20
  49. package/dist/index.d.ts +69 -20
  50. package/dist/styles.css +1 -1
  51. package/package.json +5 -5
  52. package/dist/components/navigation/_common/link-base/utils/getLinkBaseSlotChild.utils.cjs.map +0 -1
  53. package/dist/components/navigation/_common/link-base/utils/getLinkBaseSlotChild.utils.js.map +0 -1
package/README.md CHANGED
@@ -129,6 +129,9 @@ import { Button } from '@choco-vanille/components';
129
129
  variant={'outlined'}
130
130
  width={'100%'}
131
131
  />;
132
+ <Button asChild={true} endIcon={iconRegistry.arrowRight} label={'Get started'}>
133
+ <RouterLink to={'/docs'} />
134
+ </Button>;
132
135
  ```
133
136
 
134
137
  - `label` is a required string; it has no `children`. It is rendered in a
@@ -177,11 +180,22 @@ import { Button } from '@choco-vanille/components';
177
180
  fill without moving the button. Its colors fade between states, or change
178
181
  at once when reduced motion is preferred. The label is trimmed to the
179
182
  height of its capitals (`text-box`) where supported, so it sits level with
180
- the icons. In forced colors, system colors draw its border and focus ring.
181
- - Every other prop (attributes, events, `ref`) goes to the `button`, except
182
- the legacy `color` attribute, which `Box` would read as a text color;
183
- `className` comes after the generated classes and `style` after the
184
- generated variables.
183
+ the icons. In forced colors, system colors draw its text, fill, border and
184
+ focus ring.
185
+ - `asChild` renders its single child instead, an element without content
186
+ such as the link of a router, which carries the destination, handles the
187
+ navigation and keeps its `link` role: the classes, `ref`, props and
188
+ handlers of the button are merged onto it, the child's handlers running
189
+ first and its own values prevailing for any other prop, and the `label`
190
+ and icons become its content. The child takes the look of the button in
191
+ every state, without the underline nor the color of a link, and receives
192
+ neither `type` nor `disabled`; `disabled`, `loading` and `type` are not
193
+ accepted then (a type error). A child that is not a single element, or
194
+ has content of its own, throws an explicit error.
195
+ - Every other prop (attributes, events, `ref`) goes to the `button`, or to
196
+ the child with `asChild`, except the legacy `color` attribute, which `Box`
197
+ would read as a text color; `className` comes after the generated classes
198
+ and `style` after the generated variables.
185
199
 
186
200
  ### IconButton
187
201
 
@@ -1,2 +1,2 @@
1
- let e=require("react");var t=(t,n)=>{if(!(0,e.isValidElement)(t)||t.type===e.Fragment)throw Error(`\`${n}\` with \`asChild\` expects a single React element rendering an \`a\` as child, such as a router link: not a text, a list, a fragment or nothing.`);if(t.props.children!==void 0&&t.props.children!==null)throw Error(`\`${n}\` with \`asChild\` renders its \`label\` inside its child: give the child no content, such as \`<RouterLink to="/settings" />\`, and the text to \`label\`.`);return t};exports.getLinkBaseSlotChild=t;
2
- //# sourceMappingURL=getLinkBaseSlotChild.utils.cjs.map
1
+ let e=require("react");var t=(t,n)=>{if(!(0,e.isValidElement)(t)||t.type===e.Fragment)throw Error(`\`${n}\` with \`asChild\` expects a single React element rendering an \`a\` as child, such as a router link: not a text, a list, a fragment or nothing.`);if(t.props.children!==void 0&&t.props.children!==null)throw Error(`\`${n}\` with \`asChild\` renders its \`label\` inside its child: give the child no content, such as \`<RouterLink to="/settings" />\`, and the text to \`label\`.`);return t};exports.getLabelSlotChild=t;
2
+ //# sourceMappingURL=getLabelSlotChild.utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getLabelSlotChild.utils.cjs","names":["isValidElement","Fragment","react","getLabelSlotChild","children","partName"],"sources":["../../../../../src/components/_common/utils/get-label-slot-child/getLabelSlotChild.utils.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { Fragment, isValidElement } from 'react';\n\nimport type {\n LabelSlotChild,\n LabelSlotPartName,\n} from '@components/components/_common/utils/get-label-slot-child/types';\n\n/**\n * Checks the children of a component rendered with `asChild` that renders\n * its label inside its child, such as a `Button`, a `Link` or a\n * `Drawer.Item`, before the label and icons are injected into them: a\n * single element, such as a router link, without content of its own, which\n * the label would replace. The `Slot` of `Box` only validates the element\n * it receives, once the content is injected, and names no component.\n *\n * @param children Children given to the component.\n * @param partName Name of the component, as the consumer writes it, given\n * in the errors.\n * @returns The single child element.\n * @throws {Error} When the children are not a single element, are a\n * fragment, or have content of their own.\n */\nexport const getLabelSlotChild = (\n children: ReactNode,\n partName: LabelSlotPartName,\n): LabelSlotChild => {\n if (\n !isValidElement<LabelSlotChild['props']>(children) ||\n children.type === Fragment\n ) {\n throw new Error(\n `\\`${partName}\\` with \\`asChild\\` expects a single React element rendering an \\`a\\` as child, such as a router link: not a text, a list, a fragment or nothing.`,\n );\n }\n\n if (\n children.props.children !== undefined &&\n children.props.children !== null\n ) {\n throw new Error(\n `\\`${partName}\\` with \\`asChild\\` renders its \\`label\\` inside its child: give the child no content, such as \\`<RouterLink to=\"/settings\" />\\`, and the text to \\`label\\`.`,\n );\n }\n\n return children;\n};\n"],"mappings":"A,uBAuBA,IAAaG,GACT,EACA,IACiB,CACjB,GACI,EAAA,EAACH,EAAAA,eAAAA,CAAwCI,CAAQ,GACjDA,EAAS,OAASH,EAAAA,SAElB,MAAU,MACN,KAAKI,EAAS,kJAClB,EAGJ,GACID,EAAS,MAAM,WAAa,IAAA,IAC5BA,EAAS,MAAM,WAAa,KAE5B,MAAU,MACN,KAAKC,EAAS,6JAClB,EAGJ,OAAOD,CACX,E"}
@@ -1,10 +1,10 @@
1
1
  import { Fragment as e, isValidElement as t } from "react";
2
- // src/components/navigation/_common/link-base/utils/getLinkBaseSlotChild.utils.ts
2
+ // src/components/_common/utils/get-label-slot-child/getLabelSlotChild.utils.ts
3
3
  var n = (n, r) => {
4
4
  if (!t(n) || n.type === e) throw Error(`\`${r}\` with \`asChild\` expects a single React element rendering an \`a\` as child, such as a router link: not a text, a list, a fragment or nothing.`);
5
5
  if (n.props.children !== void 0 && n.props.children !== null) throw Error(`\`${r}\` with \`asChild\` renders its \`label\` inside its child: give the child no content, such as \`<RouterLink to="/settings" />\`, and the text to \`label\`.`);
6
6
  return n;
7
7
  };
8
- export { n as getLinkBaseSlotChild };
8
+ export { n as getLabelSlotChild };
9
9
 
10
- //# sourceMappingURL=getLinkBaseSlotChild.utils.js.map
10
+ //# sourceMappingURL=getLabelSlotChild.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getLabelSlotChild.utils.js","names":["getLabelSlotChild","isValidElement","children","Fragment","partName"],"sources":["../../../../../src/components/_common/utils/get-label-slot-child/getLabelSlotChild.utils.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { Fragment, isValidElement } from 'react';\n\nimport type {\n LabelSlotChild,\n LabelSlotPartName,\n} from '@components/components/_common/utils/get-label-slot-child/types';\n\n/**\n * Checks the children of a component rendered with `asChild` that renders\n * its label inside its child, such as a `Button`, a `Link` or a\n * `Drawer.Item`, before the label and icons are injected into them: a\n * single element, such as a router link, without content of its own, which\n * the label would replace. The `Slot` of `Box` only validates the element\n * it receives, once the content is injected, and names no component.\n *\n * @param children Children given to the component.\n * @param partName Name of the component, as the consumer writes it, given\n * in the errors.\n * @returns The single child element.\n * @throws {Error} When the children are not a single element, are a\n * fragment, or have content of their own.\n */\nexport const getLabelSlotChild = (\n children: ReactNode,\n partName: LabelSlotPartName,\n): LabelSlotChild => {\n if (\n !isValidElement<LabelSlotChild['props']>(children) ||\n children.type === Fragment\n ) {\n throw new Error(\n `\\`${partName}\\` with \\`asChild\\` expects a single React element rendering an \\`a\\` as child, such as a router link: not a text, a list, a fragment or nothing.`,\n );\n }\n\n if (\n children.props.children !== undefined &&\n children.props.children !== null\n ) {\n throw new Error(\n `\\`${partName}\\` with \\`asChild\\` renders its \\`label\\` inside its child: give the child no content, such as \\`<RouterLink to=\"/settings\" />\\`, and the text to \\`label\\`.`,\n );\n }\n\n return children;\n};\n"],"mappings":";;AAuBA,IAAaA,KACT,GACA,MACiB;CACjB,IACI,CAACC,EAAwCC,CAAQ,KACjDA,EAAS,SAASC,GAElB,MAAU,MACN,KAAKC,EAAS,kJAClB;CAGJ,IACIF,EAAS,MAAM,aAAa,KAAA,KAC5BA,EAAS,MAAM,aAAa,MAE5B,MAAU,MACN,KAAKE,EAAS,6JAClB;CAGJ,OAAOF;AACX"}
@@ -1,2 +1,2 @@
1
- const e=require("../../../../_common/utils/cancelEvent.utils.cjs"),t=require("../../../../_common/utils/get-state-flag-attributes/getStateFlagAttributes.utils.cjs"),n=require("../../../../_common/utils/mergeClassNames.utils.cjs"),r=require("../buttonBase.css.cjs"),i=require("../constants/index.cjs");var a=({variant:a=i.buttonBaseDefaults.variant,tone:o=i.buttonBaseDefaults.tone,type:s=i.buttonBaseDefaults.type,className:c,disabled:l,loading:u,sizeClassName:d,...f})=>{let p={...f,...t.getStateFlagAttributes({disabled:l===!0}),disabled:l,type:s,className:n.mergeClassNames(r.buttonBaseStyles.root,d,r.buttonBaseStyles.tones[o],r.buttonBaseStyles.variants[a],c)};return u?{...p,"aria-busy":!0,"aria-disabled":!0,...t.getStateFlagAttributes({loading:u}),onClick:e.cancelEvent}:p};exports.getButtonBaseProps=a;
1
+ const e=require("../../../../_common/utils/cancelEvent.utils.cjs"),t=require("../../../../_common/utils/get-state-flag-attributes/getStateFlagAttributes.utils.cjs"),n=require("../../../../_common/utils/mergeClassNames.utils.cjs"),r=require("../buttonBase.css.cjs"),i=require("../constants/index.cjs");var a=({asChild:a=!1,variant:o=i.buttonBaseDefaults.variant,tone:s=i.buttonBaseDefaults.tone,type:c=i.buttonBaseDefaults.type,className:l,disabled:u,loading:d,selected:f,sizeClassName:p,...m})=>{let h={...m,...a?{}:{...f===void 0?{}:{"aria-pressed":f},...t.getStateFlagAttributes({disabled:u===!0,selected:f===!0}),disabled:u,type:c},className:n.mergeClassNames(r.buttonBaseStyles.root,p,r.buttonBaseStyles.tones[s],r.buttonBaseStyles.variants[o],l)};return d?{...h,"aria-busy":!0,"aria-disabled":!0,...t.getStateFlagAttributes({loading:d}),onClick:e.cancelEvent}:h};exports.getButtonBaseProps=a;
2
2
  //# sourceMappingURL=getButtonBaseProps.utils.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getButtonBaseProps.utils.cjs","names":["buttonBaseDefaults","getStateFlagAttributes","mergeClassNames","buttonBaseStyles","cancelEvent","require_cancelEvent_utils","require_getStateFlagAttributes_utils","require_mergeClassNames_utils","require_buttonBase_css","require_index","getButtonBaseProps","props","elementProps","disabled","sizeClassName","tone","variant","className","loading"],"sources":["../../../../../../src/components/actions/_common/button-base/utils/getButtonBaseProps.utils.ts"],"sourcesContent":["import { cancelEvent } from '@components/components/_common/utils/cancelEvent.utils';\nimport { getStateFlagAttributes } from '@components/components/_common/utils/get-state-flag-attributes/getStateFlagAttributes.utils';\nimport { mergeClassNames } from '@components/components/_common/utils/mergeClassNames.utils';\nimport { buttonBaseStyles } from '@components/components/actions/_common/button-base/buttonBase.css';\nimport { buttonBaseDefaults } from '@components/components/actions/_common/button-base/constants';\nimport type {\n ButtonBaseConfig,\n ButtonBaseElementProps,\n} from '@components/components/actions/_common/button-base/types';\n\n/**\n * Builds the props of the element rendering a `Button` or an `IconButton`:\n * the other props as given, `type` being `button` unless given, then the\n * default class, the class of the size, the classes of the tone and variant\n * and the consumer's `className`. A disabled button keeps the native\n * `disabled` and is flagged by `data-disabled`. While loading, it is flagged by\n * `data-loading`, exposed as busy and disabled (`aria-busy`,\n * `aria-disabled`) without the native `disabled`, so it stays focusable, and\n * its clicks are cancelled instead of reaching `onClick`, so it submits no\n * form either.\n *\n * @param props Props of the component but its content, with `loading`\n * resolved and the class of its size.\n * @param props.variant Fill, outline or content alone; `contained` when\n * absent.\n * @param props.tone Color intent of the theme; `primary` when absent.\n * @param props.type Type of the button; `button` when absent.\n * @param props.className Classes added after the generated ones.\n * @param props.disabled Whether the button is disabled.\n * @param props.loading Whether the button is loading, as resolved by the\n * component.\n * @param props.sizeClassName Class of the size of the component.\n * @returns The props to spread on the element.\n */\nexport const getButtonBaseProps = <Props extends ButtonBaseConfig>({\n variant = buttonBaseDefaults.variant,\n tone = buttonBaseDefaults.tone,\n type = buttonBaseDefaults.type,\n className,\n disabled,\n loading,\n sizeClassName,\n ...props\n}: Props): ButtonBaseElementProps<Props> => {\n const elementProps = {\n ...props,\n ...getStateFlagAttributes({ disabled: disabled === true }),\n disabled,\n type,\n className: mergeClassNames(\n buttonBaseStyles.root,\n sizeClassName,\n buttonBaseStyles.tones[tone],\n buttonBaseStyles.variants[variant],\n className,\n ),\n };\n\n return loading\n ? {\n ...elementProps,\n 'aria-busy': true,\n 'aria-disabled': true,\n ...getStateFlagAttributes({ loading }),\n onClick: cancelEvent,\n }\n : elementProps;\n};\n"],"mappings":"A,6SAkCA,IAAaU,GAAsD,CAC/D,UAAUV,EAAAA,mBAAmB,QAC7B,OAAOA,EAAAA,mBAAmB,KAC1B,OAAOA,EAAAA,mBAAmB,KAC1B,YACA,WACA,UACA,gBACA,GAAGW,KACqC,CACxC,IAAMC,EAAe,CACjB,GAAGD,EACH,GAAGV,EAAAA,uBAAuB,CAAE,SAAUY,IAAa,EAAK,CAAC,EACzD,WACA,OACA,UAAWX,EAAAA,gBACPC,EAAAA,iBAAiB,KACjBW,EACAX,EAAAA,iBAAiB,MAAMY,GACvBZ,EAAAA,iBAAiB,SAASa,GAC1BC,CACJ,CACJ,EAEA,OAAOC,EACD,CACI,GAAGN,EACH,YAAa,GACb,gBAAiB,GACjB,GAAGX,EAAAA,uBAAuB,CAAE,SAAQ,CAAC,EACrC,QAASG,EAAAA,WACb,EACAQ,CACV,E"}
1
+ {"version":3,"file":"getButtonBaseProps.utils.cjs","names":["buttonBaseDefaults","getStateFlagAttributes","mergeClassNames","buttonBaseStyles","cancelEvent","require_cancelEvent_utils","require_getStateFlagAttributes_utils","require_mergeClassNames_utils","require_buttonBase_css","require_index","getButtonBaseProps","props","elementProps","asChild","selected","disabled","sizeClassName","tone","variant","className","loading"],"sources":["../../../../../../src/components/actions/_common/button-base/utils/getButtonBaseProps.utils.ts"],"sourcesContent":["import { cancelEvent } from '@components/components/_common/utils/cancelEvent.utils';\nimport { getStateFlagAttributes } from '@components/components/_common/utils/get-state-flag-attributes/getStateFlagAttributes.utils';\nimport { mergeClassNames } from '@components/components/_common/utils/mergeClassNames.utils';\nimport { buttonBaseStyles } from '@components/components/actions/_common/button-base/buttonBase.css';\nimport { buttonBaseDefaults } from '@components/components/actions/_common/button-base/constants';\nimport type {\n ButtonBaseConfig,\n ButtonBaseElementProps,\n} from '@components/components/actions/_common/button-base/types';\n\n/**\n * Builds the props of the element rendering a `Button` or an `IconButton`:\n * the other props as given, `type` being `button` unless given, then the\n * default class, the class of the size, the classes of the tone and variant\n * and the consumer's `className`. A disabled button keeps the native\n * `disabled` and is flagged by `data-disabled`. A given `selected` makes it a\n * toggle button, its state exposed by `aria-pressed`, which it overrides,\n * and flagged by `data-selected` while on. While loading, it is flagged by\n * `data-loading`, exposed as busy and disabled (`aria-busy`,\n * `aria-disabled`) without the native `disabled`, so it stays focusable, and\n * its clicks are cancelled instead of reaching `onClick`, so it submits no\n * form either. A child rendered with `asChild`, such as a router link,\n * takes neither `type`, the native `disabled`, `data-disabled`,\n * `aria-pressed` nor `data-selected`, which only a `button` honors.\n *\n * @param props Props of the component but its content, with `loading`\n * resolved and the class of its size.\n * @param props.asChild Whether the component renders its single child;\n * `false` when absent.\n * @param props.variant Fill, outline or content alone; `contained` when\n * absent.\n * @param props.tone Color intent of the theme; `primary` when absent.\n * @param props.type Type of the button; `button` when absent.\n * @param props.className Classes added after the generated ones.\n * @param props.disabled Whether the button is disabled.\n * @param props.loading Whether the button is loading, as resolved by the\n * component.\n * @param props.selected Whether the toggle button is on; no toggle when\n * absent.\n * @param props.sizeClassName Class of the size of the component.\n * @returns The props to spread on the element.\n */\nexport const getButtonBaseProps = <Props extends ButtonBaseConfig>({\n asChild = false,\n variant = buttonBaseDefaults.variant,\n tone = buttonBaseDefaults.tone,\n type = buttonBaseDefaults.type,\n className,\n disabled,\n loading,\n selected,\n sizeClassName,\n ...props\n}: Props): ButtonBaseElementProps<Props> => {\n const elementProps = {\n ...props,\n ...(asChild\n ? {}\n : {\n ...(selected === undefined\n ? {}\n : { 'aria-pressed': selected }),\n ...getStateFlagAttributes({\n disabled: disabled === true,\n selected: selected === true,\n }),\n disabled,\n type,\n }),\n className: mergeClassNames(\n buttonBaseStyles.root,\n sizeClassName,\n buttonBaseStyles.tones[tone],\n buttonBaseStyles.variants[variant],\n className,\n ),\n };\n\n return loading\n ? {\n ...elementProps,\n 'aria-busy': true,\n 'aria-disabled': true,\n ...getStateFlagAttributes({ loading }),\n onClick: cancelEvent,\n }\n : elementProps;\n};\n"],"mappings":"A,6SA0CA,IAAaU,GAAsD,CAC/D,UAAU,GACV,UAAUV,EAAAA,mBAAmB,QAC7B,OAAOA,EAAAA,mBAAmB,KAC1B,OAAOA,EAAAA,mBAAmB,KAC1B,YACA,WACA,UACA,WACA,gBACA,GAAGW,KACqC,CACxC,IAAMC,EAAe,CACjB,GAAGD,EACH,GAAIE,EACE,CAAC,EACD,CACI,GAAIC,IAAa,IAAA,GACX,CAAC,EACD,CAAE,eAAgBA,CAAS,EACjC,GAAGb,EAAAA,uBAAuB,CACtB,SAAUc,IAAa,GACvB,SAAUD,IAAa,EAC3B,CAAC,EACD,WACA,MACJ,EACN,UAAWZ,EAAAA,gBACPC,EAAAA,iBAAiB,KACjBa,EACAb,EAAAA,iBAAiB,MAAMc,GACvBd,EAAAA,iBAAiB,SAASe,GAC1BC,CACJ,CACJ,EAEA,OAAOC,EACD,CACI,GAAGR,EACH,YAAa,GACb,gBAAiB,GACjB,GAAGX,EAAAA,uBAAuB,CAAE,SAAQ,CAAC,EACrC,QAASG,EAAAA,WACb,EACAQ,CACV,E"}
@@ -4,21 +4,27 @@ import { mergeClassNames as n } from "../../../../_common/utils/mergeClassNames.
4
4
  import { buttonBaseStyles as r } from "../buttonBase.css.js";
5
5
  import { buttonBaseDefaults as i } from "../constants/index.js";
6
6
  // src/components/actions/_common/button-base/utils/getButtonBaseProps.utils.ts
7
- var a = ({ variant: a = i.variant, tone: o = i.tone, type: s = i.type, className: c, disabled: l, loading: u, sizeClassName: d, ...f }) => {
8
- let p = {
9
- ...f,
10
- ...t({ disabled: l === !0 }),
11
- disabled: l,
12
- type: s,
13
- className: n(r.root, d, r.tones[o], r.variants[a], c)
7
+ var a = ({ asChild: a = !1, variant: o = i.variant, tone: s = i.tone, type: c = i.type, className: l, disabled: u, loading: d, selected: f, sizeClassName: p, ...m }) => {
8
+ let h = {
9
+ ...m,
10
+ ...a ? {} : {
11
+ ...f === void 0 ? {} : { "aria-pressed": f },
12
+ ...t({
13
+ disabled: u === !0,
14
+ selected: f === !0
15
+ }),
16
+ disabled: u,
17
+ type: c
18
+ },
19
+ className: n(r.root, p, r.tones[s], r.variants[o], l)
14
20
  };
15
- return u ? {
16
- ...p,
21
+ return d ? {
22
+ ...h,
17
23
  "aria-busy": !0,
18
24
  "aria-disabled": !0,
19
- ...t({ loading: u }),
25
+ ...t({ loading: d }),
20
26
  onClick: e
21
- } : p;
27
+ } : h;
22
28
  };
23
29
  export { a as getButtonBaseProps };
24
30
 
@@ -1 +1 @@
1
- {"version":3,"file":"getButtonBaseProps.utils.js","names":["getButtonBaseProps","buttonBaseDefaults","props","elementProps","getStateFlagAttributes","disabled","mergeClassNames","buttonBaseStyles","sizeClassName","tone","variant","className","loading","cancelEvent"],"sources":["../../../../../../src/components/actions/_common/button-base/utils/getButtonBaseProps.utils.ts"],"sourcesContent":["import { cancelEvent } from '@components/components/_common/utils/cancelEvent.utils';\nimport { getStateFlagAttributes } from '@components/components/_common/utils/get-state-flag-attributes/getStateFlagAttributes.utils';\nimport { mergeClassNames } from '@components/components/_common/utils/mergeClassNames.utils';\nimport { buttonBaseStyles } from '@components/components/actions/_common/button-base/buttonBase.css';\nimport { buttonBaseDefaults } from '@components/components/actions/_common/button-base/constants';\nimport type {\n ButtonBaseConfig,\n ButtonBaseElementProps,\n} from '@components/components/actions/_common/button-base/types';\n\n/**\n * Builds the props of the element rendering a `Button` or an `IconButton`:\n * the other props as given, `type` being `button` unless given, then the\n * default class, the class of the size, the classes of the tone and variant\n * and the consumer's `className`. A disabled button keeps the native\n * `disabled` and is flagged by `data-disabled`. While loading, it is flagged by\n * `data-loading`, exposed as busy and disabled (`aria-busy`,\n * `aria-disabled`) without the native `disabled`, so it stays focusable, and\n * its clicks are cancelled instead of reaching `onClick`, so it submits no\n * form either.\n *\n * @param props Props of the component but its content, with `loading`\n * resolved and the class of its size.\n * @param props.variant Fill, outline or content alone; `contained` when\n * absent.\n * @param props.tone Color intent of the theme; `primary` when absent.\n * @param props.type Type of the button; `button` when absent.\n * @param props.className Classes added after the generated ones.\n * @param props.disabled Whether the button is disabled.\n * @param props.loading Whether the button is loading, as resolved by the\n * component.\n * @param props.sizeClassName Class of the size of the component.\n * @returns The props to spread on the element.\n */\nexport const getButtonBaseProps = <Props extends ButtonBaseConfig>({\n variant = buttonBaseDefaults.variant,\n tone = buttonBaseDefaults.tone,\n type = buttonBaseDefaults.type,\n className,\n disabled,\n loading,\n sizeClassName,\n ...props\n}: Props): ButtonBaseElementProps<Props> => {\n const elementProps = {\n ...props,\n ...getStateFlagAttributes({ disabled: disabled === true }),\n disabled,\n type,\n className: mergeClassNames(\n buttonBaseStyles.root,\n sizeClassName,\n buttonBaseStyles.tones[tone],\n buttonBaseStyles.variants[variant],\n className,\n ),\n };\n\n return loading\n ? {\n ...elementProps,\n 'aria-busy': true,\n 'aria-disabled': true,\n ...getStateFlagAttributes({ loading }),\n onClick: cancelEvent,\n }\n : elementProps;\n};\n"],"mappings":";;;;;;AAkCA,IAAaA,KAAsD,EAC/D,aAAUC,EAAmB,SAC7B,UAAOA,EAAmB,MAC1B,UAAOA,EAAmB,MAC1B,cACA,aACA,YACA,kBACA,GAAGC,QACqC;CACxC,IAAMC,IAAe;EACjB,GAAGD;EACH,GAAGE,EAAuB,EAAE,UAAUC,MAAa,GAAK,CAAC;EACzD;EACA;EACA,WAAWC,EACPC,EAAiB,MACjBC,GACAD,EAAiB,MAAME,IACvBF,EAAiB,SAASG,IAC1BC,CACJ;CACJ;CAEA,OAAOC,IACD;EACI,GAAGT;EACH,aAAa;EACb,iBAAiB;EACjB,GAAGC,EAAuB,EAAE,WAAQ,CAAC;EACrC,SAASS;CACb,IACAV;AACV"}
1
+ {"version":3,"file":"getButtonBaseProps.utils.js","names":["getButtonBaseProps","buttonBaseDefaults","props","elementProps","asChild","selected","getStateFlagAttributes","disabled","mergeClassNames","buttonBaseStyles","sizeClassName","tone","variant","className","loading","cancelEvent"],"sources":["../../../../../../src/components/actions/_common/button-base/utils/getButtonBaseProps.utils.ts"],"sourcesContent":["import { cancelEvent } from '@components/components/_common/utils/cancelEvent.utils';\nimport { getStateFlagAttributes } from '@components/components/_common/utils/get-state-flag-attributes/getStateFlagAttributes.utils';\nimport { mergeClassNames } from '@components/components/_common/utils/mergeClassNames.utils';\nimport { buttonBaseStyles } from '@components/components/actions/_common/button-base/buttonBase.css';\nimport { buttonBaseDefaults } from '@components/components/actions/_common/button-base/constants';\nimport type {\n ButtonBaseConfig,\n ButtonBaseElementProps,\n} from '@components/components/actions/_common/button-base/types';\n\n/**\n * Builds the props of the element rendering a `Button` or an `IconButton`:\n * the other props as given, `type` being `button` unless given, then the\n * default class, the class of the size, the classes of the tone and variant\n * and the consumer's `className`. A disabled button keeps the native\n * `disabled` and is flagged by `data-disabled`. A given `selected` makes it a\n * toggle button, its state exposed by `aria-pressed`, which it overrides,\n * and flagged by `data-selected` while on. While loading, it is flagged by\n * `data-loading`, exposed as busy and disabled (`aria-busy`,\n * `aria-disabled`) without the native `disabled`, so it stays focusable, and\n * its clicks are cancelled instead of reaching `onClick`, so it submits no\n * form either. A child rendered with `asChild`, such as a router link,\n * takes neither `type`, the native `disabled`, `data-disabled`,\n * `aria-pressed` nor `data-selected`, which only a `button` honors.\n *\n * @param props Props of the component but its content, with `loading`\n * resolved and the class of its size.\n * @param props.asChild Whether the component renders its single child;\n * `false` when absent.\n * @param props.variant Fill, outline or content alone; `contained` when\n * absent.\n * @param props.tone Color intent of the theme; `primary` when absent.\n * @param props.type Type of the button; `button` when absent.\n * @param props.className Classes added after the generated ones.\n * @param props.disabled Whether the button is disabled.\n * @param props.loading Whether the button is loading, as resolved by the\n * component.\n * @param props.selected Whether the toggle button is on; no toggle when\n * absent.\n * @param props.sizeClassName Class of the size of the component.\n * @returns The props to spread on the element.\n */\nexport const getButtonBaseProps = <Props extends ButtonBaseConfig>({\n asChild = false,\n variant = buttonBaseDefaults.variant,\n tone = buttonBaseDefaults.tone,\n type = buttonBaseDefaults.type,\n className,\n disabled,\n loading,\n selected,\n sizeClassName,\n ...props\n}: Props): ButtonBaseElementProps<Props> => {\n const elementProps = {\n ...props,\n ...(asChild\n ? {}\n : {\n ...(selected === undefined\n ? {}\n : { 'aria-pressed': selected }),\n ...getStateFlagAttributes({\n disabled: disabled === true,\n selected: selected === true,\n }),\n disabled,\n type,\n }),\n className: mergeClassNames(\n buttonBaseStyles.root,\n sizeClassName,\n buttonBaseStyles.tones[tone],\n buttonBaseStyles.variants[variant],\n className,\n ),\n };\n\n return loading\n ? {\n ...elementProps,\n 'aria-busy': true,\n 'aria-disabled': true,\n ...getStateFlagAttributes({ loading }),\n onClick: cancelEvent,\n }\n : elementProps;\n};\n"],"mappings":";;;;;;AA0CA,IAAaA,KAAsD,EAC/D,aAAU,IACV,aAAUC,EAAmB,SAC7B,UAAOA,EAAmB,MAC1B,UAAOA,EAAmB,MAC1B,cACA,aACA,YACA,aACA,kBACA,GAAGC,QACqC;CACxC,IAAMC,IAAe;EACjB,GAAGD;EACH,GAAIE,IACE,CAAC,IACD;GACI,GAAIC,MAAa,KAAA,IACX,CAAC,IACD,EAAE,gBAAgBA,EAAS;GACjC,GAAGC,EAAuB;IACtB,UAAUC,MAAa;IACvB,UAAUF,MAAa;GAC3B,CAAC;GACD;GACA;EACJ;EACN,WAAWG,EACPC,EAAiB,MACjBC,GACAD,EAAiB,MAAME,IACvBF,EAAiB,SAASG,IAC1BC,CACJ;CACJ;CAEA,OAAOC,IACD;EACI,GAAGX;EACH,aAAa;EACb,iBAAiB;EACjB,GAAGG,EAAuB,EAAE,WAAQ,CAAC;EACrC,SAASS;CACb,IACAZ;AACV"}
@@ -1,2 +1,2 @@
1
- const e=require("../../_common/components/decorative-icon/DecorativeIcon.cjs"),t=require("../_common/button-base/buttonBase.css.cjs"),n=require("../_common/button-base/constants/index.cjs"),r=require("../_common/button-base/utils/getButtonBaseProps.utils.cjs"),i=require("./Button.css.cjs"),a=require("./constants/index.cjs"),o=require("./utils/getButtonLabelClassName.utils.cjs"),s=require("../../feedback/spinner/Spinner.cjs");let c=require("@choco-vanille/primitives"),l=require("react/jsx-runtime");var u=({endIcon:u,label:d,loading:f=n.buttonBaseDefaults.loading,maxLines:p,size:m=n.buttonBaseDefaults.size,startIcon:h,...g})=>(0,l.jsxs)(c.Box,{as:`button`,...r.getButtonBaseProps({...g,loading:f,sizeClassName:i.buttonStyles.sizes[m]}),children:[(0,l.jsxs)(`span`,{className:i.buttonStyles.content,children:[h?(0,l.jsx)(e.default,{className:i.buttonStyles.startIcon,icon:h}):null,(0,l.jsx)(c.Typography,{as:`span`,className:o.getButtonLabelClassName(p),maxLines:p,...a.buttonLabelTypographyProps[m],children:d}),u?(0,l.jsx)(e.default,{className:i.buttonStyles.endIcon,icon:u}):null]}),f?(0,l.jsx)(s.default,{className:t.buttonBaseStyles.spinnerPosition}):null]});exports.default=u;
1
+ const e=require("../../_common/components/decorative-icon/DecorativeIcon.cjs"),t=require("../_common/button-base/buttonBase.css.cjs"),n=require("../_common/button-base/constants/index.cjs"),r=require("./Button.css.cjs"),i=require("./constants/index.cjs"),a=require("./utils/getButtonLabelClassName.utils.cjs"),o=require("./utils/getButtonParts.utils.cjs"),s=require("../../feedback/spinner/Spinner.cjs");let c=require("@choco-vanille/primitives"),l=require("react"),u=require("react/jsx-runtime");var d=({endIcon:d,label:f,maxLines:p,size:m=n.buttonBaseDefaults.size,startIcon:h,...g})=>{let _=o.getButtonParts(g,r.buttonStyles.sizes[m]),v=(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`span`,{className:r.buttonStyles.content,children:[h?(0,u.jsx)(e.default,{className:r.buttonStyles.startIcon,icon:h}):null,(0,u.jsx)(c.Typography,{as:`span`,className:a.getButtonLabelClassName(p),maxLines:p,...i.buttonLabelTypographyProps[m],children:f}),d?(0,u.jsx)(e.default,{className:r.buttonStyles.endIcon,icon:d}):null]}),_.loading?(0,u.jsx)(s.default,{className:t.buttonBaseStyles.spinnerPosition}):null]});return _.child===void 0?(0,u.jsx)(c.Box,{as:`button`,..._.elementProps,children:v}):(0,u.jsx)(c.Box,{asChild:!0,..._.elementProps,children:(0,l.cloneElement)(_.child,void 0,v)})};exports.default=d;
2
2
  //# sourceMappingURL=Button.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Button.cjs","names":["buttonBaseDefaults","Box","getButtonBaseProps","buttonStyles","DecorativeIcon","Typography","getButtonLabelClassName","buttonLabelTypographyProps","Spinner","buttonBaseStyles","require_DecorativeIcon","require_buttonBase_css","require_index","require_getButtonBaseProps_utils","require_Button_css","require_index$1","require_getButtonLabelClassName_utils","require_Spinner","_choco_vanille_primitives","react_jsx_runtime","Button","props","size","startIcon","maxLines","label","endIcon","loading"],"sources":["../../../../src/components/actions/button/Button.tsx"],"sourcesContent":["import { Box, Typography } from '@choco-vanille/primitives';\nimport type { FC } from 'react';\n\nimport { DecorativeIcon } from '@components/components/_common/components';\nimport { buttonBaseStyles } from '@components/components/actions/_common/button-base/buttonBase.css';\nimport { buttonBaseDefaults } from '@components/components/actions/_common/button-base/constants';\nimport { getButtonBaseProps } from '@components/components/actions/_common/button-base/utils/getButtonBaseProps.utils';\nimport { buttonStyles } from '@components/components/actions/button/Button.css';\nimport { buttonLabelTypographyProps } from '@components/components/actions/button/constants';\nimport type { ButtonProps } from '@components/components/actions/button/types';\nimport { getButtonLabelClassName } from '@components/components/actions/button/utils/getButtonLabelClassName.utils';\nimport { Spinner } from '@components/components/feedback/spinner';\n\n/**\n * Renders a native `button` (a `Box`) showing its `label` in a `Typography`\n * `span`, between optional decorative icons. `variant`, `tone` and `size`\n * set its colors and dimensions; the width props of `Box` size it, its\n * content staying centered. The label inherits the color of the button,\n * wraps freely, or is truncated with an ellipsis after `maxLines` lines.\n *\n * `loading` hides the content behind a spinner, keeping the width and the\n * name of the button, flags it with `data-loading`, `aria-busy` and\n * `aria-disabled`, and cancels its clicks: `onClick` is not called and no\n * form is submitted, but other handlers run and the button stays focusable.\n *\n * The label names the button, or `aria-label` when the label is empty; the\n * icons, given as icon data and drawn by `Icon`s at the icon size of the\n * size, are hidden from assistive technologies. `type` is `button` unless\n * given. `disabled` disables it natively and flags it with `data-disabled`.\n * The focus ring shows on keyboard focus only.\n *\n * The margin and width props of `Box` space and size it. Every other prop (attributes, events, `ref`) goes to the `button`;\n * `className` comes after the generated classes and `style` after the\n * generated variables. Its styles sit in the `cv.components` cascade layers,\n * below any unlayered style of the consumer.\n *\n * @param props Label, presentation, icons, loading state, margin and width props and\n * native props of the `button`.\n * @param props.label Visible text of the button, which names it.\n * @param props.loading Whether the button is loading; `false` when absent.\n * @param props.maxLines Lines after which the label is truncated; it wraps\n * freely when absent.\n * @param props.size Height, padding and font sizes; `md` when absent.\n * @param props.startIcon Data of the decorative icon before the label; none\n * when absent.\n * @param props.endIcon Data of the decorative icon after the label; none\n * when absent.\n * @returns The button.\n */\nconst Button: FC<ButtonProps> = ({\n endIcon,\n label,\n loading = buttonBaseDefaults.loading,\n maxLines,\n size = buttonBaseDefaults.size,\n startIcon,\n ...props\n}) => (\n <Box\n as={'button'}\n {...getButtonBaseProps({\n ...props,\n loading,\n sizeClassName: buttonStyles.sizes[size],\n })}\n >\n <span className={buttonStyles.content}>\n {startIcon ? (\n <DecorativeIcon\n className={buttonStyles.startIcon}\n icon={startIcon}\n />\n ) : null}\n <Typography\n as={'span'}\n className={getButtonLabelClassName(maxLines)}\n maxLines={maxLines}\n {...buttonLabelTypographyProps[size]}\n >\n {label}\n </Typography>\n {endIcon ? (\n <DecorativeIcon\n className={buttonStyles.endIcon}\n icon={endIcon}\n />\n ) : null}\n </span>\n {loading ? (\n <Spinner className={buttonBaseStyles.spinnerPosition} />\n ) : null}\n </Box>\n);\n\nexport default Button;\n"],"mappings":"A,ufAiDA,IAAMoB,GAA2B,CAC7B,UACA,QACA,UAAUpB,EAAAA,mBAAmB,QAC7B,WACA,OAAOA,EAAAA,mBAAmB,KAC1B,YACA,GAAGqB,MAEH,EAAAF,EAAA,KAAA,CAAClB,EAAAA,IAAD,CACI,GAAI,SACJ,GAAIC,EAAAA,mBAAmB,CACnB,GAAGmB,EACH,UACA,cAAelB,EAAAA,aAAa,MAAMmB,EACtC,CAAC,EANL,SAAA,EAQI,EAAAH,EAAA,KAAA,CAAC,OAAD,CAAM,UAAWhB,EAAAA,aAAa,QAA9B,SAAA,CACKoB,GACG,EAAAJ,EAAA,IAAA,CAACf,EAAAA,QAAD,CACI,UAAWD,EAAAA,aAAa,UACxB,KAAMoB,CACT,CAAA,EACD,MACJ,EAAAJ,EAAA,IAAA,CAACd,EAAAA,WAAD,CACI,GAAI,OACJ,UAAWC,EAAAA,wBAAwBkB,CAAQ,EACjC,WACV,GAAIjB,EAAAA,2BAA2Be,GAE9B,SAAAG,CACO,CAAA,EACXC,GACG,EAAAP,EAAA,IAAA,CAACf,EAAAA,QAAD,CACI,UAAWD,EAAAA,aAAa,QACxB,KAAMuB,CACT,CAAA,EACD,IACF,CACL,CAAA,EAAAC,GACG,EAAAR,EAAA,IAAA,CAACX,EAAAA,QAAD,CAAS,UAAWC,EAAAA,iBAAiB,eAAkB,CAAA,EACvD,IACH,C"}
1
+ {"version":3,"file":"Button.cjs","names":["buttonBaseDefaults","getButtonParts","buttonStyles","_Fragment","DecorativeIcon","Typography","getButtonLabelClassName","buttonLabelTypographyProps","Spinner","buttonBaseStyles","Box","cloneElement","require_DecorativeIcon","require_buttonBase_css","require_index","require_Button_css","require_index$1","require_getButtonLabelClassName_utils","require_getButtonParts_utils","require_Spinner","_choco_vanille_primitives","react","react_jsx_runtime","Button","props","parts","size","content","startIcon","maxLines","label","endIcon"],"sources":["../../../../src/components/actions/button/Button.tsx"],"sourcesContent":["import { Box, Typography } from '@choco-vanille/primitives';\nimport type { FC } from 'react';\nimport { cloneElement } from 'react';\n\nimport { DecorativeIcon } from '@components/components/_common/components';\nimport { buttonBaseStyles } from '@components/components/actions/_common/button-base/buttonBase.css';\nimport { buttonBaseDefaults } from '@components/components/actions/_common/button-base/constants';\nimport { buttonStyles } from '@components/components/actions/button/Button.css';\nimport { buttonLabelTypographyProps } from '@components/components/actions/button/constants';\nimport type {\n ButtonAsChildProps,\n ButtonProps,\n} from '@components/components/actions/button/types';\nimport { getButtonLabelClassName } from '@components/components/actions/button/utils/getButtonLabelClassName.utils';\nimport { getButtonParts } from '@components/components/actions/button/utils/getButtonParts.utils';\nimport { Spinner } from '@components/components/feedback/spinner';\n\n/**\n * Renders a native `button` (a `Box`) showing its `label` in a `Typography`\n * `span`, between optional decorative icons. `variant`, `tone` and `size`\n * set its colors and dimensions; the width props of `Box` size it, its\n * content staying centered. The label inherits the color of the button,\n * wraps freely, or is truncated with an ellipsis after `maxLines` lines.\n *\n * `loading` hides the content behind a spinner, keeping the width and the\n * name of the button, flags it with `data-loading`, `aria-busy` and\n * `aria-disabled`, and cancels its clicks: `onClick` is not called and no\n * form is submitted, but other handlers run and the button stays focusable.\n * A given `selected` makes it a toggle button: `aria-pressed` exposes its\n * state, and while `true` it keeps its pressed colors, hovered or loading,\n * and is flagged with `data-selected`; disabled, it takes the disabled colors.\n *\n * The label names the button, or `aria-label` when the label is empty; the\n * icons, given as icon data and drawn by `Icon`s at the icon size of the\n * size, are hidden from assistive technologies. `type` is `button` unless\n * given. `disabled` disables it natively and flags it with `data-disabled`.\n * The focus ring shows on keyboard focus only.\n *\n * With `asChild`, it renders its single child instead, an element without\n * content such as a router link, which carries the destination and keeps\n * its own role: the classes, props, `ref` and handlers of the button are\n * merged onto it, the child's handlers running first and its own values\n * prevailing for any other prop, and the label and icons become its\n * content. It then takes neither `type`, `disabled`, `loading` nor\n * `selected`.\n *\n * The margin and width props of `Box` space and size it. Every other prop\n * (attributes, events, `ref`) goes to the `button` or the child; `className`\n * comes after the generated classes and `style` after the generated\n * variables. Its styles sit in the `cv.components` cascade layers, below any\n * unlayered style of the consumer.\n *\n * @param props Label, single child with `asChild`, presentation, icons,\n * loading and selected states, margin and width props and native props of\n * the `button`.\n * @param props.label Visible text of the button, which names it.\n * @param props.maxLines Lines after which the label is truncated; it wraps\n * freely when absent.\n * @param props.size Height, padding and font sizes; `md` when absent.\n * @param props.startIcon Data of the decorative icon before the label; none\n * when absent.\n * @param props.endIcon Data of the decorative icon after the label; none\n * when absent.\n * @returns The button, or its child with `asChild`.\n * @throws {Error} With `asChild`, when the children are not a single\n * element, or have content of their own.\n */\nconst Button: FC<ButtonAsChildProps | ButtonProps> = ({\n endIcon,\n label,\n maxLines,\n size = buttonBaseDefaults.size,\n startIcon,\n ...props\n}) => {\n const parts = getButtonParts(props, buttonStyles.sizes[size]);\n const content = (\n <>\n <span className={buttonStyles.content}>\n {startIcon ? (\n <DecorativeIcon\n className={buttonStyles.startIcon}\n icon={startIcon}\n />\n ) : null}\n <Typography\n as={'span'}\n className={getButtonLabelClassName(maxLines)}\n maxLines={maxLines}\n {...buttonLabelTypographyProps[size]}\n >\n {label}\n </Typography>\n {endIcon ? (\n <DecorativeIcon\n className={buttonStyles.endIcon}\n icon={endIcon}\n />\n ) : null}\n </span>\n {parts.loading ? (\n <Spinner className={buttonBaseStyles.spinnerPosition} />\n ) : null}\n </>\n );\n\n return parts.child === undefined ? (\n <Box as={'button'} {...parts.elementProps}>\n {content}\n </Box>\n ) : (\n <Box asChild={true} {...parts.elementProps}>\n {cloneElement(parts.child, undefined, content)}\n </Box>\n );\n};\n\nexport default Button;\n"],"mappings":"A,ifAmEA,IAAMuB,GAAgD,CAClD,UACA,QACA,WACA,OAAOvB,EAAAA,mBAAmB,KAC1B,YACA,GAAGwB,KACD,CACF,IAAMC,EAAQxB,EAAAA,eAAeuB,EAAOtB,EAAAA,aAAa,MAAMwB,EAAK,EACtDC,GACF,EAAAL,EAAA,KAAA,CAAAnB,EAAAA,SAAA,CAAA,SAAA,EACI,EAAAmB,EAAA,KAAA,CAAC,OAAD,CAAM,UAAWpB,EAAAA,aAAa,QAA9B,SAAA,CACK0B,GACG,EAAAN,EAAA,IAAA,CAAClB,EAAAA,QAAD,CACI,UAAWF,EAAAA,aAAa,UACxB,KAAM0B,CACT,CAAA,EACD,MACJ,EAAAN,EAAA,IAAA,CAACjB,EAAAA,WAAD,CACI,GAAI,OACJ,UAAWC,EAAAA,wBAAwBuB,CAAQ,EACjC,WACV,GAAItB,EAAAA,2BAA2BmB,GAE9B,SAAAI,CACO,CAAA,EACXC,GACG,EAAAT,EAAA,IAAA,CAAClB,EAAAA,QAAD,CACI,UAAWF,EAAAA,aAAa,QACxB,KAAM6B,CACT,CAAA,EACD,IACF,CACL,CAAA,EAAAN,EAAM,SACH,EAAAH,EAAA,IAAA,CAACd,EAAAA,QAAD,CAAS,UAAWC,EAAAA,iBAAiB,eAAkB,CAAA,EACvD,IACN,CAAA,CAAA,EAGN,OAAOgB,EAAM,QAAU,IAAA,IACnB,EAAAH,EAAA,IAAA,CAACZ,EAAAA,IAAD,CAAK,GAAI,SAAU,GAAIe,EAAM,aACxB,SAAAE,CACA,CAAA,GAEL,EAAAL,EAAA,IAAA,CAACZ,EAAAA,IAAD,CAAK,QAAS,GAAM,GAAIe,EAAM,aACzB,UAAA,EAAAd,EAAAA,aAAAA,CAAac,EAAM,MAAO,IAAA,GAAWE,CAAO,CAC5C,CAAA,CAEb,E"}
@@ -1,42 +1,46 @@
1
1
  import e from "../../_common/components/decorative-icon/DecorativeIcon.js";
2
2
  import { buttonBaseStyles as t } from "../_common/button-base/buttonBase.css.js";
3
3
  import { buttonBaseDefaults as n } from "../_common/button-base/constants/index.js";
4
- import { getButtonBaseProps as r } from "../_common/button-base/utils/getButtonBaseProps.utils.js";
5
- import { buttonStyles as i } from "./Button.css.js";
6
- import { buttonLabelTypographyProps as a } from "./constants/index.js";
7
- import { getButtonLabelClassName as o } from "./utils/getButtonLabelClassName.utils.js";
4
+ import { buttonStyles as r } from "./Button.css.js";
5
+ import { buttonLabelTypographyProps as i } from "./constants/index.js";
6
+ import { getButtonLabelClassName as a } from "./utils/getButtonLabelClassName.utils.js";
7
+ import { getButtonParts as o } from "./utils/getButtonParts.utils.js";
8
8
  import s from "../../feedback/spinner/Spinner.js";
9
9
  import { Box as c, Typography as l } from "@choco-vanille/primitives";
10
- import { jsx as u, jsxs as d } from "react/jsx-runtime";
10
+ import { cloneElement as u } from "react";
11
+ import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
11
12
  // src/components/actions/button/Button.tsx
12
- var f = ({ endIcon: f, label: p, loading: m = n.loading, maxLines: h, size: g = n.size, startIcon: _, ...v }) => /* @__PURE__ */ d(c, {
13
- as: "button",
14
- ...r({
15
- ...v,
16
- loading: m,
17
- sizeClassName: i.sizes[g]
18
- }),
19
- children: [/* @__PURE__ */ d("span", {
20
- className: i.content,
13
+ var m = ({ endIcon: m, label: h, maxLines: g, size: _ = n.size, startIcon: v, ...y }) => {
14
+ let b = o(y, r.sizes[_]), x = /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ p("span", {
15
+ className: r.content,
21
16
  children: [
22
- _ ? /* @__PURE__ */ u(e, {
23
- className: i.startIcon,
24
- icon: _
17
+ v ? /* @__PURE__ */ f(e, {
18
+ className: r.startIcon,
19
+ icon: v
25
20
  }) : null,
26
- /* @__PURE__ */ u(l, {
21
+ /* @__PURE__ */ f(l, {
27
22
  as: "span",
28
- className: o(h),
29
- maxLines: h,
30
- ...a[g],
31
- children: p
23
+ className: a(g),
24
+ maxLines: g,
25
+ ...i[_],
26
+ children: h
32
27
  }),
33
- f ? /* @__PURE__ */ u(e, {
34
- className: i.endIcon,
35
- icon: f
28
+ m ? /* @__PURE__ */ f(e, {
29
+ className: r.endIcon,
30
+ icon: m
36
31
  }) : null
37
32
  ]
38
- }), m ? /* @__PURE__ */ u(s, { className: t.spinnerPosition }) : null]
39
- });
40
- export { f as default };
33
+ }), b.loading ? /* @__PURE__ */ f(s, { className: t.spinnerPosition }) : null] });
34
+ return b.child === void 0 ? /* @__PURE__ */ f(c, {
35
+ as: "button",
36
+ ...b.elementProps,
37
+ children: x
38
+ }) : /* @__PURE__ */ f(c, {
39
+ asChild: !0,
40
+ ...b.elementProps,
41
+ children: u(b.child, void 0, x)
42
+ });
43
+ };
44
+ export { m as default };
41
45
 
42
46
  //# sourceMappingURL=Button.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Button.js","names":["DecorativeIcon","Spinner","Button","buttonBaseDefaults","props","Box","getButtonBaseProps","buttonStyles","size","startIcon","Typography","getButtonLabelClassName","maxLines","buttonLabelTypographyProps","label","endIcon","loading","buttonBaseStyles"],"sources":["../../../../src/components/actions/button/Button.tsx"],"sourcesContent":["import { Box, Typography } from '@choco-vanille/primitives';\nimport type { FC } from 'react';\n\nimport { DecorativeIcon } from '@components/components/_common/components';\nimport { buttonBaseStyles } from '@components/components/actions/_common/button-base/buttonBase.css';\nimport { buttonBaseDefaults } from '@components/components/actions/_common/button-base/constants';\nimport { getButtonBaseProps } from '@components/components/actions/_common/button-base/utils/getButtonBaseProps.utils';\nimport { buttonStyles } from '@components/components/actions/button/Button.css';\nimport { buttonLabelTypographyProps } from '@components/components/actions/button/constants';\nimport type { ButtonProps } from '@components/components/actions/button/types';\nimport { getButtonLabelClassName } from '@components/components/actions/button/utils/getButtonLabelClassName.utils';\nimport { Spinner } from '@components/components/feedback/spinner';\n\n/**\n * Renders a native `button` (a `Box`) showing its `label` in a `Typography`\n * `span`, between optional decorative icons. `variant`, `tone` and `size`\n * set its colors and dimensions; the width props of `Box` size it, its\n * content staying centered. The label inherits the color of the button,\n * wraps freely, or is truncated with an ellipsis after `maxLines` lines.\n *\n * `loading` hides the content behind a spinner, keeping the width and the\n * name of the button, flags it with `data-loading`, `aria-busy` and\n * `aria-disabled`, and cancels its clicks: `onClick` is not called and no\n * form is submitted, but other handlers run and the button stays focusable.\n *\n * The label names the button, or `aria-label` when the label is empty; the\n * icons, given as icon data and drawn by `Icon`s at the icon size of the\n * size, are hidden from assistive technologies. `type` is `button` unless\n * given. `disabled` disables it natively and flags it with `data-disabled`.\n * The focus ring shows on keyboard focus only.\n *\n * The margin and width props of `Box` space and size it. Every other prop (attributes, events, `ref`) goes to the `button`;\n * `className` comes after the generated classes and `style` after the\n * generated variables. Its styles sit in the `cv.components` cascade layers,\n * below any unlayered style of the consumer.\n *\n * @param props Label, presentation, icons, loading state, margin and width props and\n * native props of the `button`.\n * @param props.label Visible text of the button, which names it.\n * @param props.loading Whether the button is loading; `false` when absent.\n * @param props.maxLines Lines after which the label is truncated; it wraps\n * freely when absent.\n * @param props.size Height, padding and font sizes; `md` when absent.\n * @param props.startIcon Data of the decorative icon before the label; none\n * when absent.\n * @param props.endIcon Data of the decorative icon after the label; none\n * when absent.\n * @returns The button.\n */\nconst Button: FC<ButtonProps> = ({\n endIcon,\n label,\n loading = buttonBaseDefaults.loading,\n maxLines,\n size = buttonBaseDefaults.size,\n startIcon,\n ...props\n}) => (\n <Box\n as={'button'}\n {...getButtonBaseProps({\n ...props,\n loading,\n sizeClassName: buttonStyles.sizes[size],\n })}\n >\n <span className={buttonStyles.content}>\n {startIcon ? (\n <DecorativeIcon\n className={buttonStyles.startIcon}\n icon={startIcon}\n />\n ) : null}\n <Typography\n as={'span'}\n className={getButtonLabelClassName(maxLines)}\n maxLines={maxLines}\n {...buttonLabelTypographyProps[size]}\n >\n {label}\n </Typography>\n {endIcon ? (\n <DecorativeIcon\n className={buttonStyles.endIcon}\n icon={endIcon}\n />\n ) : null}\n </span>\n {loading ? (\n <Spinner className={buttonBaseStyles.spinnerPosition} />\n ) : null}\n </Box>\n);\n\nexport default Button;\n"],"mappings":";;;;;;;;;;;AAiDA,IAAME,KAA2B,EAC7B,YACA,UACA,aAAUC,EAAmB,SAC7B,aACA,UAAOA,EAAmB,MAC1B,cACA,GAAGC,QAEH,kBAACC,GAAD;CACI,IAAI;CACJ,GAAIC,EAAmB;EACnB,GAAGF;EACH;EACA,eAAeG,EAAa,MAAMC;CACtC,CAAC;CANL,UAAA,CAQI,kBAAC,QAAD;EAAM,WAAWD,EAAa;EAA9B,UAAA;GACKE,IACG,kBAACT,GAAD;IACI,WAAWO,EAAa;IACxB,MAAME;GACT,CAAA,IACD;GACJ,kBAACC,GAAD;IACI,IAAI;IACJ,WAAWC,EAAwBC,CAAQ;IACjC;IACV,GAAIC,EAA2BL;IAE9B,UAAAM;GACO,CAAA;GACXC,IACG,kBAACf,GAAD;IACI,WAAWO,EAAa;IACxB,MAAMQ;GACT,CAAA,IACD;EACF;CACL,CAAA,GAAAC,IACG,kBAACf,GAAD,EAAS,WAAWgB,EAAiB,gBAAkB,CAAA,IACvD,IACH"}
1
+ {"version":3,"file":"Button.js","names":["_Fragment","DecorativeIcon","Spinner","Fragment$1","Button","buttonBaseDefaults","props","parts","getButtonParts","buttonStyles","size","content","startIcon","Typography","getButtonLabelClassName","maxLines","buttonLabelTypographyProps","label","endIcon","buttonBaseStyles","Box","cloneElement"],"sources":["../../../../src/components/actions/button/Button.tsx"],"sourcesContent":["import { Box, Typography } from '@choco-vanille/primitives';\nimport type { FC } from 'react';\nimport { cloneElement } from 'react';\n\nimport { DecorativeIcon } from '@components/components/_common/components';\nimport { buttonBaseStyles } from '@components/components/actions/_common/button-base/buttonBase.css';\nimport { buttonBaseDefaults } from '@components/components/actions/_common/button-base/constants';\nimport { buttonStyles } from '@components/components/actions/button/Button.css';\nimport { buttonLabelTypographyProps } from '@components/components/actions/button/constants';\nimport type {\n ButtonAsChildProps,\n ButtonProps,\n} from '@components/components/actions/button/types';\nimport { getButtonLabelClassName } from '@components/components/actions/button/utils/getButtonLabelClassName.utils';\nimport { getButtonParts } from '@components/components/actions/button/utils/getButtonParts.utils';\nimport { Spinner } from '@components/components/feedback/spinner';\n\n/**\n * Renders a native `button` (a `Box`) showing its `label` in a `Typography`\n * `span`, between optional decorative icons. `variant`, `tone` and `size`\n * set its colors and dimensions; the width props of `Box` size it, its\n * content staying centered. The label inherits the color of the button,\n * wraps freely, or is truncated with an ellipsis after `maxLines` lines.\n *\n * `loading` hides the content behind a spinner, keeping the width and the\n * name of the button, flags it with `data-loading`, `aria-busy` and\n * `aria-disabled`, and cancels its clicks: `onClick` is not called and no\n * form is submitted, but other handlers run and the button stays focusable.\n * A given `selected` makes it a toggle button: `aria-pressed` exposes its\n * state, and while `true` it keeps its pressed colors, hovered or loading,\n * and is flagged with `data-selected`; disabled, it takes the disabled colors.\n *\n * The label names the button, or `aria-label` when the label is empty; the\n * icons, given as icon data and drawn by `Icon`s at the icon size of the\n * size, are hidden from assistive technologies. `type` is `button` unless\n * given. `disabled` disables it natively and flags it with `data-disabled`.\n * The focus ring shows on keyboard focus only.\n *\n * With `asChild`, it renders its single child instead, an element without\n * content such as a router link, which carries the destination and keeps\n * its own role: the classes, props, `ref` and handlers of the button are\n * merged onto it, the child's handlers running first and its own values\n * prevailing for any other prop, and the label and icons become its\n * content. It then takes neither `type`, `disabled`, `loading` nor\n * `selected`.\n *\n * The margin and width props of `Box` space and size it. Every other prop\n * (attributes, events, `ref`) goes to the `button` or the child; `className`\n * comes after the generated classes and `style` after the generated\n * variables. Its styles sit in the `cv.components` cascade layers, below any\n * unlayered style of the consumer.\n *\n * @param props Label, single child with `asChild`, presentation, icons,\n * loading and selected states, margin and width props and native props of\n * the `button`.\n * @param props.label Visible text of the button, which names it.\n * @param props.maxLines Lines after which the label is truncated; it wraps\n * freely when absent.\n * @param props.size Height, padding and font sizes; `md` when absent.\n * @param props.startIcon Data of the decorative icon before the label; none\n * when absent.\n * @param props.endIcon Data of the decorative icon after the label; none\n * when absent.\n * @returns The button, or its child with `asChild`.\n * @throws {Error} With `asChild`, when the children are not a single\n * element, or have content of their own.\n */\nconst Button: FC<ButtonAsChildProps | ButtonProps> = ({\n endIcon,\n label,\n maxLines,\n size = buttonBaseDefaults.size,\n startIcon,\n ...props\n}) => {\n const parts = getButtonParts(props, buttonStyles.sizes[size]);\n const content = (\n <>\n <span className={buttonStyles.content}>\n {startIcon ? (\n <DecorativeIcon\n className={buttonStyles.startIcon}\n icon={startIcon}\n />\n ) : null}\n <Typography\n as={'span'}\n className={getButtonLabelClassName(maxLines)}\n maxLines={maxLines}\n {...buttonLabelTypographyProps[size]}\n >\n {label}\n </Typography>\n {endIcon ? (\n <DecorativeIcon\n className={buttonStyles.endIcon}\n icon={endIcon}\n />\n ) : null}\n </span>\n {parts.loading ? (\n <Spinner className={buttonBaseStyles.spinnerPosition} />\n ) : null}\n </>\n );\n\n return parts.child === undefined ? (\n <Box as={'button'} {...parts.elementProps}>\n {content}\n </Box>\n ) : (\n <Box asChild={true} {...parts.elementProps}>\n {cloneElement(parts.child, undefined, content)}\n </Box>\n );\n};\n\nexport default Button;\n"],"mappings":";;;;;;;;;;;;AAmEA,IAAMI,KAAgD,EAClD,YACA,UACA,aACA,UAAOC,EAAmB,MAC1B,cACA,GAAGC,QACD;CACF,IAAMC,IAAQC,EAAeF,GAAOG,EAAa,MAAMC,EAAK,GACtDC,IACF,kBAAAX,GAAA,EAAA,UAAA,CACI,kBAAC,QAAD;EAAM,WAAWS,EAAa;EAA9B,UAAA;GACKG,IACG,kBAACX,GAAD;IACI,WAAWQ,EAAa;IACxB,MAAMG;GACT,CAAA,IACD;GACJ,kBAACC,GAAD;IACI,IAAI;IACJ,WAAWC,EAAwBC,CAAQ;IACjC;IACV,GAAIC,EAA2BN;IAE9B,UAAAO;GACO,CAAA;GACXC,IACG,kBAACjB,GAAD;IACI,WAAWQ,EAAa;IACxB,MAAMS;GACT,CAAA,IACD;EACF;CACL,CAAA,GAAAX,EAAM,UACH,kBAACL,GAAD,EAAS,WAAWiB,EAAiB,gBAAkB,CAAA,IACvD,IACN,EAAA,CAAA;CAGN,OAAOZ,EAAM,UAAU,KAAA,IACnB,kBAACa,GAAD;EAAK,IAAI;EAAU,GAAIb,EAAM;EACxB,UAAAI;CACA,CAAA,IAEL,kBAACS,GAAD;EAAK,SAAS;EAAM,GAAIb,EAAM;EACzB,UAAAc,EAAad,EAAM,OAAO,KAAA,GAAWI,CAAO;CAC5C,CAAA;AAEb"}
@@ -0,0 +1,2 @@
1
+ const e=require("../../../_common/utils/get-label-slot-child/getLabelSlotChild.utils.cjs"),t=require("../../_common/button-base/constants/index.cjs"),n=require("../../_common/button-base/utils/getButtonBaseProps.utils.cjs");var r=(r,i)=>{if(r.asChild===!0){let{children:t,...a}=r;return{child:e.getLabelSlotChild(t,`Button`),elementProps:n.getButtonBaseProps({...a,loading:!1,sizeClassName:i}),loading:!1}}let{loading:a=t.buttonBaseDefaults.loading,...o}=r;return{child:void 0,elementProps:n.getButtonBaseProps({...o,loading:a,sizeClassName:i}),loading:a}};exports.getButtonParts=r;
2
+ //# sourceMappingURL=getButtonParts.utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getButtonParts.utils.cjs","names":["getLabelSlotChild","getButtonBaseProps","buttonBaseDefaults","require_getLabelSlotChild_utils","require_index","require_getButtonBaseProps_utils","getButtonParts","props","elementProps","children"],"sources":["../../../../../src/components/actions/button/utils/getButtonParts.utils.ts"],"sourcesContent":["import { getLabelSlotChild } from '@components/components/_common/utils/get-label-slot-child/getLabelSlotChild.utils';\nimport { buttonBaseDefaults } from '@components/components/actions/_common/button-base/constants';\nimport { getButtonBaseProps } from '@components/components/actions/_common/button-base/utils/getButtonBaseProps.utils';\nimport type {\n ButtonParts,\n ButtonPartsInput,\n} from '@components/components/actions/button/types';\n\n/**\n * Resolves what a `Button` renders from its props but its content, as every\n * button does (see `getButtonBaseProps`), with the class of its size: the\n * props of its own `button` and its loading state, `false` when absent;\n * with `asChild`, its validated single child, without content, which\n * receives the label and icons, and the props merged onto it, without\n * `type` nor disabled state, never loading.\n *\n * @param props Props of the button but its label, icons and size.\n * @param sizeClassName Class of the size of the button.\n * @returns The child, element props and loading state of the button.\n * @throws {Error} With `asChild`, when the children are not a single\n * element, are a fragment, or have content of their own.\n */\nexport const getButtonParts = (\n props: ButtonPartsInput,\n sizeClassName: string,\n): ButtonParts => {\n if (props.asChild === true) {\n const { children, ...elementProps } = props;\n\n return {\n child: getLabelSlotChild(children, 'Button'),\n elementProps: getButtonBaseProps({\n ...elementProps,\n loading: false,\n sizeClassName,\n }),\n loading: false,\n };\n }\n\n const { loading = buttonBaseDefaults.loading, ...elementProps } = props;\n\n return {\n child: undefined,\n elementProps: getButtonBaseProps({\n ...elementProps,\n loading,\n sizeClassName,\n }),\n loading,\n };\n};\n"],"mappings":"A,gOAsBA,IAAaM,GACT,EACA,IACc,CACd,GAAIC,EAAM,UAAY,GAAM,CACxB,GAAM,CAAE,WAAU,GAAGC,GAAiBD,EAEtC,MAAO,CACH,MAAOP,EAAAA,kBAAkBS,EAAU,QAAQ,EAC3C,aAAcR,EAAAA,mBAAmB,CAC7B,GAAGO,EACH,QAAS,GACT,eACJ,CAAC,EACD,QAAS,EACb,CACJ,CAEA,GAAM,CAAE,UAAUN,EAAAA,mBAAmB,QAAS,GAAGM,GAAiBD,EAElE,MAAO,CACH,MAAO,IAAA,GACP,aAAcN,EAAAA,mBAAmB,CAC7B,GAAGO,EACH,UACA,eACJ,CAAC,EACD,SACJ,CACJ,E"}
@@ -0,0 +1,31 @@
1
+ import { getLabelSlotChild as e } from "../../../_common/utils/get-label-slot-child/getLabelSlotChild.utils.js";
2
+ import { buttonBaseDefaults as t } from "../../_common/button-base/constants/index.js";
3
+ import { getButtonBaseProps as n } from "../../_common/button-base/utils/getButtonBaseProps.utils.js";
4
+ // src/components/actions/button/utils/getButtonParts.utils.ts
5
+ var r = (r, i) => {
6
+ if (r.asChild === !0) {
7
+ let { children: t, ...a } = r;
8
+ return {
9
+ child: e(t, "Button"),
10
+ elementProps: n({
11
+ ...a,
12
+ loading: !1,
13
+ sizeClassName: i
14
+ }),
15
+ loading: !1
16
+ };
17
+ }
18
+ let { loading: a = t.loading, ...o } = r;
19
+ return {
20
+ child: void 0,
21
+ elementProps: n({
22
+ ...o,
23
+ loading: a,
24
+ sizeClassName: i
25
+ }),
26
+ loading: a
27
+ };
28
+ };
29
+ export { r as getButtonParts };
30
+
31
+ //# sourceMappingURL=getButtonParts.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getButtonParts.utils.js","names":["getButtonParts","props","elementProps","getLabelSlotChild","children","getButtonBaseProps","buttonBaseDefaults"],"sources":["../../../../../src/components/actions/button/utils/getButtonParts.utils.ts"],"sourcesContent":["import { getLabelSlotChild } from '@components/components/_common/utils/get-label-slot-child/getLabelSlotChild.utils';\nimport { buttonBaseDefaults } from '@components/components/actions/_common/button-base/constants';\nimport { getButtonBaseProps } from '@components/components/actions/_common/button-base/utils/getButtonBaseProps.utils';\nimport type {\n ButtonParts,\n ButtonPartsInput,\n} from '@components/components/actions/button/types';\n\n/**\n * Resolves what a `Button` renders from its props but its content, as every\n * button does (see `getButtonBaseProps`), with the class of its size: the\n * props of its own `button` and its loading state, `false` when absent;\n * with `asChild`, its validated single child, without content, which\n * receives the label and icons, and the props merged onto it, without\n * `type` nor disabled state, never loading.\n *\n * @param props Props of the button but its label, icons and size.\n * @param sizeClassName Class of the size of the button.\n * @returns The child, element props and loading state of the button.\n * @throws {Error} With `asChild`, when the children are not a single\n * element, are a fragment, or have content of their own.\n */\nexport const getButtonParts = (\n props: ButtonPartsInput,\n sizeClassName: string,\n): ButtonParts => {\n if (props.asChild === true) {\n const { children, ...elementProps } = props;\n\n return {\n child: getLabelSlotChild(children, 'Button'),\n elementProps: getButtonBaseProps({\n ...elementProps,\n loading: false,\n sizeClassName,\n }),\n loading: false,\n };\n }\n\n const { loading = buttonBaseDefaults.loading, ...elementProps } = props;\n\n return {\n child: undefined,\n elementProps: getButtonBaseProps({\n ...elementProps,\n loading,\n sizeClassName,\n }),\n loading,\n };\n};\n"],"mappings":";;;;AAsBA,IAAaA,KACT,GACA,MACc;CACd,IAAIC,EAAM,YAAY,IAAM;EACxB,IAAM,EAAE,aAAU,GAAGC,MAAiBD;EAEtC,OAAO;GACH,OAAOE,EAAkBC,GAAU,QAAQ;GAC3C,cAAcC,EAAmB;IAC7B,GAAGH;IACH,SAAS;IACT;GACJ,CAAC;GACD,SAAS;EACb;CACJ;CAEA,IAAM,EAAE,aAAUI,EAAmB,SAAS,GAAGJ,MAAiBD;CAElE,OAAO;EACH,OAAO,KAAA;EACP,cAAcI,EAAmB;GAC7B,GAAGH;GACH;GACA;EACJ,CAAC;EACD;CACJ;AACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"IconButton.cjs","names":["buttonBaseDefaults","Box","getButtonBaseProps","iconButtonStyles","DecorativeIcon","Spinner","buttonBaseStyles","require_DecorativeIcon","require_buttonBase_css","require_index","require_getButtonBaseProps_utils","require_IconButton_css","require_Spinner","_choco_vanille_primitives","react_jsx_runtime","IconButton","props","size","loading"],"sources":["../../../../src/components/actions/icon-button/IconButton.tsx"],"sourcesContent":["import { Box } from '@choco-vanille/primitives';\nimport type { FC } from 'react';\n\nimport { DecorativeIcon } from '@components/components/_common/components';\nimport { buttonBaseStyles } from '@components/components/actions/_common/button-base/buttonBase.css';\nimport { buttonBaseDefaults } from '@components/components/actions/_common/button-base/constants';\nimport { getButtonBaseProps } from '@components/components/actions/_common/button-base/utils/getButtonBaseProps.utils';\nimport { iconButtonStyles } from '@components/components/actions/icon-button/IconButton.css';\nimport type { IconButtonProps } from '@components/components/actions/icon-button/types';\nimport { Spinner } from '@components/components/feedback/spinner';\n\n/**\n * Renders a square native `button` (a `Box`) drawing its decorative `icon`\n * data with an `Icon`, centered and hidden from assistive technologies.\n * `variant`, `tone` and `size` set its colors and dimensions as for a\n * `Button`: its side is the height of a `Button` of the same size, and its\n * icon is about half its side (14, 16, 20 or 24px from `xs` to `lg`), larger\n * than the icons of a `Button`.\n *\n * `loading` hides the icon behind a spinner at the icon size of a `Button`\n * of the same size, flags the button with `data-loading`, `aria-busy` and\n * `aria-disabled`, and cancels its clicks: `onClick` is not called and no\n * form is submitted, but other handlers run and the button stays focusable.\n *\n * The required `aria-label` names the button. `type` is `button` unless\n * given. `disabled` disables it natively and flags it with `data-disabled`. The focus ring shows on keyboard\n * focus only.\n *\n * The margin props of `Box` space it from its siblings. Every other prop\n * (attributes, events, `ref`) goes to the `button`; `className` comes after\n * the generated classes. Its styles sit in the `cv.components` cascade\n * layers, below any unlayered style of the consumer.\n *\n * @param props Icon, accessible name, presentation, loading state, margin\n * props and native props of the `button`.\n * @param props.icon Data of the decorative icon shown in the button.\n * @param props.loading Whether the button is loading; `false` when absent.\n * @param props.size Side and icon size; `md` when absent.\n * @returns The button.\n */\nconst IconButton: FC<IconButtonProps> = ({\n icon,\n loading = buttonBaseDefaults.loading,\n size = buttonBaseDefaults.size,\n ...props\n}) => (\n <Box\n as={'button'}\n {...getButtonBaseProps({\n ...props,\n loading,\n sizeClassName: iconButtonStyles.sizes[size],\n })}\n >\n <DecorativeIcon className={iconButtonStyles.icon} icon={icon} />\n {loading ? (\n <Spinner className={buttonBaseStyles.spinnerPosition} />\n ) : null}\n </Box>\n);\n\nexport default IconButton;\n"],"mappings":"A,iaAwCA,IAAMe,GAAmC,CACrC,OACA,UAAUf,EAAAA,mBAAmB,QAC7B,OAAOA,EAAAA,mBAAmB,KAC1B,GAAGgB,MAEH,EAAAF,EAAA,KAAA,CAACb,EAAAA,IAAD,CACI,GAAI,SACJ,GAAIC,EAAAA,mBAAmB,CACnB,GAAGc,EACH,UACA,cAAeb,EAAAA,iBAAiB,MAAMc,EAC1C,CAAC,EANL,SAAA,EAQI,EAAAH,EAAA,IAAA,CAACV,EAAAA,QAAD,CAAgB,UAAWD,EAAAA,iBAAiB,KAAY,MAAO,CAAA,EAC9De,GACG,EAAAJ,EAAA,IAAA,CAACT,EAAAA,QAAD,CAAS,UAAWC,EAAAA,iBAAiB,eAAkB,CAAA,EACvD,IACH,C"}
1
+ {"version":3,"file":"IconButton.cjs","names":["buttonBaseDefaults","Box","getButtonBaseProps","iconButtonStyles","DecorativeIcon","Spinner","buttonBaseStyles","require_DecorativeIcon","require_buttonBase_css","require_index","require_getButtonBaseProps_utils","require_IconButton_css","require_Spinner","_choco_vanille_primitives","react_jsx_runtime","IconButton","props","size","loading"],"sources":["../../../../src/components/actions/icon-button/IconButton.tsx"],"sourcesContent":["import { Box } from '@choco-vanille/primitives';\nimport type { FC } from 'react';\n\nimport { DecorativeIcon } from '@components/components/_common/components';\nimport { buttonBaseStyles } from '@components/components/actions/_common/button-base/buttonBase.css';\nimport { buttonBaseDefaults } from '@components/components/actions/_common/button-base/constants';\nimport { getButtonBaseProps } from '@components/components/actions/_common/button-base/utils/getButtonBaseProps.utils';\nimport { iconButtonStyles } from '@components/components/actions/icon-button/IconButton.css';\nimport type { IconButtonProps } from '@components/components/actions/icon-button/types';\nimport { Spinner } from '@components/components/feedback/spinner';\n\n/**\n * Renders a square native `button` (a `Box`) drawing its decorative `icon`\n * data with an `Icon`, centered and hidden from assistive technologies.\n * `variant`, `tone` and `size` set its colors and dimensions as for a\n * `Button`: its side is the height of a `Button` of the same size, and its\n * icon is about half its side (14, 16, 20 or 24px from `xs` to `lg`), larger\n * than the icons of a `Button`.\n *\n * `loading` hides the icon behind a spinner at the icon size of a `Button`\n * of the same size, flags the button with `data-loading`, `aria-busy` and\n * `aria-disabled`, and cancels its clicks: `onClick` is not called and no\n * form is submitted, but other handlers run and the button stays focusable.\n * A given `selected` makes it a toggle button: `aria-pressed` exposes its\n * state, and while `true` it keeps its pressed colors, hovered or loading,\n * and is flagged with `data-selected`; disabled, it takes the disabled colors.\n *\n * The required `aria-label` names the button. `type` is `button` unless\n * given. `disabled` disables it natively and flags it with `data-disabled`. The focus ring shows on keyboard\n * focus only.\n *\n * The margin props of `Box` space it from its siblings. Every other prop\n * (attributes, events, `ref`) goes to the `button`; `className` comes after\n * the generated classes. Its styles sit in the `cv.components` cascade\n * layers, below any unlayered style of the consumer.\n *\n * @param props Icon, accessible name, presentation, loading and selected\n * states, margin props and native props of the `button`.\n * @param props.icon Data of the decorative icon shown in the button.\n * @param props.loading Whether the button is loading; `false` when absent.\n * @param props.size Side and icon size; `md` when absent.\n * @returns The button.\n */\nconst IconButton: FC<IconButtonProps> = ({\n icon,\n loading = buttonBaseDefaults.loading,\n size = buttonBaseDefaults.size,\n ...props\n}) => (\n <Box\n as={'button'}\n {...getButtonBaseProps({\n ...props,\n loading,\n sizeClassName: iconButtonStyles.sizes[size],\n })}\n >\n <DecorativeIcon className={iconButtonStyles.icon} icon={icon} />\n {loading ? (\n <Spinner className={buttonBaseStyles.spinnerPosition} />\n ) : null}\n </Box>\n);\n\nexport default IconButton;\n"],"mappings":"A,iaA2CA,IAAMe,GAAmC,CACrC,OACA,UAAUf,EAAAA,mBAAmB,QAC7B,OAAOA,EAAAA,mBAAmB,KAC1B,GAAGgB,MAEH,EAAAF,EAAA,KAAA,CAACb,EAAAA,IAAD,CACI,GAAI,SACJ,GAAIC,EAAAA,mBAAmB,CACnB,GAAGc,EACH,UACA,cAAeb,EAAAA,iBAAiB,MAAMc,EAC1C,CAAC,EANL,SAAA,EAQI,EAAAH,EAAA,IAAA,CAACV,EAAAA,QAAD,CAAgB,UAAWD,EAAAA,iBAAiB,KAAY,MAAO,CAAA,EAC9De,GACG,EAAAJ,EAAA,IAAA,CAACT,EAAAA,QAAD,CAAS,UAAWC,EAAAA,iBAAiB,eAAkB,CAAA,EACvD,IACH,C"}
@@ -1 +1 @@
1
- {"version":3,"file":"IconButton.js","names":["DecorativeIcon","Spinner","IconButton","buttonBaseDefaults","props","Box","getButtonBaseProps","iconButtonStyles","size","loading","buttonBaseStyles"],"sources":["../../../../src/components/actions/icon-button/IconButton.tsx"],"sourcesContent":["import { Box } from '@choco-vanille/primitives';\nimport type { FC } from 'react';\n\nimport { DecorativeIcon } from '@components/components/_common/components';\nimport { buttonBaseStyles } from '@components/components/actions/_common/button-base/buttonBase.css';\nimport { buttonBaseDefaults } from '@components/components/actions/_common/button-base/constants';\nimport { getButtonBaseProps } from '@components/components/actions/_common/button-base/utils/getButtonBaseProps.utils';\nimport { iconButtonStyles } from '@components/components/actions/icon-button/IconButton.css';\nimport type { IconButtonProps } from '@components/components/actions/icon-button/types';\nimport { Spinner } from '@components/components/feedback/spinner';\n\n/**\n * Renders a square native `button` (a `Box`) drawing its decorative `icon`\n * data with an `Icon`, centered and hidden from assistive technologies.\n * `variant`, `tone` and `size` set its colors and dimensions as for a\n * `Button`: its side is the height of a `Button` of the same size, and its\n * icon is about half its side (14, 16, 20 or 24px from `xs` to `lg`), larger\n * than the icons of a `Button`.\n *\n * `loading` hides the icon behind a spinner at the icon size of a `Button`\n * of the same size, flags the button with `data-loading`, `aria-busy` and\n * `aria-disabled`, and cancels its clicks: `onClick` is not called and no\n * form is submitted, but other handlers run and the button stays focusable.\n *\n * The required `aria-label` names the button. `type` is `button` unless\n * given. `disabled` disables it natively and flags it with `data-disabled`. The focus ring shows on keyboard\n * focus only.\n *\n * The margin props of `Box` space it from its siblings. Every other prop\n * (attributes, events, `ref`) goes to the `button`; `className` comes after\n * the generated classes. Its styles sit in the `cv.components` cascade\n * layers, below any unlayered style of the consumer.\n *\n * @param props Icon, accessible name, presentation, loading state, margin\n * props and native props of the `button`.\n * @param props.icon Data of the decorative icon shown in the button.\n * @param props.loading Whether the button is loading; `false` when absent.\n * @param props.size Side and icon size; `md` when absent.\n * @returns The button.\n */\nconst IconButton: FC<IconButtonProps> = ({\n icon,\n loading = buttonBaseDefaults.loading,\n size = buttonBaseDefaults.size,\n ...props\n}) => (\n <Box\n as={'button'}\n {...getButtonBaseProps({\n ...props,\n loading,\n sizeClassName: iconButtonStyles.sizes[size],\n })}\n >\n <DecorativeIcon className={iconButtonStyles.icon} icon={icon} />\n {loading ? (\n <Spinner className={buttonBaseStyles.spinnerPosition} />\n ) : null}\n </Box>\n);\n\nexport default IconButton;\n"],"mappings":";;;;;;;;;AAwCA,IAAME,KAAmC,EACrC,SACA,aAAUC,EAAmB,SAC7B,UAAOA,EAAmB,MAC1B,GAAGC,QAEH,kBAACC,GAAD;CACI,IAAI;CACJ,GAAIC,EAAmB;EACnB,GAAGF;EACH;EACA,eAAeG,EAAiB,MAAMC;CAC1C,CAAC;CANL,UAAA,CAQI,kBAACR,GAAD;EAAgB,WAAWO,EAAiB;EAAY;CAAO,CAAA,GAC9DE,IACG,kBAACR,GAAD,EAAS,WAAWS,EAAiB,gBAAkB,CAAA,IACvD,IACH"}
1
+ {"version":3,"file":"IconButton.js","names":["DecorativeIcon","Spinner","IconButton","buttonBaseDefaults","props","Box","getButtonBaseProps","iconButtonStyles","size","loading","buttonBaseStyles"],"sources":["../../../../src/components/actions/icon-button/IconButton.tsx"],"sourcesContent":["import { Box } from '@choco-vanille/primitives';\nimport type { FC } from 'react';\n\nimport { DecorativeIcon } from '@components/components/_common/components';\nimport { buttonBaseStyles } from '@components/components/actions/_common/button-base/buttonBase.css';\nimport { buttonBaseDefaults } from '@components/components/actions/_common/button-base/constants';\nimport { getButtonBaseProps } from '@components/components/actions/_common/button-base/utils/getButtonBaseProps.utils';\nimport { iconButtonStyles } from '@components/components/actions/icon-button/IconButton.css';\nimport type { IconButtonProps } from '@components/components/actions/icon-button/types';\nimport { Spinner } from '@components/components/feedback/spinner';\n\n/**\n * Renders a square native `button` (a `Box`) drawing its decorative `icon`\n * data with an `Icon`, centered and hidden from assistive technologies.\n * `variant`, `tone` and `size` set its colors and dimensions as for a\n * `Button`: its side is the height of a `Button` of the same size, and its\n * icon is about half its side (14, 16, 20 or 24px from `xs` to `lg`), larger\n * than the icons of a `Button`.\n *\n * `loading` hides the icon behind a spinner at the icon size of a `Button`\n * of the same size, flags the button with `data-loading`, `aria-busy` and\n * `aria-disabled`, and cancels its clicks: `onClick` is not called and no\n * form is submitted, but other handlers run and the button stays focusable.\n * A given `selected` makes it a toggle button: `aria-pressed` exposes its\n * state, and while `true` it keeps its pressed colors, hovered or loading,\n * and is flagged with `data-selected`; disabled, it takes the disabled colors.\n *\n * The required `aria-label` names the button. `type` is `button` unless\n * given. `disabled` disables it natively and flags it with `data-disabled`. The focus ring shows on keyboard\n * focus only.\n *\n * The margin props of `Box` space it from its siblings. Every other prop\n * (attributes, events, `ref`) goes to the `button`; `className` comes after\n * the generated classes. Its styles sit in the `cv.components` cascade\n * layers, below any unlayered style of the consumer.\n *\n * @param props Icon, accessible name, presentation, loading and selected\n * states, margin props and native props of the `button`.\n * @param props.icon Data of the decorative icon shown in the button.\n * @param props.loading Whether the button is loading; `false` when absent.\n * @param props.size Side and icon size; `md` when absent.\n * @returns The button.\n */\nconst IconButton: FC<IconButtonProps> = ({\n icon,\n loading = buttonBaseDefaults.loading,\n size = buttonBaseDefaults.size,\n ...props\n}) => (\n <Box\n as={'button'}\n {...getButtonBaseProps({\n ...props,\n loading,\n sizeClassName: iconButtonStyles.sizes[size],\n })}\n >\n <DecorativeIcon className={iconButtonStyles.icon} icon={icon} />\n {loading ? (\n <Spinner className={buttonBaseStyles.spinnerPosition} />\n ) : null}\n </Box>\n);\n\nexport default IconButton;\n"],"mappings":";;;;;;;;;AA2CA,IAAME,KAAmC,EACrC,SACA,aAAUC,EAAmB,SAC7B,UAAOA,EAAmB,MAC1B,GAAGC,QAEH,kBAACC,GAAD;CACI,IAAI;CACJ,GAAIC,EAAmB;EACnB,GAAGF;EACH;EACA,eAAeG,EAAiB,MAAMC;CAC1C,CAAC;CANL,UAAA,CAQI,kBAACR,GAAD;EAAgB,WAAWO,EAAiB;EAAY;CAAO,CAAA,GAC9DE,IACG,kBAACR,GAAD,EAAS,WAAWS,EAAiB,gBAAkB,CAAA,IACvD,IACH"}
@@ -1,2 +1,2 @@
1
- const e=require("../constants/index.cjs"),t=require("./getLinkBaseElementProps.utils.cjs"),n=require("./getLinkBaseSlotChild.utils.cjs"),r=require("../../../../../constants/iconRegistry.const.cjs");var i=e=>{let{rel:t,target:n}=e.props;return{rel:typeof t==`string`?t:void 0,target:typeof n==`string`?n:void 0}},a=({asChild:a=!1,children:o,endIcon:s,external:c=e.linkBaseDefaults.external,externalLabel:l,label:u,startIcon:d,...f},{className:p,partName:m})=>{let h=a?n.getLinkBaseSlotChild(o,m):void 0,g=t.getLinkBaseElementProps({...f,...h===void 0?{}:i(h),asChild:a,className:p,external:c}),_=g.target?.toLowerCase()===e.linkBaseExternalAttributes.target;return{child:h===void 0?void 0:{element:h,props:{rel:g.rel,target:g.target}},elementProps:g,endIcon:s??(c?r.iconRegistry.externalLink:void 0),externalLabel:c&&_&&l!==``?l:void 0,label:u,startIcon:d}};exports.getLinkBaseParts=a;
1
+ const e=require("../../../../_common/utils/get-label-slot-child/getLabelSlotChild.utils.cjs"),t=require("../constants/index.cjs"),n=require("./getLinkBaseElementProps.utils.cjs"),r=require("../../../../../constants/iconRegistry.const.cjs");var i=e=>{let{rel:t,target:n}=e.props;return{rel:typeof t==`string`?t:void 0,target:typeof n==`string`?n:void 0}},a=({asChild:a=!1,children:o,endIcon:s,external:c=t.linkBaseDefaults.external,externalLabel:l,label:u,startIcon:d,...f},{className:p,partName:m})=>{let h=a?e.getLabelSlotChild(o,m):void 0,g=n.getLinkBaseElementProps({...f,...h===void 0?{}:i(h),asChild:a,className:p,external:c}),_=g.target?.toLowerCase()===t.linkBaseExternalAttributes.target;return{child:h===void 0?void 0:{element:h,props:{rel:g.rel,target:g.target}},elementProps:g,endIcon:s??(c?r.iconRegistry.externalLink:void 0),externalLabel:c&&_&&l!==``?l:void 0,label:u,startIcon:d}};exports.getLinkBaseParts=a;
2
2
  //# sourceMappingURL=getLinkBaseParts.utils.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getLinkBaseParts.utils.cjs","names":["linkBaseDefaults","getLinkBaseSlotChild","getLinkBaseElementProps","linkBaseExternalAttributes","iconRegistry","require_index","require_getLinkBaseElementProps_utils","require_getLinkBaseSlotChild_utils","require_iconRegistry_const","getChildAnchorAttributes","child","rel","target","getLinkBaseParts","props","asChild","children","partName","elementProps","isNewTab","endIcon","external","externalLabel"],"sources":["../../../../../../src/components/navigation/_common/link-base/utils/getLinkBaseParts.utils.ts"],"sourcesContent":["import {\n linkBaseDefaults,\n linkBaseExternalAttributes,\n} from '@components/components/navigation/_common/link-base/constants';\nimport type {\n LinkBaseElementInput,\n LinkBaseParts,\n LinkBasePartsConfig,\n LinkBasePartsInput,\n LinkBaseSlotChild,\n} from '@components/components/navigation/_common/link-base/types';\nimport { getLinkBaseElementProps } from '@components/components/navigation/_common/link-base/utils/getLinkBaseElementProps.utils';\nimport { getLinkBaseSlotChild } from '@components/components/navigation/_common/link-base/utils/getLinkBaseSlotChild.utils';\nimport { iconRegistry } from '@components/constants/iconRegistry.const';\n\n/**\n * Reads the `target` and `rel` of the child of a link rendered with\n * `asChild`, which the link resolves as its own, then gives back to the\n * child in place of them: an external child opening in the current tab\n * announces no new tab, and its `rel` keeps `noopener noreferrer`. A value\n * that is not a string is ignored.\n *\n * @param child Validated child of the link.\n * @returns The `target` and `rel` of the child, absent when not strings.\n */\nconst getChildAnchorAttributes = (\n child: LinkBaseSlotChild,\n): Pick<LinkBaseElementInput, 'rel' | 'target'> => {\n const { rel, target } = child.props;\n\n return {\n rel: typeof rel === 'string' ? rel : undefined,\n target: typeof target === 'string' ? target : undefined,\n };\n};\n\n/**\n * Resolves what a link of the navigation renders, such as a `Link` or a\n * `Drawer.Item` given an `href` or `asChild`, from its props and its\n * generated classes: the props of its element (see\n * `getLinkBaseElementProps`); with `asChild`, its validated single child,\n * without content, which receives the label, and its resolved `target` and\n * `rel`, replacing its own, which the `Slot` would keep; the label and the\n * icons, an external link ending with the external icon unless `endIcon`\n * is given; and the hidden `externalLabel`, for an external link opening\n * in a new tab with a non-empty label, so never for a disabled own anchor,\n * which has no `href` nor `target`.\n *\n * @param props Props of the link but its classes.\n * @param props.asChild Whether the link renders its single child; `false`\n * when absent.\n * @param props.children Single child rendered with `asChild`.\n * @param props.endIcon Data of the icon after the label; none when absent.\n * @param props.external Whether the link opens in a new tab; `false` when\n * absent.\n * @param props.externalLabel Hidden text announcing the new tab, given with\n * `external`; none when absent or empty.\n * @param props.label Visible text of the link.\n * @param props.startIcon Data of the icon before the label; none when\n * absent.\n * @param config Generated classes and name of the link.\n * @param config.className Generated classes of the link, followed by those\n * of the consumer.\n * @param config.partName Name of the link, given in the errors.\n * @returns The element props, child, label and decorations of the link.\n * @throws {Error} With `asChild`, when the children are not a single\n * element, are a fragment, or have content of their own.\n */\nexport const getLinkBaseParts = (\n {\n asChild = false,\n children,\n endIcon,\n external = linkBaseDefaults.external,\n externalLabel,\n label,\n startIcon,\n ...props\n }: LinkBasePartsInput,\n { className, partName }: LinkBasePartsConfig,\n): LinkBaseParts => {\n const child = asChild\n ? getLinkBaseSlotChild(children, partName)\n : undefined;\n const elementProps = getLinkBaseElementProps({\n ...props,\n ...(child === undefined ? {} : getChildAnchorAttributes(child)),\n asChild,\n className,\n external,\n });\n const isNewTab =\n elementProps.target?.toLowerCase() ===\n linkBaseExternalAttributes.target;\n\n return {\n child:\n child === undefined\n ? undefined\n : {\n element: child,\n props: {\n rel: elementProps.rel,\n target: elementProps.target,\n },\n },\n elementProps,\n endIcon: endIcon ?? (external ? iconRegistry.externalLink : undefined),\n externalLabel:\n external && isNewTab && externalLabel !== ''\n ? externalLabel\n : undefined,\n label,\n startIcon,\n };\n};\n"],"mappings":"A,sMAyBA,IAAMS,EACF,GAC+C,CAC/C,GAAM,CAAE,MAAK,UAAWC,EAAM,MAE9B,MAAO,CACH,IAAK,OAAOC,GAAQ,SAAWA,EAAM,IAAA,GACrC,OAAQ,OAAOC,GAAW,SAAWA,EAAS,IAAA,EAClD,CACJ,EAkCaC,GACT,CACI,UAAU,GACV,WACA,UACA,WAAWb,EAAAA,iBAAiB,SAC5B,gBACA,QACA,YACA,GAAGc,GAEP,CAAE,YAAW,cACG,CAChB,IAAMJ,EAAQK,EACRd,EAAAA,qBAAqBe,EAAUC,CAAQ,EACvC,IAAA,GACAC,EAAehB,EAAAA,wBAAwB,CACzC,GAAGY,EACH,GAAIJ,IAAU,IAAA,GAAY,CAAC,EAAID,EAAyBC,CAAK,EAC7D,UACA,YACA,UACJ,CAAC,EACKS,EACFD,EAAa,QAAQ,YAAY,IACjCf,EAAAA,2BAA2B,OAE/B,MAAO,CACH,MACIO,IAAU,IAAA,GACJ,IAAA,GACA,CACI,QAASA,EACT,MAAO,CACH,IAAKQ,EAAa,IAClB,OAAQA,EAAa,MACzB,CACJ,EACV,eACA,QAASE,IAAYC,EAAWjB,EAAAA,aAAa,aAAe,IAAA,IAC5D,cACIiB,GAAYF,GAAYG,IAAkB,GACpCA,EACA,IAAA,GACV,QACA,WACJ,CACJ,E"}
1
+ {"version":3,"file":"getLinkBaseParts.utils.cjs","names":["linkBaseDefaults","getLabelSlotChild","getLinkBaseElementProps","linkBaseExternalAttributes","iconRegistry","require_getLabelSlotChild_utils","require_index","require_getLinkBaseElementProps_utils","require_iconRegistry_const","getChildAnchorAttributes","child","rel","target","getLinkBaseParts","props","asChild","children","partName","elementProps","isNewTab","endIcon","external","externalLabel"],"sources":["../../../../../../src/components/navigation/_common/link-base/utils/getLinkBaseParts.utils.ts"],"sourcesContent":["import { getLabelSlotChild } from '@components/components/_common/utils/get-label-slot-child/getLabelSlotChild.utils';\nimport {\n linkBaseDefaults,\n linkBaseExternalAttributes,\n} from '@components/components/navigation/_common/link-base/constants';\nimport type {\n LinkBaseElementInput,\n LinkBaseParts,\n LinkBasePartsConfig,\n LinkBasePartsInput,\n LinkBaseSlotChild,\n} from '@components/components/navigation/_common/link-base/types';\nimport { getLinkBaseElementProps } from '@components/components/navigation/_common/link-base/utils/getLinkBaseElementProps.utils';\nimport { iconRegistry } from '@components/constants/iconRegistry.const';\n\n/**\n * Reads the `target` and `rel` of the child of a link rendered with\n * `asChild`, which the link resolves as its own, then gives back to the\n * child in place of them: an external child opening in the current tab\n * announces no new tab, and its `rel` keeps `noopener noreferrer`. A value\n * that is not a string is ignored.\n *\n * @param child Validated child of the link.\n * @returns The `target` and `rel` of the child, absent when not strings.\n */\nconst getChildAnchorAttributes = (\n child: LinkBaseSlotChild,\n): Pick<LinkBaseElementInput, 'rel' | 'target'> => {\n const { rel, target } = child.props;\n\n return {\n rel: typeof rel === 'string' ? rel : undefined,\n target: typeof target === 'string' ? target : undefined,\n };\n};\n\n/**\n * Resolves what a link of the navigation renders, such as a `Link` or a\n * `Drawer.Item` given an `href` or `asChild`, from its props and its\n * generated classes: the props of its element (see\n * `getLinkBaseElementProps`); with `asChild`, its validated single child,\n * without content, which receives the label, and its resolved `target` and\n * `rel`, replacing its own, which the `Slot` would keep; the label and the\n * icons, an external link ending with the external icon unless `endIcon`\n * is given; and the hidden `externalLabel`, for an external link opening\n * in a new tab with a non-empty label, so never for a disabled own anchor,\n * which has no `href` nor `target`.\n *\n * @param props Props of the link but its classes.\n * @param props.asChild Whether the link renders its single child; `false`\n * when absent.\n * @param props.children Single child rendered with `asChild`.\n * @param props.endIcon Data of the icon after the label; none when absent.\n * @param props.external Whether the link opens in a new tab; `false` when\n * absent.\n * @param props.externalLabel Hidden text announcing the new tab, given with\n * `external`; none when absent or empty.\n * @param props.label Visible text of the link.\n * @param props.startIcon Data of the icon before the label; none when\n * absent.\n * @param config Generated classes and name of the link.\n * @param config.className Generated classes of the link, followed by those\n * of the consumer.\n * @param config.partName Name of the link, given in the errors.\n * @returns The element props, child, label and decorations of the link.\n * @throws {Error} With `asChild`, when the children are not a single\n * element, are a fragment, or have content of their own.\n */\nexport const getLinkBaseParts = (\n {\n asChild = false,\n children,\n endIcon,\n external = linkBaseDefaults.external,\n externalLabel,\n label,\n startIcon,\n ...props\n }: LinkBasePartsInput,\n { className, partName }: LinkBasePartsConfig,\n): LinkBaseParts => {\n const child = asChild ? getLabelSlotChild(children, partName) : undefined;\n const elementProps = getLinkBaseElementProps({\n ...props,\n ...(child === undefined ? {} : getChildAnchorAttributes(child)),\n asChild,\n className,\n external,\n });\n const isNewTab =\n elementProps.target?.toLowerCase() ===\n linkBaseExternalAttributes.target;\n\n return {\n child:\n child === undefined\n ? undefined\n : {\n element: child,\n props: {\n rel: elementProps.rel,\n target: elementProps.target,\n },\n },\n elementProps,\n endIcon: endIcon ?? (external ? iconRegistry.externalLink : undefined),\n externalLabel:\n external && isNewTab && externalLabel !== ''\n ? externalLabel\n : undefined,\n label,\n startIcon,\n };\n};\n"],"mappings":"A,gPAyBA,IAAMS,EACF,GAC+C,CAC/C,GAAM,CAAE,MAAK,UAAWC,EAAM,MAE9B,MAAO,CACH,IAAK,OAAOC,GAAQ,SAAWA,EAAM,IAAA,GACrC,OAAQ,OAAOC,GAAW,SAAWA,EAAS,IAAA,EAClD,CACJ,EAkCaC,GACT,CACI,UAAU,GACV,WACA,UACA,WAAWb,EAAAA,iBAAiB,SAC5B,gBACA,QACA,YACA,GAAGc,GAEP,CAAE,YAAW,cACG,CAChB,IAAMJ,EAAQK,EAAUd,EAAAA,kBAAkBe,EAAUC,CAAQ,EAAI,IAAA,GAC1DC,EAAehB,EAAAA,wBAAwB,CACzC,GAAGY,EACH,GAAIJ,IAAU,IAAA,GAAY,CAAC,EAAID,EAAyBC,CAAK,EAC7D,UACA,YACA,UACJ,CAAC,EACKS,EACFD,EAAa,QAAQ,YAAY,IACjCf,EAAAA,2BAA2B,OAE/B,MAAO,CACH,MACIO,IAAU,IAAA,GACJ,IAAA,GACA,CACI,QAASA,EACT,MAAO,CACH,IAAKQ,EAAa,IAClB,OAAQA,EAAa,MACzB,CACJ,EACV,eACA,QAASE,IAAYC,EAAWjB,EAAAA,aAAa,aAAe,IAAA,IAC5D,cACIiB,GAAYF,GAAYG,IAAkB,GACpCA,EACA,IAAA,GACV,QACA,WACJ,CACJ,E"}
@@ -1,6 +1,6 @@
1
- import { linkBaseDefaults as e, linkBaseExternalAttributes as t } from "../constants/index.js";
2
- import { getLinkBaseElementProps as n } from "./getLinkBaseElementProps.utils.js";
3
- import { getLinkBaseSlotChild as r } from "./getLinkBaseSlotChild.utils.js";
1
+ import { getLabelSlotChild as e } from "../../../../_common/utils/get-label-slot-child/getLabelSlotChild.utils.js";
2
+ import { linkBaseDefaults as t, linkBaseExternalAttributes as n } from "../constants/index.js";
3
+ import { getLinkBaseElementProps as r } from "./getLinkBaseElementProps.utils.js";
4
4
  import { iconRegistry as i } from "../../../../../constants/iconRegistry.const.js";
5
5
  // src/components/navigation/_common/link-base/utils/getLinkBaseParts.utils.ts
6
6
  var a = (e) => {
@@ -9,14 +9,14 @@ var a = (e) => {
9
9
  rel: typeof t == "string" ? t : void 0,
10
10
  target: typeof n == "string" ? n : void 0
11
11
  };
12
- }, o = ({ asChild: o = !1, children: s, endIcon: c, external: l = e.external, externalLabel: u, label: d, startIcon: f, ...p }, { className: m, partName: h }) => {
13
- let g = o ? r(s, h) : void 0, _ = n({
12
+ }, o = ({ asChild: o = !1, children: s, endIcon: c, external: l = t.external, externalLabel: u, label: d, startIcon: f, ...p }, { className: m, partName: h }) => {
13
+ let g = o ? e(s, h) : void 0, _ = r({
14
14
  ...p,
15
15
  ...g === void 0 ? {} : a(g),
16
16
  asChild: o,
17
17
  className: m,
18
18
  external: l
19
- }), v = _.target?.toLowerCase() === t.target;
19
+ }), v = _.target?.toLowerCase() === n.target;
20
20
  return {
21
21
  child: g === void 0 ? void 0 : {
22
22
  element: g,
@@ -1 +1 @@
1
- {"version":3,"file":"getLinkBaseParts.utils.js","names":["getChildAnchorAttributes","child","rel","target","getLinkBaseParts","linkBaseDefaults","props","asChild","getLinkBaseSlotChild","children","partName","elementProps","getLinkBaseElementProps","isNewTab","linkBaseExternalAttributes","endIcon","external","iconRegistry","externalLabel"],"sources":["../../../../../../src/components/navigation/_common/link-base/utils/getLinkBaseParts.utils.ts"],"sourcesContent":["import {\n linkBaseDefaults,\n linkBaseExternalAttributes,\n} from '@components/components/navigation/_common/link-base/constants';\nimport type {\n LinkBaseElementInput,\n LinkBaseParts,\n LinkBasePartsConfig,\n LinkBasePartsInput,\n LinkBaseSlotChild,\n} from '@components/components/navigation/_common/link-base/types';\nimport { getLinkBaseElementProps } from '@components/components/navigation/_common/link-base/utils/getLinkBaseElementProps.utils';\nimport { getLinkBaseSlotChild } from '@components/components/navigation/_common/link-base/utils/getLinkBaseSlotChild.utils';\nimport { iconRegistry } from '@components/constants/iconRegistry.const';\n\n/**\n * Reads the `target` and `rel` of the child of a link rendered with\n * `asChild`, which the link resolves as its own, then gives back to the\n * child in place of them: an external child opening in the current tab\n * announces no new tab, and its `rel` keeps `noopener noreferrer`. A value\n * that is not a string is ignored.\n *\n * @param child Validated child of the link.\n * @returns The `target` and `rel` of the child, absent when not strings.\n */\nconst getChildAnchorAttributes = (\n child: LinkBaseSlotChild,\n): Pick<LinkBaseElementInput, 'rel' | 'target'> => {\n const { rel, target } = child.props;\n\n return {\n rel: typeof rel === 'string' ? rel : undefined,\n target: typeof target === 'string' ? target : undefined,\n };\n};\n\n/**\n * Resolves what a link of the navigation renders, such as a `Link` or a\n * `Drawer.Item` given an `href` or `asChild`, from its props and its\n * generated classes: the props of its element (see\n * `getLinkBaseElementProps`); with `asChild`, its validated single child,\n * without content, which receives the label, and its resolved `target` and\n * `rel`, replacing its own, which the `Slot` would keep; the label and the\n * icons, an external link ending with the external icon unless `endIcon`\n * is given; and the hidden `externalLabel`, for an external link opening\n * in a new tab with a non-empty label, so never for a disabled own anchor,\n * which has no `href` nor `target`.\n *\n * @param props Props of the link but its classes.\n * @param props.asChild Whether the link renders its single child; `false`\n * when absent.\n * @param props.children Single child rendered with `asChild`.\n * @param props.endIcon Data of the icon after the label; none when absent.\n * @param props.external Whether the link opens in a new tab; `false` when\n * absent.\n * @param props.externalLabel Hidden text announcing the new tab, given with\n * `external`; none when absent or empty.\n * @param props.label Visible text of the link.\n * @param props.startIcon Data of the icon before the label; none when\n * absent.\n * @param config Generated classes and name of the link.\n * @param config.className Generated classes of the link, followed by those\n * of the consumer.\n * @param config.partName Name of the link, given in the errors.\n * @returns The element props, child, label and decorations of the link.\n * @throws {Error} With `asChild`, when the children are not a single\n * element, are a fragment, or have content of their own.\n */\nexport const getLinkBaseParts = (\n {\n asChild = false,\n children,\n endIcon,\n external = linkBaseDefaults.external,\n externalLabel,\n label,\n startIcon,\n ...props\n }: LinkBasePartsInput,\n { className, partName }: LinkBasePartsConfig,\n): LinkBaseParts => {\n const child = asChild\n ? getLinkBaseSlotChild(children, partName)\n : undefined;\n const elementProps = getLinkBaseElementProps({\n ...props,\n ...(child === undefined ? {} : getChildAnchorAttributes(child)),\n asChild,\n className,\n external,\n });\n const isNewTab =\n elementProps.target?.toLowerCase() ===\n linkBaseExternalAttributes.target;\n\n return {\n child:\n child === undefined\n ? undefined\n : {\n element: child,\n props: {\n rel: elementProps.rel,\n target: elementProps.target,\n },\n },\n elementProps,\n endIcon: endIcon ?? (external ? iconRegistry.externalLink : undefined),\n externalLabel:\n external && isNewTab && externalLabel !== ''\n ? externalLabel\n : undefined,\n label,\n startIcon,\n };\n};\n"],"mappings":";;;;;AAyBA,IAAMA,KACF,MAC+C;CAC/C,IAAM,EAAE,QAAK,cAAWC,EAAM;CAE9B,OAAO;EACH,KAAK,OAAOC,KAAQ,WAAWA,IAAM,KAAA;EACrC,QAAQ,OAAOC,KAAW,WAAWA,IAAS,KAAA;CAClD;AACJ,GAkCaC,KACT,EACI,aAAU,IACV,aACA,YACA,cAAWC,EAAiB,UAC5B,kBACA,UACA,cACA,GAAGC,KAEP,EAAE,cAAW,kBACG;CAChB,IAAML,IAAQM,IACRC,EAAqBC,GAAUC,CAAQ,IACvC,KAAA,GACAC,IAAeC,EAAwB;EACzC,GAAGN;EACH,GAAIL,MAAU,KAAA,IAAY,CAAC,IAAID,EAAyBC,CAAK;EAC7D;EACA;EACA;CACJ,CAAC,GACKY,IACFF,EAAa,QAAQ,YAAY,MACjCG,EAA2B;CAE/B,OAAO;EACH,OACIb,MAAU,KAAA,IACJ,KAAA,IACA;GACI,SAASA;GACT,OAAO;IACH,KAAKU,EAAa;IAClB,QAAQA,EAAa;GACzB;EACJ;EACV;EACA,SAASI,MAAYC,IAAWC,EAAa,eAAe,KAAA;EAC5D,eACID,KAAYH,KAAYK,MAAkB,KACpCA,IACA,KAAA;EACV;EACA;CACJ;AACJ"}
1
+ {"version":3,"file":"getLinkBaseParts.utils.js","names":["getChildAnchorAttributes","child","rel","target","getLinkBaseParts","linkBaseDefaults","props","asChild","getLabelSlotChild","children","partName","elementProps","getLinkBaseElementProps","isNewTab","linkBaseExternalAttributes","endIcon","external","iconRegistry","externalLabel"],"sources":["../../../../../../src/components/navigation/_common/link-base/utils/getLinkBaseParts.utils.ts"],"sourcesContent":["import { getLabelSlotChild } from '@components/components/_common/utils/get-label-slot-child/getLabelSlotChild.utils';\nimport {\n linkBaseDefaults,\n linkBaseExternalAttributes,\n} from '@components/components/navigation/_common/link-base/constants';\nimport type {\n LinkBaseElementInput,\n LinkBaseParts,\n LinkBasePartsConfig,\n LinkBasePartsInput,\n LinkBaseSlotChild,\n} from '@components/components/navigation/_common/link-base/types';\nimport { getLinkBaseElementProps } from '@components/components/navigation/_common/link-base/utils/getLinkBaseElementProps.utils';\nimport { iconRegistry } from '@components/constants/iconRegistry.const';\n\n/**\n * Reads the `target` and `rel` of the child of a link rendered with\n * `asChild`, which the link resolves as its own, then gives back to the\n * child in place of them: an external child opening in the current tab\n * announces no new tab, and its `rel` keeps `noopener noreferrer`. A value\n * that is not a string is ignored.\n *\n * @param child Validated child of the link.\n * @returns The `target` and `rel` of the child, absent when not strings.\n */\nconst getChildAnchorAttributes = (\n child: LinkBaseSlotChild,\n): Pick<LinkBaseElementInput, 'rel' | 'target'> => {\n const { rel, target } = child.props;\n\n return {\n rel: typeof rel === 'string' ? rel : undefined,\n target: typeof target === 'string' ? target : undefined,\n };\n};\n\n/**\n * Resolves what a link of the navigation renders, such as a `Link` or a\n * `Drawer.Item` given an `href` or `asChild`, from its props and its\n * generated classes: the props of its element (see\n * `getLinkBaseElementProps`); with `asChild`, its validated single child,\n * without content, which receives the label, and its resolved `target` and\n * `rel`, replacing its own, which the `Slot` would keep; the label and the\n * icons, an external link ending with the external icon unless `endIcon`\n * is given; and the hidden `externalLabel`, for an external link opening\n * in a new tab with a non-empty label, so never for a disabled own anchor,\n * which has no `href` nor `target`.\n *\n * @param props Props of the link but its classes.\n * @param props.asChild Whether the link renders its single child; `false`\n * when absent.\n * @param props.children Single child rendered with `asChild`.\n * @param props.endIcon Data of the icon after the label; none when absent.\n * @param props.external Whether the link opens in a new tab; `false` when\n * absent.\n * @param props.externalLabel Hidden text announcing the new tab, given with\n * `external`; none when absent or empty.\n * @param props.label Visible text of the link.\n * @param props.startIcon Data of the icon before the label; none when\n * absent.\n * @param config Generated classes and name of the link.\n * @param config.className Generated classes of the link, followed by those\n * of the consumer.\n * @param config.partName Name of the link, given in the errors.\n * @returns The element props, child, label and decorations of the link.\n * @throws {Error} With `asChild`, when the children are not a single\n * element, are a fragment, or have content of their own.\n */\nexport const getLinkBaseParts = (\n {\n asChild = false,\n children,\n endIcon,\n external = linkBaseDefaults.external,\n externalLabel,\n label,\n startIcon,\n ...props\n }: LinkBasePartsInput,\n { className, partName }: LinkBasePartsConfig,\n): LinkBaseParts => {\n const child = asChild ? getLabelSlotChild(children, partName) : undefined;\n const elementProps = getLinkBaseElementProps({\n ...props,\n ...(child === undefined ? {} : getChildAnchorAttributes(child)),\n asChild,\n className,\n external,\n });\n const isNewTab =\n elementProps.target?.toLowerCase() ===\n linkBaseExternalAttributes.target;\n\n return {\n child:\n child === undefined\n ? undefined\n : {\n element: child,\n props: {\n rel: elementProps.rel,\n target: elementProps.target,\n },\n },\n elementProps,\n endIcon: endIcon ?? (external ? iconRegistry.externalLink : undefined),\n externalLabel:\n external && isNewTab && externalLabel !== ''\n ? externalLabel\n : undefined,\n label,\n startIcon,\n };\n};\n"],"mappings":";;;;;AAyBA,IAAMA,KACF,MAC+C;CAC/C,IAAM,EAAE,QAAK,cAAWC,EAAM;CAE9B,OAAO;EACH,KAAK,OAAOC,KAAQ,WAAWA,IAAM,KAAA;EACrC,QAAQ,OAAOC,KAAW,WAAWA,IAAS,KAAA;CAClD;AACJ,GAkCaC,KACT,EACI,aAAU,IACV,aACA,YACA,cAAWC,EAAiB,UAC5B,kBACA,UACA,cACA,GAAGC,KAEP,EAAE,cAAW,kBACG;CAChB,IAAML,IAAQM,IAAUC,EAAkBC,GAAUC,CAAQ,IAAI,KAAA,GAC1DC,IAAeC,EAAwB;EACzC,GAAGN;EACH,GAAIL,MAAU,KAAA,IAAY,CAAC,IAAID,EAAyBC,CAAK;EAC7D;EACA;EACA;CACJ,CAAC,GACKY,IACFF,EAAa,QAAQ,YAAY,MACjCG,EAA2B;CAE/B,OAAO;EACH,OACIb,MAAU,KAAA,IACJ,KAAA,IACA;GACI,SAASA;GACT,OAAO;IACH,KAAKU,EAAa;IAClB,QAAQA,EAAa;GACzB;EACJ;EACV;EACA,SAASI,MAAYC,IAAWC,EAAa,eAAe,KAAA;EAC5D,eACID,KAAYH,KAAYK,MAAkB,KACpCA,IACA,KAAA;EACV;EACA;CACJ;AACJ"}
@@ -1,2 +1,2 @@
1
- const e=require("../../../../_common/components/decorative-icon/DecorativeIcon.cjs"),t=require("../../../../_common/utils/hasRenderableContent.utils.cjs"),n=require("./DrawerItem.css.cjs"),r=require("./utils/getDrawerItemParts.utils.cjs"),i=require("../../constants/index.cjs"),a=require("../../hooks/useDrawerContext.hook.cjs");let o=require("@choco-vanille/primitives"),s=require("react/jsx-runtime"),c=require("react");var l=l=>{a.useDrawerContext(i.drawerPartNames.item);let u=r.getDrawerItemParts(l),{content:d}=u,f=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.default,{className:d.isDot?n.drawerItemStyles.dot:n.drawerItemStyles.startIcon,icon:d.startIcon}),(0,s.jsx)(`span`,{className:n.drawerItemStyles.label,children:d.label}),d.endIcon?(0,s.jsx)(e.default,{className:n.drawerItemStyles.endIcon,icon:d.endIcon}):null,t.hasRenderableContent(d.endSlot)?(0,s.jsx)(`span`,{className:n.drawerItemStyles.endSlot,children:d.endSlot}):null,d.externalLabel===void 0?null:(0,s.jsxs)(o.VisuallyHidden,{children:[` `,d.externalLabel]})]});return u.element===`button`?(0,s.jsx)(o.Box,{as:`button`,...u.elementProps,children:f}):u.child===void 0?(0,s.jsx)(o.Box,{as:`a`,...u.elementProps,children:f}):(0,s.jsx)(o.Box,{asChild:!0,...u.elementProps,children:(0,c.cloneElement)(u.child.element,u.child.props,f)})};exports.default=l;
1
+ const e=require("../../../../_common/components/decorative-icon/DecorativeIcon.cjs"),t=require("../../../../_common/utils/hasRenderableContent.utils.cjs"),n=require("./DrawerItem.css.cjs"),r=require("./utils/getDrawerItemParts.utils.cjs"),i=require("../../constants/index.cjs"),a=require("../../hooks/useDrawerContext.hook.cjs");let o=require("@choco-vanille/primitives"),s=require("react"),c=require("react/jsx-runtime");var l=l=>{a.useDrawerContext(i.drawerPartNames.item);let u=r.getDrawerItemParts(l),{content:d}=u,f=(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(e.default,{className:d.isDot?n.drawerItemStyles.dot:n.drawerItemStyles.startIcon,icon:d.startIcon}),(0,c.jsx)(`span`,{className:n.drawerItemStyles.label,children:d.label}),d.endIcon?(0,c.jsx)(e.default,{className:n.drawerItemStyles.endIcon,icon:d.endIcon}):null,t.hasRenderableContent(d.endSlot)?(0,c.jsx)(`span`,{className:n.drawerItemStyles.endSlot,children:d.endSlot}):null,d.externalLabel===void 0?null:(0,c.jsxs)(o.VisuallyHidden,{children:[` `,d.externalLabel]})]});return u.element===`button`?(0,c.jsx)(o.Box,{as:`button`,...u.elementProps,children:f}):u.child===void 0?(0,c.jsx)(o.Box,{as:`a`,...u.elementProps,children:f}):(0,c.jsx)(o.Box,{asChild:!0,...u.elementProps,children:(0,s.cloneElement)(u.child.element,u.child.props,f)})};exports.default=l;
2
2
  //# sourceMappingURL=DrawerItem.cjs.map