@choco-vanille/primitives 0.0.0-stage → 0.1.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +482 -2
- package/dist/components/_common/components/slot/Slot.cjs +2 -0
- package/dist/components/_common/components/slot/Slot.cjs.map +1 -0
- package/dist/components/_common/components/slot/Slot.js +10 -0
- package/dist/components/_common/components/slot/Slot.js.map +1 -0
- package/dist/components/_common/components/slot/hooks/use-slot/useSlot.hook.cjs +2 -0
- package/dist/components/_common/components/slot/hooks/use-slot/useSlot.hook.cjs.map +1 -0
- package/dist/components/_common/components/slot/hooks/use-slot/useSlot.hook.js +18 -0
- package/dist/components/_common/components/slot/hooks/use-slot/useSlot.hook.js.map +1 -0
- package/dist/components/_common/components/slot/utils/attachRef.utils.cjs +2 -0
- package/dist/components/_common/components/slot/utils/attachRef.utils.cjs.map +1 -0
- package/dist/components/_common/components/slot/utils/attachRef.utils.js +18 -0
- package/dist/components/_common/components/slot/utils/attachRef.utils.js.map +1 -0
- package/dist/components/_common/components/slot/utils/composeRefs.utils.cjs +2 -0
- package/dist/components/_common/components/slot/utils/composeRefs.utils.cjs.map +1 -0
- package/dist/components/_common/components/slot/utils/composeRefs.utils.js +13 -0
- package/dist/components/_common/components/slot/utils/composeRefs.utils.js.map +1 -0
- package/dist/components/_common/components/slot/utils/getSlotChild.utils.cjs +2 -0
- package/dist/components/_common/components/slot/utils/getSlotChild.utils.cjs.map +1 -0
- package/dist/components/_common/components/slot/utils/getSlotChild.utils.js +9 -0
- package/dist/components/_common/components/slot/utils/getSlotChild.utils.js.map +1 -0
- package/dist/components/_common/components/slot/utils/mergeClassNames.utils.cjs +2 -0
- package/dist/components/_common/components/slot/utils/mergeClassNames.utils.cjs.map +1 -0
- package/dist/components/_common/components/slot/utils/mergeClassNames.utils.js +8 -0
- package/dist/components/_common/components/slot/utils/mergeClassNames.utils.js.map +1 -0
- package/dist/components/_common/components/slot/utils/mergeSlotProps.utils.cjs +2 -0
- package/dist/components/_common/components/slot/utils/mergeSlotProps.utils.cjs.map +1 -0
- package/dist/components/_common/components/slot/utils/mergeSlotProps.utils.js +16 -0
- package/dist/components/_common/components/slot/utils/mergeSlotProps.utils.js.map +1 -0
- package/dist/components/_common/components/slot/utils/mergeStyles.utils.cjs +2 -0
- package/dist/components/_common/components/slot/utils/mergeStyles.utils.cjs.map +1 -0
- package/dist/components/_common/components/slot/utils/mergeStyles.utils.js +14 -0
- package/dist/components/_common/components/slot/utils/mergeStyles.utils.js.map +1 -0
- package/dist/components/_common/styles/style-props/styleProps.css.cjs +2 -0
- package/dist/components/_common/styles/style-props/styleProps.css.cjs.map +1 -0
- package/dist/components/_common/styles/style-props/styleProps.css.js +370 -0
- package/dist/components/_common/styles/style-props/styleProps.css.js.map +1 -0
- package/dist/components/_common/utils/environment/isProcessUnavailableError.utils.cjs +2 -0
- package/dist/components/_common/utils/environment/isProcessUnavailableError.utils.cjs.map +1 -0
- package/dist/components/_common/utils/environment/isProcessUnavailableError.utils.js +5 -0
- package/dist/components/_common/utils/environment/isProcessUnavailableError.utils.js.map +1 -0
- package/dist/components/_common/utils/style-props/createStyleSet.utils.cjs +2 -0
- package/dist/components/_common/utils/style-props/createStyleSet.utils.cjs.map +1 -0
- package/dist/components/_common/utils/style-props/createStyleSet.utils.js +13 -0
- package/dist/components/_common/utils/style-props/createStyleSet.utils.js.map +1 -0
- package/dist/components/_common/utils/style-props/formatStyleValue.utils.cjs +2 -0
- package/dist/components/_common/utils/style-props/formatStyleValue.utils.cjs.map +1 -0
- package/dist/components/_common/utils/style-props/formatStyleValue.utils.js +11 -0
- package/dist/components/_common/utils/style-props/formatStyleValue.utils.js.map +1 -0
- package/dist/components/_common/utils/style-props/getClassName.utils.cjs +2 -0
- package/dist/components/_common/utils/style-props/getClassName.utils.cjs.map +1 -0
- package/dist/components/_common/utils/style-props/getClassName.utils.js +21 -0
- package/dist/components/_common/utils/style-props/getClassName.utils.js.map +1 -0
- package/dist/components/_common/utils/style-props/getElementProps.utils.cjs +2 -0
- package/dist/components/_common/utils/style-props/getElementProps.utils.cjs.map +1 -0
- package/dist/components/_common/utils/style-props/getElementProps.utils.js +39 -0
- package/dist/components/_common/utils/style-props/getElementProps.utils.js.map +1 -0
- package/dist/components/_common/utils/style-props/getTokenClassNames.utils.cjs +2 -0
- package/dist/components/_common/utils/style-props/getTokenClassNames.utils.cjs.map +1 -0
- package/dist/components/_common/utils/style-props/getTokenClassNames.utils.js +21 -0
- package/dist/components/_common/utils/style-props/getTokenClassNames.utils.js.map +1 -0
- package/dist/components/_common/utils/style-props/logUnknownStyleValue.utils.cjs +2 -0
- package/dist/components/_common/utils/style-props/logUnknownStyleValue.utils.cjs.map +1 -0
- package/dist/components/_common/utils/style-props/logUnknownStyleValue.utils.js +9 -0
- package/dist/components/_common/utils/style-props/logUnknownStyleValue.utils.js.map +1 -0
- package/dist/components/_common/utils/style-props/resolveSizeValue.utils.cjs +2 -0
- package/dist/components/_common/utils/style-props/resolveSizeValue.utils.cjs.map +1 -0
- package/dist/components/_common/utils/style-props/resolveSizeValue.utils.js +5 -0
- package/dist/components/_common/utils/style-props/resolveSizeValue.utils.js.map +1 -0
- package/dist/components/accessibility/visually-hidden/VisuallyHidden.cjs +2 -0
- package/dist/components/accessibility/visually-hidden/VisuallyHidden.cjs.map +1 -0
- package/dist/components/accessibility/visually-hidden/VisuallyHidden.css.cjs +2 -0
- package/dist/components/accessibility/visually-hidden/VisuallyHidden.css.cjs.map +1 -0
- package/dist/components/accessibility/visually-hidden/VisuallyHidden.css.js +10 -0
- package/dist/components/accessibility/visually-hidden/VisuallyHidden.css.js.map +1 -0
- package/dist/components/accessibility/visually-hidden/VisuallyHidden.js +11 -0
- package/dist/components/accessibility/visually-hidden/VisuallyHidden.js.map +1 -0
- package/dist/components/accessibility/visually-hidden/utils/getVisuallyHiddenElementProps.utils.cjs +2 -0
- package/dist/components/accessibility/visually-hidden/utils/getVisuallyHiddenElementProps.utils.cjs.map +1 -0
- package/dist/components/accessibility/visually-hidden/utils/getVisuallyHiddenElementProps.utils.js +17 -0
- package/dist/components/accessibility/visually-hidden/utils/getVisuallyHiddenElementProps.utils.js.map +1 -0
- package/dist/components/foundation/icon/Icon.cjs +2 -0
- package/dist/components/foundation/icon/Icon.cjs.map +1 -0
- package/dist/components/foundation/icon/Icon.css.cjs +2 -0
- package/dist/components/foundation/icon/Icon.css.cjs.map +1 -0
- package/dist/components/foundation/icon/Icon.css.js +29 -0
- package/dist/components/foundation/icon/Icon.css.js.map +1 -0
- package/dist/components/foundation/icon/Icon.js +8 -0
- package/dist/components/foundation/icon/Icon.js.map +1 -0
- package/dist/components/foundation/icon/utils/getIconElementProps.utils.cjs +2 -0
- package/dist/components/foundation/icon/utils/getIconElementProps.utils.cjs.map +1 -0
- package/dist/components/foundation/icon/utils/getIconElementProps.utils.js +26 -0
- package/dist/components/foundation/icon/utils/getIconElementProps.utils.js.map +1 -0
- package/dist/components/foundation/typography/Typography.cjs +2 -0
- package/dist/components/foundation/typography/Typography.cjs.map +1 -0
- package/dist/components/foundation/typography/Typography.css.cjs +2 -0
- package/dist/components/foundation/typography/Typography.css.cjs.map +1 -0
- package/dist/components/foundation/typography/Typography.css.js +149 -0
- package/dist/components/foundation/typography/Typography.css.js.map +1 -0
- package/dist/components/foundation/typography/Typography.js +11 -0
- package/dist/components/foundation/typography/Typography.js.map +1 -0
- package/dist/components/foundation/typography/utils/getTypographyElementProps.utils.cjs +2 -0
- package/dist/components/foundation/typography/utils/getTypographyElementProps.utils.cjs.map +1 -0
- package/dist/components/foundation/typography/utils/getTypographyElementProps.utils.js +9 -0
- package/dist/components/foundation/typography/utils/getTypographyElementProps.utils.js.map +1 -0
- package/dist/components/layout/box/Box.cjs +2 -0
- package/dist/components/layout/box/Box.cjs.map +1 -0
- package/dist/components/layout/box/Box.css.cjs +2 -0
- package/dist/components/layout/box/Box.css.cjs.map +1 -0
- package/dist/components/layout/box/Box.css.js +418 -0
- package/dist/components/layout/box/Box.css.js.map +1 -0
- package/dist/components/layout/box/Box.js +11 -0
- package/dist/components/layout/box/Box.js.map +1 -0
- package/dist/components/layout/box/utils/getBoxElementProps.utils.cjs +2 -0
- package/dist/components/layout/box/utils/getBoxElementProps.utils.cjs.map +1 -0
- package/dist/components/layout/box/utils/getBoxElementProps.utils.js +9 -0
- package/dist/components/layout/box/utils/getBoxElementProps.utils.js.map +1 -0
- package/dist/components/layout/flex/Flex.cjs +2 -0
- package/dist/components/layout/flex/Flex.cjs.map +1 -0
- package/dist/components/layout/flex/Flex.js +11 -0
- package/dist/components/layout/flex/Flex.js.map +1 -0
- package/dist/components/layout/flex/constants/index.cjs +2 -0
- package/dist/components/layout/flex/constants/index.cjs.map +1 -0
- package/dist/components/layout/flex/constants/index.js +5 -0
- package/dist/components/layout/flex/constants/index.js.map +1 -0
- package/dist/components/layout/flex/utils/getFlexElementProps.utils.cjs +2 -0
- package/dist/components/layout/flex/utils/getFlexElementProps.utils.cjs.map +1 -0
- package/dist/components/layout/flex/utils/getFlexElementProps.utils.js +9 -0
- package/dist/components/layout/flex/utils/getFlexElementProps.utils.js.map +1 -0
- package/dist/components/layout/grid/Grid.cjs +2 -0
- package/dist/components/layout/grid/Grid.cjs.map +1 -0
- package/dist/components/layout/grid/Grid.js +11 -0
- package/dist/components/layout/grid/Grid.js.map +1 -0
- package/dist/components/layout/grid/constants/index.cjs +2 -0
- package/dist/components/layout/grid/constants/index.cjs.map +1 -0
- package/dist/components/layout/grid/constants/index.js +5 -0
- package/dist/components/layout/grid/constants/index.js.map +1 -0
- package/dist/components/layout/grid/utils/getGridElementProps.utils.cjs +2 -0
- package/dist/components/layout/grid/utils/getGridElementProps.utils.cjs.map +1 -0
- package/dist/components/layout/grid/utils/getGridElementProps.utils.js +9 -0
- package/dist/components/layout/grid/utils/getGridElementProps.utils.js.map +1 -0
- package/dist/components/layout/separator/Separator.cjs +2 -0
- package/dist/components/layout/separator/Separator.cjs.map +1 -0
- package/dist/components/layout/separator/Separator.css.cjs +2 -0
- package/dist/components/layout/separator/Separator.css.cjs.map +1 -0
- package/dist/components/layout/separator/Separator.css.js +32 -0
- package/dist/components/layout/separator/Separator.css.js.map +1 -0
- package/dist/components/layout/separator/Separator.js +10 -0
- package/dist/components/layout/separator/Separator.js.map +1 -0
- package/dist/components/layout/separator/utils/getSeparatorElementProps.utils.cjs +2 -0
- package/dist/components/layout/separator/utils/getSeparatorElementProps.utils.cjs.map +1 -0
- package/dist/components/layout/separator/utils/getSeparatorElementProps.utils.js +22 -0
- package/dist/components/layout/separator/utils/getSeparatorElementProps.utils.js.map +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +1427 -0
- package/dist/index.d.ts +1427 -0
- package/dist/index.js +8 -0
- package/dist/styles.css +2 -0
- package/package.json +89 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getClassName.utils.js","names":["isUnknownValueReported","error","isProcessUnavailableError","getClassName","propertySuffixes","table","property","value","suffix","logUnknownStyleValue","prop"],"sources":["../../../../../src/components/_common/utils/style-props/getClassName.utils.ts"],"sourcesContent":["import type { ClassTable } from '@primitives/components/_common/types';\nimport { isProcessUnavailableError } from '@primitives/components/_common/utils/environment/isProcessUnavailableError.utils';\nimport { logUnknownStyleValue } from '@primitives/components/_common/utils/style-props/logUnknownStyleValue.utils';\n\n/**\n * Tells whether an unknown style value must be reported, reading\n * `process.env.NODE_ENV` verbatim so bundlers replace it and production\n * builds drop the report. Only this read sits in the `try`, so an error\n * raised while logging is never taken for an unavailable `process`. Without\n * `process`, the environment is unknown and the value is reported.\n *\n * @returns Whether the environment is not production.\n * @throws {Error} When the read fails for another reason than an unavailable\n * `process`.\n */\nconst isUnknownValueReported = (): boolean => {\n try {\n return process.env.NODE_ENV !== 'production';\n } catch (error) {\n if (isProcessUnavailableError(error)) {\n return true;\n }\n\n throw error;\n }\n};\n\n/**\n * Looks up the atomic class of one value of a longhand property. The class\n * comes with a leading space, ready to be appended to a class list. A value\n * outside the property's set, which the prop types forbid, yields no class\n * and is ignored: outside production, an error naming the prop, the value\n * and the possible values is logged to the console, without interrupting\n * the render.\n *\n * The check reads `process.env.NODE_ENV` verbatim, right where it reports,\n * so bundlers replace it and production builds drop the report. Without\n * bundler, where `process` does not exist, the environment is unknown and\n * the value is reported.\n *\n * @param table Class table holding the property.\n * @param property Longhand property the class belongs to.\n * @param value Value given to the prop.\n * @param prop Prop the value was given to, named in the logged error: the\n * property itself or one of its shorthands.\n * @returns The class preceded by a space, or an empty string when the value\n * has no class.\n * @throws {Error} When reading `process.env.NODE_ENV` fails for another\n * reason than an unavailable `process`, or when the console fails.\n */\nexport const getClassName = (\n table: ClassTable,\n property: string,\n value: unknown,\n prop: string,\n): string => {\n const propertySuffixes = table.suffixes[property];\n\n if (\n propertySuffixes !== undefined &&\n (typeof value === 'string' || typeof value === 'number')\n ) {\n // The type check also rejects members inherited from `Object`.\n const suffix: unknown = propertySuffixes[value];\n\n if (typeof suffix === 'string') {\n return ` ${table.prefix}${suffix}`;\n }\n }\n\n if (isUnknownValueReported()) {\n logUnknownStyleValue(table, property, value, prop);\n }\n\n return '';\n};\n"],"mappings":";;;AAeA,IAAMA,UAAwC;CAC1C,IAAI;EACA,OAAA,QAAA,IAAA,aAAgC;CACpC,SAASC,GAAO;EACZ,IAAIC,EAA0BD,CAAK,GAC/B,OAAO;EAGX,MAAMA;CACV;AACJ,GAyBaE,KACT,GACA,GACA,GACA,MACS;CACT,IAAMC,IAAmBC,EAAM,SAASC;CAExC,IACIF,MAAqB,KAAA,MACpB,OAAOG,KAAU,YAAY,OAAOA,KAAU,WACjD;EAEE,IAAMC,IAAkBJ,EAAiBG;EAEzC,IAAI,OAAOC,KAAW,UAClB,OAAO,IAAIH,EAAM,SAASG;CAElC;CAMA,OAJIR,EAAuB,KACvBS,EAAqBJ,GAAOC,GAAUC,GAAOG,CAAI,GAG9C;AACX"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../../styles/style-props/styleProps.css.cjs"),t=require("./getTokenClassNames.utils.cjs"),n=require("./resolveSizeValue.utils.cjs");let r=require("@vanilla-extract/dynamic");var i=(i,a,o)=>{let s={},c,l=o===``?``:` ${o}`;for(let r in i)switch(r){case`as`:case`asChild`:case`className`:case`style`:break;case`width`:case`minWidth`:case`maxWidth`:case`height`:case`minHeight`:case`maxHeight`:{let t=i[r];t!==void 0&&a.get(r)!==null&&(c??={},c[e.stylePropsStyles.sizeVars[r]]=n.resolveSizeValue(t),l=`${l} ${e.stylePropsStyles.sizes[r]}`);break}case`backgroundColor`:case`borderColor`:case`color`:{let t=i[r];t!==void 0&&a.get(r)!==null&&(c??={},c[e.stylePropsStyles.colorVars[r]]=t,l=`${l} ${e.stylePropsStyles.colors[r]}`);break}default:{let e=a.get(r);e===void 0?s[r]=i[r]:e!==null&&(l+=t.getTokenClassNames(e,i,r))}}return i.className!==void 0&&i.className!==``&&(l=`${l} ${i.className}`),l!==``&&(s.className=l.slice(1)),c===void 0?i.style!==void 0&&(s.style=i.style):s.style=Object.assign((0,r.assignInlineVars)(c),i.style),s};exports.getElementProps=i;
|
|
2
|
+
//# sourceMappingURL=getElementProps.utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getElementProps.utils.cjs","names":["stylePropsStyles","resolveSizeValue","getTokenClassNames","assignInlineVars","require_styleProps_css","require_getTokenClassNames_utils","require_resolveSizeValue_utils","_vanilla_extract_dynamic","getElementProps","elementProps","variables","className","baseClassName","key","props","value","styleSet","table"],"sources":["../../../../../src/components/_common/utils/style-props/getElementProps.utils.ts"],"sourcesContent":["import { assignInlineVars } from '@vanilla-extract/dynamic';\n\nimport { stylePropsStyles } from '@primitives/components/_common/styles/style-props/styleProps.css';\nimport type {\n StyledProps,\n StyleSet,\n} from '@primitives/components/_common/types';\nimport { getTokenClassNames } from '@primitives/components/_common/utils/style-props/getTokenClassNames.utils';\nimport { resolveSizeValue } from '@primitives/components/_common/utils/style-props/resolveSizeValue.utils';\n\n/**\n * Turns the props of a styled component into the props of its element, in a\n * single pass: token style props become atomic classes, sizing and color\n * props each become a class reading a private CSS variable set inline, and\n * every other prop is forwarded as is. A sizing value that is a number\n * other than `0` becomes a length in pixels, as in `style`. `as`, `asChild`\n * and the style props are never forwarded. `className` only exists when a\n * class applies, and `style` only when the consumer provides one or a\n * sizing or color prop is set; consumer styles are kept and merged after\n * the variables, so they prevail. A token style prop given a value outside\n * its set adds no class; outside production, an error is logged to the\n * console. A style prop the style set marks as ignored, token, sizing or\n * color prop, adds neither class, variable nor attribute; an undefined one\n * adds nothing either.\n *\n * @param props Props received by the component, native ones included.\n * @param styleSet Token style props of the component and their class\n * tables, and the style props it ignores.\n * @param baseClassName Class of the component's default style, placed first;\n * an empty string without one.\n * @returns The props to spread on the rendered element.\n */\nexport const getElementProps = (\n props: StyledProps,\n styleSet: StyleSet,\n baseClassName: string,\n): Record<string, unknown> => {\n const elementProps: Record<string, unknown> = {};\n let variables: Record<string, string> | undefined;\n let className = baseClassName === '' ? '' : ` ${baseClassName}`;\n\n for (const key in props) {\n switch (key) {\n case 'as':\n case 'asChild':\n case 'className':\n case 'style': {\n break;\n }\n\n case 'width':\n case 'minWidth':\n case 'maxWidth':\n case 'height':\n case 'minHeight':\n case 'maxHeight': {\n const value = props[key];\n\n if (value !== undefined && styleSet.get(key) !== null) {\n variables ??= {};\n variables[stylePropsStyles.sizeVars[key]] =\n resolveSizeValue(value);\n className = `${className} ${stylePropsStyles.sizes[key]}`;\n }\n\n break;\n }\n\n case 'backgroundColor':\n case 'borderColor':\n case 'color': {\n const value = props[key];\n\n if (value !== undefined && styleSet.get(key) !== null) {\n variables ??= {};\n variables[stylePropsStyles.colorVars[key]] = value;\n className = `${className} ${stylePropsStyles.colors[key]}`;\n }\n\n break;\n }\n\n default: {\n const table = styleSet.get(key);\n\n if (table === undefined) {\n elementProps[key] = props[key];\n } else if (table !== null) {\n className += getTokenClassNames(table, props, key);\n }\n }\n }\n }\n\n if (props.className !== undefined && props.className !== '') {\n className = `${className} ${props.className}`;\n }\n\n if (className !== '') {\n elementProps.className = className.slice(1);\n }\n\n if (variables !== undefined) {\n // The consumer style comes last, so its properties, a variable\n // included, prevail.\n elementProps.style = Object.assign(\n assignInlineVars(variables),\n props.style,\n );\n } else if (props.style !== undefined) {\n elementProps.style = props.style;\n }\n\n return elementProps;\n};\n"],"mappings":"A,+LAgCA,IAAaQ,GACT,EACA,EACA,IAC0B,CAC1B,IAAMC,EAAwC,CAAC,EAC3CC,EACAC,EAAYC,IAAkB,GAAK,GAAK,IAAIA,IAEhD,IAAK,IAAMC,KAAOC,EACd,OAAQD,EAAR,CACI,IAAK,KACL,IAAK,UACL,IAAK,YACL,IAAK,QACD,MAGJ,IAAK,QACL,IAAK,WACL,IAAK,WACL,IAAK,SACL,IAAK,YACL,IAAK,YAAa,CACd,IAAME,EAAQD,EAAMD,GAEhBE,IAAU,IAAA,IAAaC,EAAS,IAAIH,CAAG,IAAM,OAC7C,IAAc,CAAC,EACf,EAAUb,EAAAA,iBAAiB,SAASa,IAChCZ,EAAAA,iBAAiBc,CAAK,EAC1B,EAAY,GAAGJ,EAAU,GAAGX,EAAAA,iBAAiB,MAAMa,MAGvD,KACJ,CAEA,IAAK,kBACL,IAAK,cACL,IAAK,QAAS,CACV,IAAME,EAAQD,EAAMD,GAEhBE,IAAU,IAAA,IAAaC,EAAS,IAAIH,CAAG,IAAM,OAC7C,IAAc,CAAC,EACf,EAAUb,EAAAA,iBAAiB,UAAUa,IAAQE,EAC7C,EAAY,GAAGJ,EAAU,GAAGX,EAAAA,iBAAiB,OAAOa,MAGxD,KACJ,CAEA,QAAS,CACL,IAAMI,EAAQD,EAAS,IAAIH,CAAG,EAE1BI,IAAU,IAAA,GACV,EAAaJ,GAAOC,EAAMD,GACnBI,IAAU,OACjB,GAAaf,EAAAA,mBAAmBe,EAAOH,EAAOD,CAAG,EAEzD,CACJ,CAsBJ,OAnBIC,EAAM,YAAc,IAAA,IAAaA,EAAM,YAAc,KACrD,EAAY,GAAGH,EAAU,GAAGG,EAAM,aAGlCH,IAAc,KACd,EAAa,UAAYA,EAAU,MAAM,CAAC,GAG1CD,IAAc,IAAA,GAOPI,EAAM,QAAU,IAAA,KACvB,EAAa,MAAQA,EAAM,OAL3B,EAAa,MAAQ,OAAO,QAAA,EACxBX,EAAAA,iBAAAA,CAAiBO,CAAS,EAC1BI,EAAM,KACV,EAKGL,CACX,E"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { stylePropsStyles as e } from "../../styles/style-props/styleProps.css.js";
|
|
2
|
+
import { getTokenClassNames as t } from "./getTokenClassNames.utils.js";
|
|
3
|
+
import { resolveSizeValue as n } from "./resolveSizeValue.utils.js";
|
|
4
|
+
import { assignInlineVars as r } from "@vanilla-extract/dynamic";
|
|
5
|
+
// src/components/_common/utils/style-props/getElementProps.utils.ts
|
|
6
|
+
var i = (i, a, o) => {
|
|
7
|
+
let s = {}, c, l = o === "" ? "" : ` ${o}`;
|
|
8
|
+
for (let r in i) switch (r) {
|
|
9
|
+
case "as":
|
|
10
|
+
case "asChild":
|
|
11
|
+
case "className":
|
|
12
|
+
case "style": break;
|
|
13
|
+
case "width":
|
|
14
|
+
case "minWidth":
|
|
15
|
+
case "maxWidth":
|
|
16
|
+
case "height":
|
|
17
|
+
case "minHeight":
|
|
18
|
+
case "maxHeight": {
|
|
19
|
+
let t = i[r];
|
|
20
|
+
t !== void 0 && a.get(r) !== null && (c ??= {}, c[e.sizeVars[r]] = n(t), l = `${l} ${e.sizes[r]}`);
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
case "backgroundColor":
|
|
24
|
+
case "borderColor":
|
|
25
|
+
case "color": {
|
|
26
|
+
let t = i[r];
|
|
27
|
+
t !== void 0 && a.get(r) !== null && (c ??= {}, c[e.colorVars[r]] = t, l = `${l} ${e.colors[r]}`);
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
default: {
|
|
31
|
+
let e = a.get(r);
|
|
32
|
+
e === void 0 ? s[r] = i[r] : e !== null && (l += t(e, i, r));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return i.className !== void 0 && i.className !== "" && (l = `${l} ${i.className}`), l !== "" && (s.className = l.slice(1)), c === void 0 ? i.style !== void 0 && (s.style = i.style) : s.style = Object.assign(r(c), i.style), s;
|
|
36
|
+
};
|
|
37
|
+
export { i as getElementProps };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=getElementProps.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getElementProps.utils.js","names":["getElementProps","elementProps","variables","className","baseClassName","key","props","value","styleSet","stylePropsStyles","resolveSizeValue","table","getTokenClassNames","assignInlineVars"],"sources":["../../../../../src/components/_common/utils/style-props/getElementProps.utils.ts"],"sourcesContent":["import { assignInlineVars } from '@vanilla-extract/dynamic';\n\nimport { stylePropsStyles } from '@primitives/components/_common/styles/style-props/styleProps.css';\nimport type {\n StyledProps,\n StyleSet,\n} from '@primitives/components/_common/types';\nimport { getTokenClassNames } from '@primitives/components/_common/utils/style-props/getTokenClassNames.utils';\nimport { resolveSizeValue } from '@primitives/components/_common/utils/style-props/resolveSizeValue.utils';\n\n/**\n * Turns the props of a styled component into the props of its element, in a\n * single pass: token style props become atomic classes, sizing and color\n * props each become a class reading a private CSS variable set inline, and\n * every other prop is forwarded as is. A sizing value that is a number\n * other than `0` becomes a length in pixels, as in `style`. `as`, `asChild`\n * and the style props are never forwarded. `className` only exists when a\n * class applies, and `style` only when the consumer provides one or a\n * sizing or color prop is set; consumer styles are kept and merged after\n * the variables, so they prevail. A token style prop given a value outside\n * its set adds no class; outside production, an error is logged to the\n * console. A style prop the style set marks as ignored, token, sizing or\n * color prop, adds neither class, variable nor attribute; an undefined one\n * adds nothing either.\n *\n * @param props Props received by the component, native ones included.\n * @param styleSet Token style props of the component and their class\n * tables, and the style props it ignores.\n * @param baseClassName Class of the component's default style, placed first;\n * an empty string without one.\n * @returns The props to spread on the rendered element.\n */\nexport const getElementProps = (\n props: StyledProps,\n styleSet: StyleSet,\n baseClassName: string,\n): Record<string, unknown> => {\n const elementProps: Record<string, unknown> = {};\n let variables: Record<string, string> | undefined;\n let className = baseClassName === '' ? '' : ` ${baseClassName}`;\n\n for (const key in props) {\n switch (key) {\n case 'as':\n case 'asChild':\n case 'className':\n case 'style': {\n break;\n }\n\n case 'width':\n case 'minWidth':\n case 'maxWidth':\n case 'height':\n case 'minHeight':\n case 'maxHeight': {\n const value = props[key];\n\n if (value !== undefined && styleSet.get(key) !== null) {\n variables ??= {};\n variables[stylePropsStyles.sizeVars[key]] =\n resolveSizeValue(value);\n className = `${className} ${stylePropsStyles.sizes[key]}`;\n }\n\n break;\n }\n\n case 'backgroundColor':\n case 'borderColor':\n case 'color': {\n const value = props[key];\n\n if (value !== undefined && styleSet.get(key) !== null) {\n variables ??= {};\n variables[stylePropsStyles.colorVars[key]] = value;\n className = `${className} ${stylePropsStyles.colors[key]}`;\n }\n\n break;\n }\n\n default: {\n const table = styleSet.get(key);\n\n if (table === undefined) {\n elementProps[key] = props[key];\n } else if (table !== null) {\n className += getTokenClassNames(table, props, key);\n }\n }\n }\n }\n\n if (props.className !== undefined && props.className !== '') {\n className = `${className} ${props.className}`;\n }\n\n if (className !== '') {\n elementProps.className = className.slice(1);\n }\n\n if (variables !== undefined) {\n // The consumer style comes last, so its properties, a variable\n // included, prevail.\n elementProps.style = Object.assign(\n assignInlineVars(variables),\n props.style,\n );\n } else if (props.style !== undefined) {\n elementProps.style = props.style;\n }\n\n return elementProps;\n};\n"],"mappings":";;;;;AAgCA,IAAaA,KACT,GACA,GACA,MAC0B;CAC1B,IAAMC,IAAwC,CAAC,GAC3CC,GACAC,IAAYC,MAAkB,KAAK,KAAK,IAAIA;CAEhD,KAAK,IAAMC,KAAOC,GACd,QAAQD,GAAR;EACI,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,SACD;EAGJ,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,aAAa;GACd,IAAME,IAAQD,EAAMD;GAEpB,AAAIE,MAAU,KAAA,KAAaC,EAAS,IAAIH,CAAG,MAAM,SAC7C,MAAc,CAAC,GACf,EAAUI,EAAiB,SAASJ,MAChCK,EAAiBH,CAAK,GAC1B,IAAY,GAAGJ,EAAU,GAAGM,EAAiB,MAAMJ;GAGvD;EACJ;EAEA,KAAK;EACL,KAAK;EACL,KAAK,SAAS;GACV,IAAME,IAAQD,EAAMD;GAEpB,AAAIE,MAAU,KAAA,KAAaC,EAAS,IAAIH,CAAG,MAAM,SAC7C,MAAc,CAAC,GACf,EAAUI,EAAiB,UAAUJ,MAAQE,GAC7C,IAAY,GAAGJ,EAAU,GAAGM,EAAiB,OAAOJ;GAGxD;EACJ;EAEA,SAAS;GACL,IAAMM,IAAQH,EAAS,IAAIH,CAAG;GAE9B,AAAIM,MAAU,KAAA,IACV,EAAaN,KAAOC,EAAMD,KACnBM,MAAU,SACjB,KAAaC,EAAmBD,GAAOL,GAAOD,CAAG;EAEzD;CACJ;CAsBJ,OAnBIC,EAAM,cAAc,KAAA,KAAaA,EAAM,cAAc,OACrD,IAAY,GAAGH,EAAU,GAAGG,EAAM,cAGlCH,MAAc,OACd,EAAa,YAAYA,EAAU,MAAM,CAAC,IAG1CD,MAAc,KAAA,IAOPI,EAAM,UAAU,KAAA,MACvB,EAAa,QAAQA,EAAM,SAL3B,EAAa,QAAQ,OAAO,OACxBO,EAAiBX,CAAS,GAC1BI,EAAM,KACV,GAKGL;AACX"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./getClassName.utils.cjs");var t=(t,n,r)=>{let i=n[r];if(i===void 0)return``;let a=t.shorthands[r];if(a===void 0)return e.getClassName(t,r,i,r);let o=``;for(let s of a){let a=s[0];for(let e of s)if(n[e]!==void 0){a=void 0;break}a!==void 0&&(o+=e.getClassName(t,a,i,r))}return o};exports.getTokenClassNames=t;
|
|
2
|
+
//# sourceMappingURL=getTokenClassNames.utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTokenClassNames.utils.cjs","names":["getClassName","require_getClassName_utils","getTokenClassNames","value","props","key","chains","table","classNames","chain","longhand","overridingProp"],"sources":["../../../../../src/components/_common/utils/style-props/getTokenClassNames.utils.ts"],"sourcesContent":["import type { ClassTable } from '@primitives/components/_common/types';\nimport { getClassName } from '@primitives/components/_common/utils/style-props/getClassName.utils';\n\n/**\n * Resolves one token style prop to its atomic classes, without allocating. A\n * longhand yields its class. A shorthand yields the class of each longhand it\n * sets, except those a more specific prop overrides: the longhand itself or a\n * later shorthand, whatever the order the props were written in. An\n * `undefined` value yields nothing and overrides nothing; a value outside\n * the set yields nothing either, and is reported outside production.\n *\n * @param table Class table holding the prop, as given by the style set.\n * @param props Props received by the component.\n * @param key Name of the prop to resolve, a longhand or a shorthand of the\n * table.\n * @returns The classes, each preceded by a space; an empty string when the\n * prop is undefined or fully overridden.\n */\nexport const getTokenClassNames = (\n table: ClassTable,\n props: Readonly<Record<string, unknown>>,\n key: string,\n): string => {\n const value = props[key];\n\n if (value === undefined) {\n return '';\n }\n\n const chains = table.shorthands[key];\n\n if (chains === undefined) {\n return getClassName(table, key, value, key);\n }\n\n let classNames = '';\n\n for (const chain of chains) {\n let longhand: string | undefined = chain[0];\n\n for (const overridingProp of chain) {\n if (props[overridingProp] !== undefined) {\n longhand = undefined;\n break;\n }\n }\n\n if (longhand !== undefined) {\n classNames += getClassName(table, longhand, value, key);\n }\n }\n\n return classNames;\n};\n"],"mappings":"A,4CAkBA,IAAaE,GACT,EACA,EACA,IACS,CACT,IAAMC,EAAQC,EAAMC,GAEpB,GAAIF,IAAU,IAAA,GACV,MAAO,GAGX,IAAMG,EAASC,EAAM,WAAWF,GAEhC,GAAIC,IAAW,IAAA,GACX,OAAON,EAAAA,aAAaO,EAAOF,EAAKF,EAAOE,CAAG,EAG9C,IAAIG,EAAa,GAEjB,IAAK,IAAMC,KAASH,EAAQ,CACxB,IAAII,EAA+BD,EAAM,GAEzC,IAAK,IAAME,KAAkBF,EACzB,GAAIL,EAAMO,KAAoB,IAAA,GAAW,CACrC,EAAW,IAAA,GACX,KACJ,CAGAD,IAAa,IAAA,KACb,GAAcV,EAAAA,aAAaO,EAAOG,EAAUP,EAAOE,CAAG,EAE9D,CAEA,OAAOG,CACX,E"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getClassName as e } from "./getClassName.utils.js";
|
|
2
|
+
// src/components/_common/utils/style-props/getTokenClassNames.utils.ts
|
|
3
|
+
var t = (t, n, r) => {
|
|
4
|
+
let i = n[r];
|
|
5
|
+
if (i === void 0) return "";
|
|
6
|
+
let a = t.shorthands[r];
|
|
7
|
+
if (a === void 0) return e(t, r, i, r);
|
|
8
|
+
let o = "";
|
|
9
|
+
for (let s of a) {
|
|
10
|
+
let a = s[0];
|
|
11
|
+
for (let e of s) if (n[e] !== void 0) {
|
|
12
|
+
a = void 0;
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
a !== void 0 && (o += e(t, a, i, r));
|
|
16
|
+
}
|
|
17
|
+
return o;
|
|
18
|
+
};
|
|
19
|
+
export { t as getTokenClassNames };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=getTokenClassNames.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTokenClassNames.utils.js","names":["getTokenClassNames","value","props","key","chains","table","getClassName","classNames","chain","longhand","overridingProp"],"sources":["../../../../../src/components/_common/utils/style-props/getTokenClassNames.utils.ts"],"sourcesContent":["import type { ClassTable } from '@primitives/components/_common/types';\nimport { getClassName } from '@primitives/components/_common/utils/style-props/getClassName.utils';\n\n/**\n * Resolves one token style prop to its atomic classes, without allocating. A\n * longhand yields its class. A shorthand yields the class of each longhand it\n * sets, except those a more specific prop overrides: the longhand itself or a\n * later shorthand, whatever the order the props were written in. An\n * `undefined` value yields nothing and overrides nothing; a value outside\n * the set yields nothing either, and is reported outside production.\n *\n * @param table Class table holding the prop, as given by the style set.\n * @param props Props received by the component.\n * @param key Name of the prop to resolve, a longhand or a shorthand of the\n * table.\n * @returns The classes, each preceded by a space; an empty string when the\n * prop is undefined or fully overridden.\n */\nexport const getTokenClassNames = (\n table: ClassTable,\n props: Readonly<Record<string, unknown>>,\n key: string,\n): string => {\n const value = props[key];\n\n if (value === undefined) {\n return '';\n }\n\n const chains = table.shorthands[key];\n\n if (chains === undefined) {\n return getClassName(table, key, value, key);\n }\n\n let classNames = '';\n\n for (const chain of chains) {\n let longhand: string | undefined = chain[0];\n\n for (const overridingProp of chain) {\n if (props[overridingProp] !== undefined) {\n longhand = undefined;\n break;\n }\n }\n\n if (longhand !== undefined) {\n classNames += getClassName(table, longhand, value, key);\n }\n }\n\n return classNames;\n};\n"],"mappings":";;AAkBA,IAAaA,KACT,GACA,GACA,MACS;CACT,IAAMC,IAAQC,EAAMC;CAEpB,IAAIF,MAAU,KAAA,GACV,OAAO;CAGX,IAAMG,IAASC,EAAM,WAAWF;CAEhC,IAAIC,MAAW,KAAA,GACX,OAAOE,EAAaD,GAAOF,GAAKF,GAAOE,CAAG;CAG9C,IAAII,IAAa;CAEjB,KAAK,IAAMC,KAASJ,GAAQ;EACxB,IAAIK,IAA+BD,EAAM;EAEzC,KAAK,IAAME,KAAkBF,GACzB,IAAIN,EAAMQ,OAAoB,KAAA,GAAW;GACrC,IAAW,KAAA;GACX;EACJ;EAGJ,AAAID,MAAa,KAAA,MACb,KAAcH,EAAaD,GAAOI,GAAUR,GAAOE,CAAG;CAE9D;CAEA,OAAOI;AACX"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./formatStyleValue.utils.cjs");var t=(t,n,r,i)=>{let a=t.suffixes[n],o=a===void 0?``:Object.keys(a).join(`, `);console.error(`Style prop "${i}" has no value ${e.formatStyleValue(r)}. Possible values are: ${o}.`)};exports.logUnknownStyleValue=t;
|
|
2
|
+
//# sourceMappingURL=logUnknownStyleValue.utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logUnknownStyleValue.utils.cjs","names":["formatStyleValue","require_formatStyleValue_utils","logUnknownStyleValue","propertySuffixes","table","property","values","prop","value"],"sources":["../../../../../src/components/_common/utils/style-props/logUnknownStyleValue.utils.ts"],"sourcesContent":["import type { ClassTable } from '@primitives/components/_common/types';\nimport { formatStyleValue } from '@primitives/components/_common/utils/style-props/formatStyleValue.utils';\n\n/**\n * Logs to the console that a style prop was given a value outside the set\n * of its property, naming the prop, the value and the possible values, so\n * the mistake shows without interrupting the render. Formatting the value\n * never throws, even for a `BigInt` or a circular structure.\n *\n * @param table Class table expected to hold the property.\n * @param property Longhand property the value was looked up for.\n * @param value Value given to the prop.\n * @param prop Prop the value was given to: the property itself or one of\n * its shorthands.\n */\nexport const logUnknownStyleValue = (\n table: ClassTable,\n property: string,\n value: unknown,\n prop: string,\n): void => {\n const propertySuffixes = table.suffixes[property];\n const values =\n propertySuffixes === undefined\n ? ''\n : Object.keys(propertySuffixes).join(', ');\n\n console.error(\n `Style prop \"${prop}\" has no value ${formatStyleValue(value)}. Possible values are: ${values}.`,\n );\n};\n"],"mappings":"A,gDAeA,IAAaE,GACT,EACA,EACA,EACA,IACO,CACP,IAAMC,EAAmBC,EAAM,SAASC,GAClCC,EACFH,IAAqB,IAAA,GACf,GACA,OAAO,KAAKA,CAAgB,CAAC,CAAC,KAAK,IAAI,EAEjD,QAAQ,MACJ,eAAeI,EAAK,iBAAiBP,EAAAA,iBAAiBQ,CAAK,EAAE,yBAAyBF,EAAO,EACjG,CACJ,E"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { formatStyleValue as e } from "./formatStyleValue.utils.js";
|
|
2
|
+
// src/components/_common/utils/style-props/logUnknownStyleValue.utils.ts
|
|
3
|
+
var t = (t, n, r, i) => {
|
|
4
|
+
let a = t.suffixes[n], o = a === void 0 ? "" : Object.keys(a).join(", ");
|
|
5
|
+
console.error(`Style prop "${i}" has no value ${e(r)}. Possible values are: ${o}.`);
|
|
6
|
+
};
|
|
7
|
+
export { t as logUnknownStyleValue };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=logUnknownStyleValue.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logUnknownStyleValue.utils.js","names":["logUnknownStyleValue","propertySuffixes","table","property","values","prop","formatStyleValue","value"],"sources":["../../../../../src/components/_common/utils/style-props/logUnknownStyleValue.utils.ts"],"sourcesContent":["import type { ClassTable } from '@primitives/components/_common/types';\nimport { formatStyleValue } from '@primitives/components/_common/utils/style-props/formatStyleValue.utils';\n\n/**\n * Logs to the console that a style prop was given a value outside the set\n * of its property, naming the prop, the value and the possible values, so\n * the mistake shows without interrupting the render. Formatting the value\n * never throws, even for a `BigInt` or a circular structure.\n *\n * @param table Class table expected to hold the property.\n * @param property Longhand property the value was looked up for.\n * @param value Value given to the prop.\n * @param prop Prop the value was given to: the property itself or one of\n * its shorthands.\n */\nexport const logUnknownStyleValue = (\n table: ClassTable,\n property: string,\n value: unknown,\n prop: string,\n): void => {\n const propertySuffixes = table.suffixes[property];\n const values =\n propertySuffixes === undefined\n ? ''\n : Object.keys(propertySuffixes).join(', ');\n\n console.error(\n `Style prop \"${prop}\" has no value ${formatStyleValue(value)}. Possible values are: ${values}.`,\n );\n};\n"],"mappings":";;AAeA,IAAaA,KACT,GACA,GACA,GACA,MACO;CACP,IAAMC,IAAmBC,EAAM,SAASC,IAClCC,IACFH,MAAqB,KAAA,IACf,KACA,OAAO,KAAKA,CAAgB,CAAC,CAAC,KAAK,IAAI;CAEjD,QAAQ,MACJ,eAAeI,EAAK,iBAAiBC,EAAiBC,CAAK,EAAE,yBAAyBH,EAAO,EACjG;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveSizeValue.utils.cjs","names":["resolveSizeValue","value"],"sources":["../../../../../src/components/_common/utils/style-props/resolveSizeValue.utils.ts"],"sourcesContent":["/**\n * Converts the value of a sizing prop into the CSS value its variable\n * carries, as React does for the same property in `style`: a number other\n * than `0` becomes a length in pixels, `0` stays unitless, and a string is\n * kept as given.\n *\n * @param value Value given to the sizing prop.\n * @returns The CSS value, such as `320px`, `0` or `calc(100% - 2rem)`.\n */\nexport const resolveSizeValue = (value: string | number): string =>\n typeof value === 'number' && value !== 0 ? `${value}px` : String(value);\n"],"mappings":"AASA,IAAaA,EAAoB,GAC7B,OAAOC,GAAU,UAAYA,IAAU,EAAI,GAAGA,EAAM,IAAM,OAAOA,CAAK,E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveSizeValue.utils.js","names":["resolveSizeValue","value"],"sources":["../../../../../src/components/_common/utils/style-props/resolveSizeValue.utils.ts"],"sourcesContent":["/**\n * Converts the value of a sizing prop into the CSS value its variable\n * carries, as React does for the same property in `style`: a number other\n * than `0` becomes a length in pixels, `0` stays unitless, and a string is\n * kept as given.\n *\n * @param value Value given to the sizing prop.\n * @returns The CSS value, such as `320px`, `0` or `calc(100% - 2rem)`.\n */\nexport const resolveSizeValue = (value: string | number): string =>\n typeof value === 'number' && value !== 0 ? `${value}px` : String(value);\n"],"mappings":";AASA,IAAaA,KAAoB,MAC7B,OAAOC,KAAU,YAAYA,MAAU,IAAI,GAAGA,EAAM,MAAM,OAAOA,CAAK"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../../_common/components/slot/Slot.cjs"),t=require("./utils/getVisuallyHiddenElementProps.utils.cjs");let n=require("react/jsx-runtime");var r=r=>{let i=r.asChild===!0?e.default:r.as??`span`;return(0,n.jsx)(i,{...t.getVisuallyHiddenElementProps(r)})};exports.default=r;
|
|
2
|
+
//# sourceMappingURL=VisuallyHidden.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VisuallyHidden.cjs","names":["Slot","getVisuallyHiddenElementProps","require_Slot","require_getVisuallyHiddenElementProps_utils","react_jsx_runtime","VisuallyHidden","Element","props"],"sources":["../../../../src/components/accessibility/visually-hidden/VisuallyHidden.tsx"],"sourcesContent":["import type { ElementType, ReactElement } from 'react';\n\nimport { Slot } from '@primitives/components/_common/components/slot';\nimport type {\n VisuallyHiddenAsChildProps,\n VisuallyHiddenProps,\n VisuallyHiddenTag,\n} from '@primitives/components/accessibility/visually-hidden/types';\nimport { getVisuallyHiddenElementProps } from '@primitives/components/accessibility/visually-hidden/utils/getVisuallyHiddenElementProps.utils';\n\n/**\n * Hides its content from the screen while keeping it in the accessibility\n * tree, so screen readers still announce it: a skip link, the end of a\n * visible text that an `aria-label` would replace, a heading that\n * structures a page without being displayed, or the label of a field. A\n * button that only shows an icon needs none: an `aria-label` names it. It\n * renders any HTML tag, a `span` by default, out of the flow, one pixel\n * wide and clipped to nothing. The hiding styles sit in the base cascade\n * layer.\n *\n * With `focusable`, the element shows again while it or one of its\n * descendants has the focus, with the styles its own classes give it: a\n * \"Skip to content\" link appears when reached with the keyboard. It does not\n * make the element focusable: render a focusable element, such as a link, or\n * wrap one.\n *\n * It takes no style props. Every other prop (attributes, events, `ref`) is\n * typed after the tag and forwarded to the element; the consumer's\n * `className` follows the hiding class, and `style` is kept as given. With\n * `asChild`, nothing is rendered of its own: the single child is, with the\n * hiding class, other props and `ref` merged onto it (see `AsChildProps`),\n * for instance a router link used as a skip link.\n *\n * @param props `focusable`, `as` or `asChild`, and the native props of the\n * rendered tag.\n * @returns The visually hidden element.\n * @throws {Error} With `asChild`, when the children are not a single\n * element.\n */\nconst VisuallyHidden = <Tag extends VisuallyHiddenTag = 'span'>(\n props: VisuallyHiddenProps<Tag> | VisuallyHiddenAsChildProps,\n): ReactElement => {\n const Element: ElementType =\n props.asChild === true ? Slot : (props.as ?? 'span');\n\n return <Element {...getVisuallyHiddenElementProps(props)} />;\n};\n\nexport default VisuallyHidden;\n"],"mappings":"A,0JAuCA,IAAMK,EACF,GACe,CACf,IAAMC,EACFC,EAAM,UAAY,GAAOP,EAAAA,QAAQO,EAAM,IAAM,OAEjD,OAAO,EAAAH,EAAA,IAAA,CAACE,EAAD,CAAS,GAAIL,EAAAA,8BAA8BM,CAAK,CAAI,CAAA,CAC/D,E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VisuallyHidden.css.cjs","names":["visuallyHiddenStyles"],"sources":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VisuallyHidden.css.js","names":["visuallyHiddenStyles"],"sources":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import e from "../../_common/components/slot/Slot.js";
|
|
2
|
+
import { getVisuallyHiddenElementProps as t } from "./utils/getVisuallyHiddenElementProps.utils.js";
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
// src/components/accessibility/visually-hidden/VisuallyHidden.tsx
|
|
5
|
+
var r = (r) => {
|
|
6
|
+
let i = r.asChild === !0 ? e : r.as ?? "span";
|
|
7
|
+
return /* @__PURE__ */ n(i, { ...t(r) });
|
|
8
|
+
};
|
|
9
|
+
export { r as default };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=VisuallyHidden.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VisuallyHidden.js","names":["Slot","VisuallyHidden","Element","props","getVisuallyHiddenElementProps"],"sources":["../../../../src/components/accessibility/visually-hidden/VisuallyHidden.tsx"],"sourcesContent":["import type { ElementType, ReactElement } from 'react';\n\nimport { Slot } from '@primitives/components/_common/components/slot';\nimport type {\n VisuallyHiddenAsChildProps,\n VisuallyHiddenProps,\n VisuallyHiddenTag,\n} from '@primitives/components/accessibility/visually-hidden/types';\nimport { getVisuallyHiddenElementProps } from '@primitives/components/accessibility/visually-hidden/utils/getVisuallyHiddenElementProps.utils';\n\n/**\n * Hides its content from the screen while keeping it in the accessibility\n * tree, so screen readers still announce it: a skip link, the end of a\n * visible text that an `aria-label` would replace, a heading that\n * structures a page without being displayed, or the label of a field. A\n * button that only shows an icon needs none: an `aria-label` names it. It\n * renders any HTML tag, a `span` by default, out of the flow, one pixel\n * wide and clipped to nothing. The hiding styles sit in the base cascade\n * layer.\n *\n * With `focusable`, the element shows again while it or one of its\n * descendants has the focus, with the styles its own classes give it: a\n * \"Skip to content\" link appears when reached with the keyboard. It does not\n * make the element focusable: render a focusable element, such as a link, or\n * wrap one.\n *\n * It takes no style props. Every other prop (attributes, events, `ref`) is\n * typed after the tag and forwarded to the element; the consumer's\n * `className` follows the hiding class, and `style` is kept as given. With\n * `asChild`, nothing is rendered of its own: the single child is, with the\n * hiding class, other props and `ref` merged onto it (see `AsChildProps`),\n * for instance a router link used as a skip link.\n *\n * @param props `focusable`, `as` or `asChild`, and the native props of the\n * rendered tag.\n * @returns The visually hidden element.\n * @throws {Error} With `asChild`, when the children are not a single\n * element.\n */\nconst VisuallyHidden = <Tag extends VisuallyHiddenTag = 'span'>(\n props: VisuallyHiddenProps<Tag> | VisuallyHiddenAsChildProps,\n): ReactElement => {\n const Element: ElementType =\n props.asChild === true ? Slot : (props.as ?? 'span');\n\n return <Element {...getVisuallyHiddenElementProps(props)} />;\n};\n\nexport default VisuallyHidden;\n"],"mappings":";;;;AAuCA,IAAMC,KACF,MACe;CACf,IAAMC,IACFC,EAAM,YAAY,KAAOH,IAAQG,EAAM,MAAM;CAEjD,OAAO,kBAACD,GAAD,EAAS,GAAIE,EAA8BD,CAAK,EAAI,CAAA;AAC/D"}
|
package/dist/components/accessibility/visually-hidden/utils/getVisuallyHiddenElementProps.utils.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../VisuallyHidden.css.cjs");var t=t=>{let n={};for(let e in t)switch(e){case`as`:case`asChild`:case`className`:case`focusable`:break;default:n[e]=t[e]}let r=t.focusable===!0?e.visuallyHiddenStyles.focusable:e.visuallyHiddenStyles.hidden;return n.className=t.className===void 0||t.className===``?r:`${r} ${t.className}`,n};exports.getVisuallyHiddenElementProps=t;
|
|
2
|
+
//# sourceMappingURL=getVisuallyHiddenElementProps.utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getVisuallyHiddenElementProps.utils.cjs","names":["visuallyHiddenStyles","require_VisuallyHidden_css","getVisuallyHiddenElementProps","elementProps","key","props","hidingClassName"],"sources":["../../../../../src/components/accessibility/visually-hidden/utils/getVisuallyHiddenElementProps.utils.ts"],"sourcesContent":["import type { VisuallyHiddenOwnProps } from '@primitives/components/accessibility/visually-hidden/types';\nimport { visuallyHiddenStyles } from '@primitives/components/accessibility/visually-hidden/VisuallyHidden.css';\n\n/**\n * Turns the props of a `VisuallyHidden` into the props of its element, in a\n * single pass: the hiding class comes first, followed by the consumer's\n * `className`; `as`, `asChild` and `focusable` are dropped and every other\n * prop, `style` included, is forwarded as is. No prop is read as a style\n * prop.\n *\n * @param props Props received by the `VisuallyHidden`, native ones\n * included.\n * @param props.focusable Whether the element shows while it or a\n * descendant has the focus; always hidden when absent.\n * @param props.className Classes added after the hiding class.\n * @returns The props to spread on the rendered element.\n */\nexport const getVisuallyHiddenElementProps = (\n props: VisuallyHiddenOwnProps & Readonly<Record<string, unknown>>,\n): Record<string, unknown> => {\n const elementProps: Record<string, unknown> = {};\n\n for (const key in props) {\n switch (key) {\n case 'as':\n case 'asChild':\n case 'className':\n case 'focusable': {\n break;\n }\n\n default: {\n elementProps[key] = props[key];\n }\n }\n }\n\n const hidingClassName =\n props.focusable === true\n ? visuallyHiddenStyles.focusable\n : visuallyHiddenStyles.hidden;\n\n elementProps.className =\n props.className === undefined || props.className === ''\n ? hidingClassName\n : `${hidingClassName} ${props.className}`;\n\n return elementProps;\n};\n"],"mappings":"A,6CAiBA,IAAaE,EACT,GAC0B,CAC1B,IAAMC,EAAwC,CAAC,EAE/C,IAAK,IAAMC,KAAOC,EACd,OAAQD,EAAR,CACI,IAAK,KACL,IAAK,UACL,IAAK,YACL,IAAK,YACD,MAGJ,QACI,EAAaA,GAAOC,EAAMD,EAElC,CAGJ,IAAME,EACFD,EAAM,YAAc,GACdL,EAAAA,qBAAqB,UACrBA,EAAAA,qBAAqB,OAO/B,MALA,GAAa,UACTK,EAAM,YAAc,IAAA,IAAaA,EAAM,YAAc,GAC/CC,EACA,GAAGA,EAAgB,GAAGD,EAAM,YAE/BF,CACX,E"}
|
package/dist/components/accessibility/visually-hidden/utils/getVisuallyHiddenElementProps.utils.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { visuallyHiddenStyles as e } from "../VisuallyHidden.css.js";
|
|
2
|
+
// src/components/accessibility/visually-hidden/utils/getVisuallyHiddenElementProps.utils.ts
|
|
3
|
+
var t = (t) => {
|
|
4
|
+
let n = {};
|
|
5
|
+
for (let e in t) switch (e) {
|
|
6
|
+
case "as":
|
|
7
|
+
case "asChild":
|
|
8
|
+
case "className":
|
|
9
|
+
case "focusable": break;
|
|
10
|
+
default: n[e] = t[e];
|
|
11
|
+
}
|
|
12
|
+
let r = t.focusable === !0 ? e.focusable : e.hidden;
|
|
13
|
+
return n.className = t.className === void 0 || t.className === "" ? r : `${r} ${t.className}`, n;
|
|
14
|
+
};
|
|
15
|
+
export { t as getVisuallyHiddenElementProps };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=getVisuallyHiddenElementProps.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getVisuallyHiddenElementProps.utils.js","names":["getVisuallyHiddenElementProps","elementProps","key","props","hidingClassName","visuallyHiddenStyles"],"sources":["../../../../../src/components/accessibility/visually-hidden/utils/getVisuallyHiddenElementProps.utils.ts"],"sourcesContent":["import type { VisuallyHiddenOwnProps } from '@primitives/components/accessibility/visually-hidden/types';\nimport { visuallyHiddenStyles } from '@primitives/components/accessibility/visually-hidden/VisuallyHidden.css';\n\n/**\n * Turns the props of a `VisuallyHidden` into the props of its element, in a\n * single pass: the hiding class comes first, followed by the consumer's\n * `className`; `as`, `asChild` and `focusable` are dropped and every other\n * prop, `style` included, is forwarded as is. No prop is read as a style\n * prop.\n *\n * @param props Props received by the `VisuallyHidden`, native ones\n * included.\n * @param props.focusable Whether the element shows while it or a\n * descendant has the focus; always hidden when absent.\n * @param props.className Classes added after the hiding class.\n * @returns The props to spread on the rendered element.\n */\nexport const getVisuallyHiddenElementProps = (\n props: VisuallyHiddenOwnProps & Readonly<Record<string, unknown>>,\n): Record<string, unknown> => {\n const elementProps: Record<string, unknown> = {};\n\n for (const key in props) {\n switch (key) {\n case 'as':\n case 'asChild':\n case 'className':\n case 'focusable': {\n break;\n }\n\n default: {\n elementProps[key] = props[key];\n }\n }\n }\n\n const hidingClassName =\n props.focusable === true\n ? visuallyHiddenStyles.focusable\n : visuallyHiddenStyles.hidden;\n\n elementProps.className =\n props.className === undefined || props.className === ''\n ? hidingClassName\n : `${hidingClassName} ${props.className}`;\n\n return elementProps;\n};\n"],"mappings":";;AAiBA,IAAaA,KACT,MAC0B;CAC1B,IAAMC,IAAwC,CAAC;CAE/C,KAAK,IAAMC,KAAOC,GACd,QAAQD,GAAR;EACI,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,aACD;EAGJ,SACI,EAAaA,KAAOC,EAAMD;CAElC;CAGJ,IAAME,IACFD,EAAM,cAAc,KACdE,EAAqB,YACrBA,EAAqB;CAO/B,OALA,EAAa,YACTF,EAAM,cAAc,KAAA,KAAaA,EAAM,cAAc,KAC/CC,IACA,GAAGA,EAAgB,GAAGD,EAAM,aAE/BF;AACX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Icon.cjs","names":["Element","getIconElementProps","require_getIconElementProps_utils","react_jsx_runtime","_iconify_react_offline","Icon","props"],"sources":["../../../../src/components/foundation/icon/Icon.tsx"],"sourcesContent":["import { Icon as OfflineIcon } from '@iconify/react/offline';\nimport type { ElementType, FC } from 'react';\n\nimport type { IconProps } from '@primitives/components/foundation/icon/types';\nimport { getIconElementProps } from '@primitives/components/foundation/icon/utils/getIconElementProps.utils';\n\n/**\n * Displays trusted local Iconify data as an SVG using `@iconify/react/offline`,\n * with a font size token, CSS sizes and CSS colors. Icons are decorative\n * unless given an accessible name.\n *\n * The icon draws the data given through `icon`, never fetched: the library\n * ships no icon set, so consumers keep their own registry of `IconData` and\n * pass its entries. The body is inserted as markup, so the data must come\n * from a trusted source, never from user input.\n *\n * Without size props, the icon is `1em` high, follows the font size of its\n * context, and its width follows the ratio of its data. `size` sets the\n * font size of the icon to a font size token of the theme, such as `24` for\n * `1.5rem`: both axes scale with it and the ratio is kept. `width` and `height` take any CSS value, as on\n * `Box`, and replace the default size on their axis, `size` included; the\n * other axis keeps its default, computed from the font size, and the\n * drawing keeps its ratio, centered in the box. `100%` fills the container\n * on that axis; `auto` and the content keywords come back to the default\n * size. The icon draws with `currentColor`: it inherits the text color, and\n * `color`, which accepts any CSS value, overrides it.\n *\n * The style props of `Box` apply to the `svg` box, with the same values and\n * classes, except those of flex and grid containers: `backgroundColor`,\n * `borderColor`, borders, radii, padding and shadow draw a badge around the\n * drawing. The box is `content-box` by default: padding and borders add to\n * the size, and with `boxSizing={'border-box'}` they shrink the drawing\n * instead. The drawing is not clipped by rounded corners unless `overflow`\n * says so, and the icon does not shrink in a flex row unless `flexShrink`\n * says so.\n *\n * A non-empty `aria-label` or `aria-labelledby` makes the icon an image\n * (`role=\"img\"`) announced by that name. Otherwise it is decorative: hidden\n * from assistive technologies, without role and not focusable. Every other\n * prop (attributes, events, `ref`) is forwarded to the `svg` element, and\n * the consumer's `className` and `style` are merged with the generated ones.\n *\n * @param props Icon data, style props and native props of the `svg`.\n * @param props.icon Data of the icon to draw.\n * @returns The icon as an inline SVG.\n */\nconst Icon: FC<IconProps> = (props) => {\n // The props are checked by `IconProps`; the Iconify component receives\n // them resolved, the `null` role that removes its default one included.\n const Element: ElementType = OfflineIcon;\n\n return <Element {...getIconElementProps(props)} />;\n};\n\nexport default Icon;\n"],"mappings":"A,gIA8CA,IAAMK,EAAuB,IAKlB,EAAAF,EAAA,IAAA,CAACH,EAAAA,KAAD,CAAS,GAAIC,EAAAA,oBAAoBK,CAAK,CAAI,CAAA,E"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* empty css */;/* empty css */var e={base:`kiviqn0`,sizeClassTable:{prefix:`kiviqn`,suffixes:{size:{10:`1`,12:`2`,14:`3`,16:`4`,18:`5`,20:`6`,24:`7`,28:`8`,32:`9`,36:`a`,40:`b`,48:`c`,60:`d`,72:`e`}},shorthands:{}}};exports.iconStyles=e;
|
|
2
|
+
//# sourceMappingURL=Icon.css.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Icon.css.cjs","names":["iconStyles"],"sources":[],"mappings":""}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* empty css */
|
|
2
|
+
/* empty css */
|
|
3
|
+
// src/components/foundation/icon/Icon.css.ts
|
|
4
|
+
var e = {
|
|
5
|
+
base: "kiviqn0",
|
|
6
|
+
sizeClassTable: {
|
|
7
|
+
prefix: "kiviqn",
|
|
8
|
+
suffixes: { size: {
|
|
9
|
+
10: "1",
|
|
10
|
+
12: "2",
|
|
11
|
+
14: "3",
|
|
12
|
+
16: "4",
|
|
13
|
+
18: "5",
|
|
14
|
+
20: "6",
|
|
15
|
+
24: "7",
|
|
16
|
+
28: "8",
|
|
17
|
+
32: "9",
|
|
18
|
+
36: "a",
|
|
19
|
+
40: "b",
|
|
20
|
+
48: "c",
|
|
21
|
+
60: "d",
|
|
22
|
+
72: "e"
|
|
23
|
+
} },
|
|
24
|
+
shorthands: {}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
export { e as iconStyles };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=Icon.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Icon.css.js","names":["iconStyles"],"sources":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { getIconElementProps as e } from "./utils/getIconElementProps.utils.js";
|
|
2
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
3
|
+
import { Icon as n } from "@iconify/react/offline";
|
|
4
|
+
// src/components/foundation/icon/Icon.tsx
|
|
5
|
+
var r = (r) => /* @__PURE__ */ t(n, { ...e(r) });
|
|
6
|
+
export { r as default };
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=Icon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Icon.js","names":["Icon","Element","Icon$1","Icon","getIconElementProps","props"],"sources":["../../../../src/components/foundation/icon/Icon.tsx"],"sourcesContent":["import { Icon as OfflineIcon } from '@iconify/react/offline';\nimport type { ElementType, FC } from 'react';\n\nimport type { IconProps } from '@primitives/components/foundation/icon/types';\nimport { getIconElementProps } from '@primitives/components/foundation/icon/utils/getIconElementProps.utils';\n\n/**\n * Displays trusted local Iconify data as an SVG using `@iconify/react/offline`,\n * with a font size token, CSS sizes and CSS colors. Icons are decorative\n * unless given an accessible name.\n *\n * The icon draws the data given through `icon`, never fetched: the library\n * ships no icon set, so consumers keep their own registry of `IconData` and\n * pass its entries. The body is inserted as markup, so the data must come\n * from a trusted source, never from user input.\n *\n * Without size props, the icon is `1em` high, follows the font size of its\n * context, and its width follows the ratio of its data. `size` sets the\n * font size of the icon to a font size token of the theme, such as `24` for\n * `1.5rem`: both axes scale with it and the ratio is kept. `width` and `height` take any CSS value, as on\n * `Box`, and replace the default size on their axis, `size` included; the\n * other axis keeps its default, computed from the font size, and the\n * drawing keeps its ratio, centered in the box. `100%` fills the container\n * on that axis; `auto` and the content keywords come back to the default\n * size. The icon draws with `currentColor`: it inherits the text color, and\n * `color`, which accepts any CSS value, overrides it.\n *\n * The style props of `Box` apply to the `svg` box, with the same values and\n * classes, except those of flex and grid containers: `backgroundColor`,\n * `borderColor`, borders, radii, padding and shadow draw a badge around the\n * drawing. The box is `content-box` by default: padding and borders add to\n * the size, and with `boxSizing={'border-box'}` they shrink the drawing\n * instead. The drawing is not clipped by rounded corners unless `overflow`\n * says so, and the icon does not shrink in a flex row unless `flexShrink`\n * says so.\n *\n * A non-empty `aria-label` or `aria-labelledby` makes the icon an image\n * (`role=\"img\"`) announced by that name. Otherwise it is decorative: hidden\n * from assistive technologies, without role and not focusable. Every other\n * prop (attributes, events, `ref`) is forwarded to the `svg` element, and\n * the consumer's `className` and `style` are merged with the generated ones.\n *\n * @param props Icon data, style props and native props of the `svg`.\n * @param props.icon Data of the icon to draw.\n * @returns The icon as an inline SVG.\n */\nconst Icon: FC<IconProps> = (props) => {\n // The props are checked by `IconProps`; the Iconify component receives\n // them resolved, the `null` role that removes its default one included.\n const Element: ElementType = OfflineIcon;\n\n return <Element {...getIconElementProps(props)} />;\n};\n\nexport default Icon;\n"],"mappings":";;;;AA8CA,IAAMA,KAAuB,MAKlB,kBAACC,GAAD,EAAS,GAAIG,EAAoBC,CAAK,EAAI,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../../../_common/styles/style-props/styleProps.css.cjs"),t=require("../../../_common/utils/style-props/createStyleSet.utils.cjs"),n=require("../../../_common/utils/style-props/getElementProps.utils.cjs"),r=require("../Icon.css.cjs"),i=require("../../../layout/box/Box.css.cjs");var a=t.createStyleSet([e.stylePropsStyles.classTable,i.boxStyles.classTable,r.iconStyles.sizeClassTable]),o=e=>{let t=n.getElementProps(e,a,r.iconStyles.base),i=e[`aria-label`],o=e[`aria-labelledby`];return typeof i==`string`&&i!==``||typeof o==`string`&&o!==``?{...t,"aria-hidden":!1,role:`img`}:{...t,"aria-hidden":!0,focusable:`false`,role:null}};exports.getIconElementProps=o;
|
|
2
|
+
//# sourceMappingURL=getIconElementProps.utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getIconElementProps.utils.cjs","names":["createStyleSet","stylePropsStyles","boxStyles","iconStyles","getElementProps","require_styleProps_css","require_createStyleSet_utils","require_getElementProps_utils","require_Icon_css","require_Box_css","iconStyleSet","getIconElementProps","elementProps","props","label","labelledBy"],"sources":["../../../../../src/components/foundation/icon/utils/getIconElementProps.utils.ts"],"sourcesContent":["import { stylePropsStyles } from '@primitives/components/_common/styles/style-props/styleProps.css';\nimport type { StyledProps } from '@primitives/components/_common/types';\nimport { createStyleSet } from '@primitives/components/_common/utils/style-props/createStyleSet.utils';\nimport { getElementProps } from '@primitives/components/_common/utils/style-props/getElementProps.utils';\nimport { iconStyles } from '@primitives/components/foundation/icon/Icon.css';\nimport type { IconOwnProps } from '@primitives/components/foundation/icon/types';\nimport { boxStyles } from '@primitives/components/layout/box/Box.css';\n\nconst iconStyleSet = createStyleSet([\n stylePropsStyles.classTable,\n boxStyles.classTable,\n iconStyles.sizeClassTable,\n]);\n\n/**\n * Turns the props of an `Icon` into the props of the Iconify icon it\n * renders, in a single pass: the default class comes first, style props\n * become the classes of `Box`, sizing and color props become variables set\n * inline, `size` becomes a font size class, and `icon` and every native\n * prop are forwarded as is. The icon being `1em` high, `size` scales it\n * without setting `width` or `height`, which keep their own variables.\n *\n * The accessibility attributes follow the name: a non-empty `aria-label` or\n * `aria-labelledby` makes the icon an image (`role=\"img\"`, not hidden);\n * otherwise it is decorative (`aria-hidden=\"true\"`, `focusable=\"false\"` and\n * a `null` role, which removes the default role of Iconify).\n *\n * @param props Props received by the `Icon`, native ones included.\n * @param props.size Font size token of the icon, which sets its `1em`\n * height; a value outside the tokens adds no class and, outside production,\n * logs an error to the console. No font size is set when absent.\n * @returns The props to spread on the Iconify icon.\n */\nexport const getIconElementProps = (\n props: IconOwnProps & StyledProps,\n): Record<string, unknown> => {\n const elementProps = getElementProps(props, iconStyleSet, iconStyles.base);\n\n const label = props['aria-label'];\n const labelledBy = props['aria-labelledby'];\n const hasName =\n (typeof label === 'string' && label !== '') ||\n (typeof labelledBy === 'string' && labelledBy !== '');\n\n return hasName\n ? { ...elementProps, 'aria-hidden': false, role: 'img' }\n : {\n ...elementProps,\n 'aria-hidden': true,\n focusable: 'false',\n role: null,\n };\n};\n"],"mappings":"A,uSAQA,IAAMU,EAAeV,EAAAA,eAAe,CAChCC,EAAAA,iBAAiB,WACjBC,EAAAA,UAAU,WACVC,EAAAA,WAAW,cACf,CAAC,EAqBYQ,EACT,GAC0B,CAC1B,IAAMC,EAAeR,EAAAA,gBAAgBS,EAAOH,EAAcP,EAAAA,WAAW,IAAI,EAEnEW,EAAQD,EAAM,cACdE,EAAaF,EAAM,mBAKzB,OAHK,OAAOC,GAAU,UAAYA,IAAU,IACvC,OAAOC,GAAe,UAAYA,IAAe,GAGhD,CAAE,GAAGH,EAAc,cAAe,GAAO,KAAM,KAAM,EACrD,CACI,GAAGA,EACH,cAAe,GACf,UAAW,QACX,KAAM,IACV,CACV,E"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { stylePropsStyles as e } from "../../../_common/styles/style-props/styleProps.css.js";
|
|
2
|
+
import { createStyleSet as t } from "../../../_common/utils/style-props/createStyleSet.utils.js";
|
|
3
|
+
import { getElementProps as n } from "../../../_common/utils/style-props/getElementProps.utils.js";
|
|
4
|
+
import { iconStyles as r } from "../Icon.css.js";
|
|
5
|
+
import { boxStyles as i } from "../../../layout/box/Box.css.js";
|
|
6
|
+
// src/components/foundation/icon/utils/getIconElementProps.utils.ts
|
|
7
|
+
var a = t([
|
|
8
|
+
e.classTable,
|
|
9
|
+
i.classTable,
|
|
10
|
+
r.sizeClassTable
|
|
11
|
+
]), o = (e) => {
|
|
12
|
+
let t = n(e, a, r.base), i = e["aria-label"], o = e["aria-labelledby"];
|
|
13
|
+
return typeof i == "string" && i !== "" || typeof o == "string" && o !== "" ? {
|
|
14
|
+
...t,
|
|
15
|
+
"aria-hidden": !1,
|
|
16
|
+
role: "img"
|
|
17
|
+
} : {
|
|
18
|
+
...t,
|
|
19
|
+
"aria-hidden": !0,
|
|
20
|
+
focusable: "false",
|
|
21
|
+
role: null
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export { o as getIconElementProps };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=getIconElementProps.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getIconElementProps.utils.js","names":["iconStyleSet","createStyleSet","stylePropsStyles","boxStyles","iconStyles","getIconElementProps","elementProps","getElementProps","props","label","labelledBy"],"sources":["../../../../../src/components/foundation/icon/utils/getIconElementProps.utils.ts"],"sourcesContent":["import { stylePropsStyles } from '@primitives/components/_common/styles/style-props/styleProps.css';\nimport type { StyledProps } from '@primitives/components/_common/types';\nimport { createStyleSet } from '@primitives/components/_common/utils/style-props/createStyleSet.utils';\nimport { getElementProps } from '@primitives/components/_common/utils/style-props/getElementProps.utils';\nimport { iconStyles } from '@primitives/components/foundation/icon/Icon.css';\nimport type { IconOwnProps } from '@primitives/components/foundation/icon/types';\nimport { boxStyles } from '@primitives/components/layout/box/Box.css';\n\nconst iconStyleSet = createStyleSet([\n stylePropsStyles.classTable,\n boxStyles.classTable,\n iconStyles.sizeClassTable,\n]);\n\n/**\n * Turns the props of an `Icon` into the props of the Iconify icon it\n * renders, in a single pass: the default class comes first, style props\n * become the classes of `Box`, sizing and color props become variables set\n * inline, `size` becomes a font size class, and `icon` and every native\n * prop are forwarded as is. The icon being `1em` high, `size` scales it\n * without setting `width` or `height`, which keep their own variables.\n *\n * The accessibility attributes follow the name: a non-empty `aria-label` or\n * `aria-labelledby` makes the icon an image (`role=\"img\"`, not hidden);\n * otherwise it is decorative (`aria-hidden=\"true\"`, `focusable=\"false\"` and\n * a `null` role, which removes the default role of Iconify).\n *\n * @param props Props received by the `Icon`, native ones included.\n * @param props.size Font size token of the icon, which sets its `1em`\n * height; a value outside the tokens adds no class and, outside production,\n * logs an error to the console. No font size is set when absent.\n * @returns The props to spread on the Iconify icon.\n */\nexport const getIconElementProps = (\n props: IconOwnProps & StyledProps,\n): Record<string, unknown> => {\n const elementProps = getElementProps(props, iconStyleSet, iconStyles.base);\n\n const label = props['aria-label'];\n const labelledBy = props['aria-labelledby'];\n const hasName =\n (typeof label === 'string' && label !== '') ||\n (typeof labelledBy === 'string' && labelledBy !== '');\n\n return hasName\n ? { ...elementProps, 'aria-hidden': false, role: 'img' }\n : {\n ...elementProps,\n 'aria-hidden': true,\n focusable: 'false',\n role: null,\n };\n};\n"],"mappings":";;;;;;AAQA,IAAMA,IAAeC,EAAe;CAChCC,EAAiB;CACjBC,EAAU;CACVC,EAAW;AACf,CAAC,GAqBYC,KACT,MAC0B;CAC1B,IAAMC,IAAeC,EAAgBC,GAAOR,GAAcI,EAAW,IAAI,GAEnEK,IAAQD,EAAM,eACdE,IAAaF,EAAM;CAKzB,OAHK,OAAOC,KAAU,YAAYA,MAAU,MACvC,OAAOC,KAAe,YAAYA,MAAe,KAGhD;EAAE,GAAGJ;EAAc,eAAe;EAAO,MAAM;CAAM,IACrD;EACI,GAAGA;EACH,eAAe;EACf,WAAW;EACX,MAAM;CACV;AACV"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../../_common/components/slot/Slot.cjs"),t=require("./utils/getTypographyElementProps.utils.cjs");let n=require("react/jsx-runtime");var r=r=>{let i=r.asChild===!0?void 0:r.as??`p`;return(0,n.jsx)(i??e.default,{...t.getTypographyElementProps(r,i)})};exports.default=r;
|
|
2
|
+
//# sourceMappingURL=Typography.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Typography.cjs","names":["Slot","getTypographyElementProps","require_Slot","require_getTypographyElementProps_utils","react_jsx_runtime","Typography","tag","props"],"sources":["../../../../src/components/foundation/typography/Typography.tsx"],"sourcesContent":["import type { ElementType, ReactElement } from 'react';\n\nimport { Slot } from '@primitives/components/_common/components/slot';\nimport type {\n TypographyAsChildProps,\n TypographyProps,\n TypographyTag,\n} from '@primitives/components/foundation/typography/types';\nimport { getTypographyElementProps } from '@primitives/components/foundation/typography/utils/getTypographyElementProps.utils';\n\n/**\n * Text primitive: renders any text tag, a `p` by default, with the default\n * style of that tag, built from the theme tokens. The style follows the tag:\n * there is no variant. Style props override it: text and font props, the\n * shared spacing, sizing and placement props, and `color`. The sizing props\n * and `color` accept any CSS value, a sizing number being a length in\n * pixels, as in `style`. Their classes sit in a later cascade layer than the\n * tag styles, so a prop always prevails. Style props never reach the DOM,\n * and the consumer's `className` and `style` are merged with the generated\n * ones, the consumer's `style` prevailing.\n * Every other prop (attributes, events, `ref`) is typed after the tag and\n * forwarded to the element.\n *\n * `maxLines` truncates the text after a number of lines, with an ellipsis.\n * It turns the element into a block, so an inline tag such as `span` or `a`\n * leaves the flow of its sentence; inside a flex or grid container the text\n * shrinks with its track without further setup. `1` keeps the text on a\n * single line, aligned to the start whatever `textAlign`, and cuts it where\n * it overflows, descenders and accents left uncut; `2` to `6` clamp it after\n * that many lines, a word longer than the line breaking anywhere.\n * Truncation is only visual: the full text stays available to assistive\n * technologies, and sighted users need another way to read it.\n *\n * With `asChild`, nothing is rendered of its own: the single child is, with\n * the classes, styles, other props and `ref` merged onto it, for instance\n * to style a router link. No tag style applies then, since the child sets\n * the element: only the style props do.\n *\n * @param props Style props, `as` or `asChild`, and the native props of the\n * rendered tag.\n * @returns The styled text element.\n * @throws {Error} With `asChild`, when the children are not a single\n * element.\n */\nconst Typography = <Tag extends TypographyTag = 'p'>(\n props: TypographyProps<Tag> | TypographyAsChildProps,\n): ReactElement => {\n const tag: TypographyTag | undefined =\n props.asChild === true ? undefined : (props.as ?? 'p');\n const Element: ElementType = tag ?? Slot;\n\n return <Element {...getTypographyElementProps(props, tag)} />;\n};\n\nexport default Typography;\n"],"mappings":"A,sJA4CA,IAAMK,EACF,GACe,CACf,IAAMC,EACFC,EAAM,UAAY,GAAO,IAAA,GAAaA,EAAM,IAAM,IAGtD,OAAO,EAAAH,EAAA,IAAA,CAFsBE,GAAON,EAAAA,QAE7B,CAAS,GAAIC,EAAAA,0BAA0BM,EAAOD,CAAG,CAAI,CAAA,CAChE,E"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* empty css *//* empty css */;/* empty css */var e={classTable:{prefix:`_1teni2o`,suffixes:{fontFamily:{sans:`6`,serif:`7`,mono:`8`},fontSize:{10:`9`,12:`a`,14:`b`,16:`c`,18:`d`,20:`e`,24:`f`,28:`g`,32:`h`,36:`i`,40:`j`,48:`k`,60:`l`,72:`m`},fontWeight:{regular:`n`,medium:`o`,semibold:`p`,bold:`q`},fontStyle:{normal:`r`,italic:`s`},lineHeight:{none:`t`,tight:`u`,snug:`v`,normal:`w`,relaxed:`x`},letterSpacing:{tighter:`y`,tight:`z`,normal:`10`,wide:`11`,wider:`12`,widest:`13`},textAlign:{start:`14`,center:`15`,end:`16`,justify:`17`},textTransform:{none:`18`,uppercase:`19`,lowercase:`1a`,capitalize:`1b`},textDecoration:{none:`1c`,underline:`1d`,"line-through":`1e`},whiteSpace:{normal:`1f`,nowrap:`1g`,pre:`1h`,"pre-wrap":`1i`,"pre-line":`1j`,"break-spaces":`1k`},textWrap:{wrap:`1l`,nowrap:`1m`,balance:`1n`,pretty:`1o`},wordBreak:{normal:`1p`,"break-all":`1q`,"keep-all":`1r`},overflowWrap:{normal:`1s`,"break-word":`1t`,anywhere:`1u`},maxLines:{1:`0`,2:`1`,3:`2`,4:`3`,5:`4`,6:`5`}},shorthands:{}},tags:{h1:`_1teni2o1v`,h2:`_1teni2o1w`,h3:`_1teni2o1x`,h4:`_1teni2o1y`,h5:`_1teni2o1z`,h6:`_1teni2o20`,p:`_1teni2o21`,blockquote:`_1teni2o22`,pre:`_1teni2o23`,figcaption:`_1teni2o24`,span:``,strong:`_1teni2o25`,b:`_1teni2o25`,em:`_1teni2o26`,i:`_1teni2o26`,small:`_1teni2o27`,mark:`_1teni2o28`,code:`_1teni2o29`,kbd:`_1teni2o2a`,samp:`_1teni2o29`,abbr:`_1teni2o2b`,cite:`_1teni2o26`,q:``,del:`_1teni2o2c`,ins:`_1teni2o2d`,sub:`_1teni2o2e`,sup:`_1teni2o2e`,time:`_1teni2o2f`,u:`_1teni2o2d`,s:`_1teni2o2c`,a:`_1teni2o2g`,label:`_1teni2o2h`,li:`_1teni2o21`,dt:`_1teni2o2i`,dd:`_1teni2o2j`,legend:`_1teni2o2k`,caption:`_1teni2o24`}};exports.typographyStyles=e;
|
|
2
|
+
//# sourceMappingURL=Typography.css.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Typography.css.cjs","names":["typographyStyles"],"sources":[],"mappings":""}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/* empty css */
|
|
2
|
+
/* empty css */
|
|
3
|
+
/* empty css */
|
|
4
|
+
// src/components/foundation/typography/Typography.css.ts
|
|
5
|
+
var e = {
|
|
6
|
+
classTable: {
|
|
7
|
+
prefix: "_1teni2o",
|
|
8
|
+
suffixes: {
|
|
9
|
+
fontFamily: {
|
|
10
|
+
sans: "6",
|
|
11
|
+
serif: "7",
|
|
12
|
+
mono: "8"
|
|
13
|
+
},
|
|
14
|
+
fontSize: {
|
|
15
|
+
10: "9",
|
|
16
|
+
12: "a",
|
|
17
|
+
14: "b",
|
|
18
|
+
16: "c",
|
|
19
|
+
18: "d",
|
|
20
|
+
20: "e",
|
|
21
|
+
24: "f",
|
|
22
|
+
28: "g",
|
|
23
|
+
32: "h",
|
|
24
|
+
36: "i",
|
|
25
|
+
40: "j",
|
|
26
|
+
48: "k",
|
|
27
|
+
60: "l",
|
|
28
|
+
72: "m"
|
|
29
|
+
},
|
|
30
|
+
fontWeight: {
|
|
31
|
+
regular: "n",
|
|
32
|
+
medium: "o",
|
|
33
|
+
semibold: "p",
|
|
34
|
+
bold: "q"
|
|
35
|
+
},
|
|
36
|
+
fontStyle: {
|
|
37
|
+
normal: "r",
|
|
38
|
+
italic: "s"
|
|
39
|
+
},
|
|
40
|
+
lineHeight: {
|
|
41
|
+
none: "t",
|
|
42
|
+
tight: "u",
|
|
43
|
+
snug: "v",
|
|
44
|
+
normal: "w",
|
|
45
|
+
relaxed: "x"
|
|
46
|
+
},
|
|
47
|
+
letterSpacing: {
|
|
48
|
+
tighter: "y",
|
|
49
|
+
tight: "z",
|
|
50
|
+
normal: "10",
|
|
51
|
+
wide: "11",
|
|
52
|
+
wider: "12",
|
|
53
|
+
widest: "13"
|
|
54
|
+
},
|
|
55
|
+
textAlign: {
|
|
56
|
+
start: "14",
|
|
57
|
+
center: "15",
|
|
58
|
+
end: "16",
|
|
59
|
+
justify: "17"
|
|
60
|
+
},
|
|
61
|
+
textTransform: {
|
|
62
|
+
none: "18",
|
|
63
|
+
uppercase: "19",
|
|
64
|
+
lowercase: "1a",
|
|
65
|
+
capitalize: "1b"
|
|
66
|
+
},
|
|
67
|
+
textDecoration: {
|
|
68
|
+
none: "1c",
|
|
69
|
+
underline: "1d",
|
|
70
|
+
"line-through": "1e"
|
|
71
|
+
},
|
|
72
|
+
whiteSpace: {
|
|
73
|
+
normal: "1f",
|
|
74
|
+
nowrap: "1g",
|
|
75
|
+
pre: "1h",
|
|
76
|
+
"pre-wrap": "1i",
|
|
77
|
+
"pre-line": "1j",
|
|
78
|
+
"break-spaces": "1k"
|
|
79
|
+
},
|
|
80
|
+
textWrap: {
|
|
81
|
+
wrap: "1l",
|
|
82
|
+
nowrap: "1m",
|
|
83
|
+
balance: "1n",
|
|
84
|
+
pretty: "1o"
|
|
85
|
+
},
|
|
86
|
+
wordBreak: {
|
|
87
|
+
normal: "1p",
|
|
88
|
+
"break-all": "1q",
|
|
89
|
+
"keep-all": "1r"
|
|
90
|
+
},
|
|
91
|
+
overflowWrap: {
|
|
92
|
+
normal: "1s",
|
|
93
|
+
"break-word": "1t",
|
|
94
|
+
anywhere: "1u"
|
|
95
|
+
},
|
|
96
|
+
maxLines: {
|
|
97
|
+
1: "0",
|
|
98
|
+
2: "1",
|
|
99
|
+
3: "2",
|
|
100
|
+
4: "3",
|
|
101
|
+
5: "4",
|
|
102
|
+
6: "5"
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
shorthands: {}
|
|
106
|
+
},
|
|
107
|
+
tags: {
|
|
108
|
+
h1: "_1teni2o1v",
|
|
109
|
+
h2: "_1teni2o1w",
|
|
110
|
+
h3: "_1teni2o1x",
|
|
111
|
+
h4: "_1teni2o1y",
|
|
112
|
+
h5: "_1teni2o1z",
|
|
113
|
+
h6: "_1teni2o20",
|
|
114
|
+
p: "_1teni2o21",
|
|
115
|
+
blockquote: "_1teni2o22",
|
|
116
|
+
pre: "_1teni2o23",
|
|
117
|
+
figcaption: "_1teni2o24",
|
|
118
|
+
span: "",
|
|
119
|
+
strong: "_1teni2o25",
|
|
120
|
+
b: "_1teni2o25",
|
|
121
|
+
em: "_1teni2o26",
|
|
122
|
+
i: "_1teni2o26",
|
|
123
|
+
small: "_1teni2o27",
|
|
124
|
+
mark: "_1teni2o28",
|
|
125
|
+
code: "_1teni2o29",
|
|
126
|
+
kbd: "_1teni2o2a",
|
|
127
|
+
samp: "_1teni2o29",
|
|
128
|
+
abbr: "_1teni2o2b",
|
|
129
|
+
cite: "_1teni2o26",
|
|
130
|
+
q: "",
|
|
131
|
+
del: "_1teni2o2c",
|
|
132
|
+
ins: "_1teni2o2d",
|
|
133
|
+
sub: "_1teni2o2e",
|
|
134
|
+
sup: "_1teni2o2e",
|
|
135
|
+
time: "_1teni2o2f",
|
|
136
|
+
u: "_1teni2o2d",
|
|
137
|
+
s: "_1teni2o2c",
|
|
138
|
+
a: "_1teni2o2g",
|
|
139
|
+
label: "_1teni2o2h",
|
|
140
|
+
li: "_1teni2o21",
|
|
141
|
+
dt: "_1teni2o2i",
|
|
142
|
+
dd: "_1teni2o2j",
|
|
143
|
+
legend: "_1teni2o2k",
|
|
144
|
+
caption: "_1teni2o24"
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
export { e as typographyStyles };
|
|
148
|
+
|
|
149
|
+
//# sourceMappingURL=Typography.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Typography.css.js","names":["typographyStyles"],"sources":[],"mappings":""}
|