@mohirlab/react 0.6.0 → 0.6.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/dist/components/accordion/accordion.d.ts +1 -0
- package/dist/components/accordion/accordion.d.ts.map +1 -1
- package/dist/components/accordion/accordion.js +1 -0
- package/dist/components/accordion/accordion.js.map +1 -1
- package/dist/components/accordion/accordion.styles.js +1 -0
- package/dist/components/accordion/index.d.ts +1 -0
- package/dist/components/avatar/avatar.css.d.ts +1 -0
- package/dist/components/avatar/avatar.css.d.ts.map +1 -1
- package/dist/components/avatar/avatar.d.ts +1 -0
- package/dist/components/avatar/avatar.d.ts.map +1 -1
- package/dist/components/avatar/avatar.js +1 -0
- package/dist/components/avatar/avatar.js.map +1 -1
- package/dist/components/avatar/avatar.styles.js +1 -0
- package/dist/components/avatar/index.d.ts +1 -0
- package/dist/components/badge/badge.css.d.ts +1 -0
- package/dist/components/badge/badge.css.d.ts.map +1 -1
- package/dist/components/badge/badge.d.ts +1 -0
- package/dist/components/badge/badge.d.ts.map +1 -1
- package/dist/components/badge/badge.js +1 -0
- package/dist/components/badge/badge.js.map +1 -1
- package/dist/components/badge/badge.styles.js +1 -0
- package/dist/components/badge/index.d.ts +1 -0
- package/dist/components/box/box.d.ts +1 -0
- package/dist/components/box/box.d.ts.map +1 -1
- package/dist/components/box/box.js +1 -0
- package/dist/components/box/box.js.map +1 -1
- package/dist/components/box/index.d.ts +1 -0
- package/dist/components/box/stack.d.ts +1 -0
- package/dist/components/box/stack.d.ts.map +1 -1
- package/dist/components/box/stack.js +1 -0
- package/dist/components/box/stack.js.map +1 -1
- package/dist/components/button/button.css.d.ts +1 -0
- package/dist/components/button/button.css.d.ts.map +1 -1
- package/dist/components/button/button.d.ts +1 -0
- package/dist/components/button/button.d.ts.map +1 -1
- package/dist/components/button/button.js +1 -0
- package/dist/components/button/button.js.map +1 -1
- package/dist/components/button/button.styles.js +1 -0
- package/dist/components/button/index.d.ts +1 -0
- package/dist/components/card/card-media.d.ts +1 -0
- package/dist/components/card/card-media.d.ts.map +1 -1
- package/dist/components/card/card-media.js +1 -0
- package/dist/components/card/card-media.js.map +1 -1
- package/dist/components/card/card.css.d.ts +1 -0
- package/dist/components/card/card.css.d.ts.map +1 -1
- package/dist/components/card/card.d.ts +1 -0
- package/dist/components/card/card.d.ts.map +1 -1
- package/dist/components/card/card.js +1 -0
- package/dist/components/card/card.js.map +1 -1
- package/dist/components/card/card.styles.js +1 -0
- package/dist/components/card/index.d.ts +1 -0
- package/dist/components/choice/choice.d.ts +1 -0
- package/dist/components/choice/choice.d.ts.map +1 -1
- package/dist/components/choice/choice.js +1 -0
- package/dist/components/choice/choice.js.map +1 -1
- package/dist/components/choice/choice.styles.js +1 -0
- package/dist/components/choice/index.d.ts +1 -0
- package/dist/components/dialog/dialog.css.d.ts +1 -0
- package/dist/components/dialog/dialog.css.d.ts.map +1 -1
- package/dist/components/dialog/dialog.d.ts +1 -0
- package/dist/components/dialog/dialog.d.ts.map +1 -1
- package/dist/components/dialog/dialog.js +1 -0
- package/dist/components/dialog/dialog.js.map +1 -1
- package/dist/components/dialog/dialog.styles.js +1 -0
- package/dist/components/dialog/index.d.ts +1 -0
- package/dist/components/field/field-context.d.ts +1 -0
- package/dist/components/field/field-context.d.ts.map +1 -1
- package/dist/components/field/field-context.js +1 -0
- package/dist/components/field/field-context.js.map +1 -1
- package/dist/components/field/field.d.ts +1 -0
- package/dist/components/field/field.d.ts.map +1 -1
- package/dist/components/field/field.js +1 -0
- package/dist/components/field/field.js.map +1 -1
- package/dist/components/field/field.styles.js +1 -0
- package/dist/components/field/index.d.ts +1 -0
- package/dist/components/field/use-field-control.js +1 -0
- package/dist/components/field/use-field-control.js.map +1 -1
- package/dist/components/icon/icon.d.ts +1 -0
- package/dist/components/icon/icon.d.ts.map +1 -1
- package/dist/components/icon/icon.js +1 -0
- package/dist/components/icon/icon.js.map +1 -1
- package/dist/components/icon/index.d.ts +1 -0
- package/dist/components/input/index.d.ts +1 -0
- package/dist/components/input/input.css.d.ts +1 -0
- package/dist/components/input/input.css.d.ts.map +1 -1
- package/dist/components/input/input.d.ts +1 -0
- package/dist/components/input/input.d.ts.map +1 -1
- package/dist/components/input/input.js +1 -0
- package/dist/components/input/input.js.map +1 -1
- package/dist/components/input/input.styles.js +1 -0
- package/dist/components/navigation/index.d.ts +1 -0
- package/dist/components/navigation/nav.d.ts +1 -0
- package/dist/components/navigation/nav.d.ts.map +1 -1
- package/dist/components/navigation/nav.js +1 -0
- package/dist/components/navigation/nav.js.map +1 -1
- package/dist/components/navigation/navigation.styles.js +1 -0
- package/dist/components/navigation/tabs.d.ts +1 -0
- package/dist/components/navigation/tabs.d.ts.map +1 -1
- package/dist/components/navigation/tabs.js +1 -0
- package/dist/components/navigation/tabs.js.map +1 -1
- package/dist/components/popover/index.d.ts +1 -0
- package/dist/components/popover/popover.css.d.ts +1 -0
- package/dist/components/popover/popover.css.d.ts.map +1 -1
- package/dist/components/popover/popover.d.ts +1 -0
- package/dist/components/popover/popover.d.ts.map +1 -1
- package/dist/components/popover/popover.js +1 -0
- package/dist/components/popover/popover.js.map +1 -1
- package/dist/components/popover/popover.styles.js +1 -0
- package/dist/components/select/index.d.ts +1 -0
- package/dist/components/select/select.d.ts +1 -0
- package/dist/components/select/select.d.ts.map +1 -1
- package/dist/components/select/select.js +1 -0
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/select/select.styles.js +1 -0
- package/dist/components/slider/index.d.ts +1 -0
- package/dist/components/slider/slider.d.ts +1 -0
- package/dist/components/slider/slider.d.ts.map +1 -1
- package/dist/components/slider/slider.js +1 -0
- package/dist/components/slider/slider.js.map +1 -1
- package/dist/components/slider/slider.styles.js +1 -0
- package/dist/components/table/index.d.ts +1 -0
- package/dist/components/table/table.d.ts +1 -0
- package/dist/components/table/table.d.ts.map +1 -1
- package/dist/components/table/table.js +1 -0
- package/dist/components/table/table.js.map +1 -1
- package/dist/components/table/table.styles.js +1 -0
- package/dist/components/text/index.d.ts +1 -0
- package/dist/components/text/text.css.d.ts +1 -0
- package/dist/components/text/text.css.d.ts.map +1 -1
- package/dist/components/text/text.d.ts +1 -0
- package/dist/components/text/text.d.ts.map +1 -1
- package/dist/components/text/text.js +1 -0
- package/dist/components/text/text.js.map +1 -1
- package/dist/components/text/text.styles.js +1 -0
- package/dist/components/theme-scope/theme-scope.d.ts +1 -0
- package/dist/components/theme-scope/theme-scope.d.ts.map +1 -1
- package/dist/components/theme-scope/theme-scope.js +1 -0
- package/dist/components/theme-scope/theme-scope.js.map +1 -1
- package/dist/components/toast/index.d.ts +1 -0
- package/dist/components/toast/toast.d.ts +1 -0
- package/dist/components/toast/toast.d.ts.map +1 -1
- package/dist/components/toast/toast.js +1 -0
- package/dist/components/toast/toast.js.map +1 -1
- package/dist/components/toast/toast.styles.js +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/use-disclosure.d.ts +1 -0
- package/dist/hooks/use-disclosure.d.ts.map +1 -1
- package/dist/hooks/use-disclosure.js +1 -0
- package/dist/hooks/use-disclosure.js.map +1 -1
- package/dist/hooks/use-presence.d.ts +1 -0
- package/dist/hooks/use-presence.d.ts.map +1 -1
- package/dist/hooks/use-presence.js +1 -0
- package/dist/hooks/use-presence.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/utils/cx.d.ts +1 -0
- package/dist/utils/cx.d.ts.map +1 -1
- package/dist/utils/cx.js +1 -0
- package/dist/utils/cx.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accordion.d.ts","names":[],"sources":["../../../src/components/accordion/accordion.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"accordion.d.ts","names":[],"sources":["../../../src/components/accordion/accordion.tsx"],"mappings":";;iBAQiB,uBAAuB;;EAEtC;EACA,UAAU;;;;;;wBAOI,YAAY,MAAmB,cAAc,QAAQ,iCAAc,IAAA;iBASlE,2BAA2B,KAAK;;EAE/C,OAAO;EACP;EACA,UAAU;;wBAGI,gBAAgB,OAAO,aAAa,WAAW,aAAa,QAAQ,qCAAkB,IAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accordion.js","names":["styles.accordion","styles.item","styles.summary","styles.chevron","styles.content"],"sources":["../../../src/components/accordion/accordion.tsx"],"sourcesContent":["import { createContext, useContext, useId, type ComponentPropsWithRef, type ReactNode } from 'react';\nimport { iconChevronDown } from '@mohirlab/icons';\nimport { cx } from '../../utils/cx';\nimport { Icon } from '../icon';\nimport * as styles from './accordion.css';\n\nconst AccordionContext = createContext<{ name?: string }>({});\n\nexport interface AccordionProps extends ComponentPropsWithRef<'div'> {\n /** `single`: opening one item closes the others. `multiple` (default): independent. */\n type?: 'single' | 'multiple';\n children: ReactNode;\n}\n\n/**\n * Collapsible sections on native `<details>`/`<summary>`: keyboard support, screen reader\n * semantics and find-in-page (which opens the matching item) come from the browser.\n */\nexport function Accordion({ type = 'multiple', className, ...rest }: AccordionProps) {\n const id = useId();\n return (\n <AccordionContext.Provider value={{ name: type === 'single' ? `ml-accordion-${id}` : undefined }}>\n <div {...rest} className={cx(styles.accordion, className)} />\n </AccordionContext.Provider>\n );\n}\n\nexport interface AccordionItemProps extends Omit<ComponentPropsWithRef<'details'>, 'title'> {\n /** The always-visible heading of the item. */\n title: ReactNode;\n defaultOpen?: boolean;\n children: ReactNode;\n}\n\nexport function AccordionItem({ title, defaultOpen, className, children, ...rest }: AccordionItemProps) {\n const { name } = useContext(AccordionContext);\n return (\n <details {...rest} name={name} open={defaultOpen} className={cx(styles.item, className)}>\n <summary className={styles.summary}>\n {title}\n <Icon icon={iconChevronDown} className={styles.chevron} />\n </summary>\n <div className={styles.content}>{children}</div>\n </details>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"accordion.js","names":["styles.accordion","styles.item","styles.summary","styles.chevron","styles.content"],"sources":["../../../src/components/accordion/accordion.tsx"],"sourcesContent":["import { createContext, useContext, useId, type ComponentPropsWithRef, type ReactNode } from 'react';\nimport { iconChevronDown } from '@mohirlab/icons';\nimport { cx } from '../../utils/cx';\nimport { Icon } from '../icon';\nimport * as styles from './accordion.css';\n\nconst AccordionContext = createContext<{ name?: string }>({});\n\nexport interface AccordionProps extends ComponentPropsWithRef<'div'> {\n /** `single`: opening one item closes the others. `multiple` (default): independent. */\n type?: 'single' | 'multiple';\n children: ReactNode;\n}\n\n/**\n * Collapsible sections on native `<details>`/`<summary>`: keyboard support, screen reader\n * semantics and find-in-page (which opens the matching item) come from the browser.\n */\nexport function Accordion({ type = 'multiple', className, ...rest }: AccordionProps) {\n const id = useId();\n return (\n <AccordionContext.Provider value={{ name: type === 'single' ? `ml-accordion-${id}` : undefined }}>\n <div {...rest} className={cx(styles.accordion, className)} />\n </AccordionContext.Provider>\n );\n}\n\nexport interface AccordionItemProps extends Omit<ComponentPropsWithRef<'details'>, 'title'> {\n /** The always-visible heading of the item. */\n title: ReactNode;\n defaultOpen?: boolean;\n children: ReactNode;\n}\n\nexport function AccordionItem({ title, defaultOpen, className, children, ...rest }: AccordionItemProps) {\n const { name } = useContext(AccordionContext);\n return (\n <details {...rest} name={name} open={defaultOpen} className={cx(styles.item, className)}>\n <summary className={styles.summary}>\n {title}\n <Icon icon={iconChevronDown} className={styles.chevron} />\n </summary>\n <div className={styles.content}>{children}</div>\n </details>\n );\n}\n"],"mappings":";;;;;;;;AAMA,MAAM,mBAAmB,cAAiC,CAAC,CAAC;;;;;AAY5D,SAAgB,UAAU,EAAE,OAAO,YAAY,WAAW,GAAG,QAAwB;CACnF,MAAM,KAAK,MAAM;CACjB,OACE,oBAAC,iBAAiB,UAAlB;EAA2B,OAAO,EAAE,MAAM,SAAS,WAAW,gBAAgB,OAAO,KAAA,EAAU;EAC7F,UAAA,oBAAC,OAAD;GAAK,GAAI;GAAM,WAAW,GAAGA,WAAkB,SAAS;EAAI,CAAA;CACnC,CAAA;AAE/B;AASA,SAAgB,cAAc,EAAE,OAAO,aAAa,WAAW,UAAU,GAAG,QAA4B;CACtG,MAAM,EAAE,SAAS,WAAW,gBAAgB;CAC5C,OACE,qBAAC,WAAD;EAAS,GAAI;EAAY;EAAM,MAAM;EAAa,WAAW,GAAGC,MAAa,SAAS;EAAtF,UAAA,CACE,qBAAC,WAAD;GAAS,WAAWC;GAApB,UAAA,CACG,OACD,oBAAC,MAAD;IAAM,MAAM;IAAiB,WAAWC;GAAiB,CAAA,CAClD;EACT,CAAA,GAAA,oBAAC,OAAD;GAAK,WAAWC;GAAiB;EAAc,CAAA,CACxC;;AAEb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avatar.css.d.ts","names":[],"sources":["../../../src/components/avatar/avatar.css.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"avatar.css.d.ts","names":[],"sources":["../../../src/components/avatar/avatar.css.ts"],"mappings":";;qBAOa;qBAEA,2CAAM;;;;SAgBE;;;;;SACA;;;;;SACA;;;;;SACA;;;;;SACA;;;;;;;;;;MAKL;;;;YAMJ,iBAAiB,YAAY,sBAAsB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avatar.d.ts","names":["styles.AvatarVariants"],"sources":["../../../src/components/avatar/avatar.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"avatar.d.ts","names":["styles.AvatarVariants"],"sources":["../../../src/components/avatar/avatar.tsx"],"mappings":";;;iBAYiB,oBAAoB,KAAK;;EAExC;;EAEA;;EAEA;;EAEA;EACA,OAAOA;EACP,QAAQA;;wBAGM,SAAS,KAAK,MAAM,MAAM,UAAiB,MAAM,OAAO,cAAc,QAAQ,8BAAW,IAAA;iBAwBxF,yBAAyB;;EAExC;;EAEA;;EAEA,iBAAiB,mBAAmB;EACpC,OAAOA;EACP,UAAU;;wBAKI,cACd,KACA,OACA,eACA,MACA,WACA,aACG,QACF,mCAAgB,IAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avatar.js","names":["generateAvatar","styles.avatar","styles.image","styles.group","styles.groupItem"],"sources":["../../../src/components/avatar/avatar.tsx"],"sourcesContent":["import {\n Children,\n isValidElement,\n useMemo,\n useState,\n type ComponentPropsWithRef,\n type ReactNode,\n} from 'react';\nimport { avatar as generateAvatar, initialsOf, toDataUri } from '@mohirlab/assets';\nimport { cx } from '../../utils/cx';\nimport * as styles from './avatar.css';\n\nexport interface AvatarProps extends Omit<ComponentPropsWithRef<'span'>, 'children'> {\n /** Photo URL. When missing or broken, a generated tile avatar is shown. */\n src?: string;\n /** Person or entity name: the accessible label and the source of initials. */\n name: string;\n /** Stable id for the generated fallback (a user id survives renames). Defaults to `name`. */\n seed?: string;\n /** Draw initials on the fallback tile. Default true. */\n initials?: boolean;\n size?: styles.AvatarVariants['size'];\n shape?: styles.AvatarVariants['shape'];\n}\n\nexport function Avatar({ src, name, seed, initials = true, size, shape, className, ...rest }: AvatarProps) {\n const [failed, setFailed] = useState<string | null>(null);\n const fallback = useMemo(\n () =>\n toDataUri(\n generateAvatar(seed ?? name, { size: 96, initials: initials ? initialsOf(name) : undefined }),\n ),\n [seed, name, initials],\n );\n const showPhoto = src && failed !== src;\n\n return (\n <span {...rest} className={cx(styles.avatar({ size, shape }), className)}>\n <img\n className={styles.image}\n src={showPhoto ? src : fallback}\n alt={name}\n draggable={false}\n onError={showPhoto ? () => setFailed(src) : undefined}\n />\n </span>\n );\n}\n\nexport interface AvatarGroupProps extends ComponentPropsWithRef<'div'> {\n /** Show at most this many avatars. */\n max?: number;\n /** Total people, when larger than the avatars you pass (e.g. 2,140 going). */\n total?: number;\n /** Text after the stack. Default: \"+N\" for the people not shown. */\n overflowLabel?: (hidden: number) => ReactNode;\n size?: styles.AvatarVariants['size'];\n children: ReactNode;\n}\n\nconst compact = new Intl.NumberFormat(undefined, { notation: 'compact', maximumFractionDigits: 1 });\n\nexport function AvatarGroup({\n max = 4,\n total,\n overflowLabel = (n) => `+${compact.format(n)}`,\n size = 'sm',\n className,\n children,\n ...rest\n}: AvatarGroupProps) {\n const items = Children.toArray(children).filter(isValidElement);\n const shown = items.slice(0, max);\n const hidden = Math.max((total ?? items.length) - shown.length, 0);\n\n return (\n <div {...rest} className={cx(styles.group, className)}>\n {shown.map((child) => (\n <Avatar\n key={child.key}\n {...(child.props as AvatarProps)}\n size={size}\n className={cx(styles.groupItem, (child.props as AvatarProps).className)}\n />\n ))}\n {hidden > 0 && <span className={styles.overflow}>{overflowLabel(hidden)}</span>}\n </div>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"avatar.js","names":["generateAvatar","styles.avatar","styles.image","styles.group","styles.groupItem"],"sources":["../../../src/components/avatar/avatar.tsx"],"sourcesContent":["import {\n Children,\n isValidElement,\n useMemo,\n useState,\n type ComponentPropsWithRef,\n type ReactNode,\n} from 'react';\nimport { avatar as generateAvatar, initialsOf, toDataUri } from '@mohirlab/assets';\nimport { cx } from '../../utils/cx';\nimport * as styles from './avatar.css';\n\nexport interface AvatarProps extends Omit<ComponentPropsWithRef<'span'>, 'children'> {\n /** Photo URL. When missing or broken, a generated tile avatar is shown. */\n src?: string;\n /** Person or entity name: the accessible label and the source of initials. */\n name: string;\n /** Stable id for the generated fallback (a user id survives renames). Defaults to `name`. */\n seed?: string;\n /** Draw initials on the fallback tile. Default true. */\n initials?: boolean;\n size?: styles.AvatarVariants['size'];\n shape?: styles.AvatarVariants['shape'];\n}\n\nexport function Avatar({ src, name, seed, initials = true, size, shape, className, ...rest }: AvatarProps) {\n const [failed, setFailed] = useState<string | null>(null);\n const fallback = useMemo(\n () =>\n toDataUri(\n generateAvatar(seed ?? name, { size: 96, initials: initials ? initialsOf(name) : undefined }),\n ),\n [seed, name, initials],\n );\n const showPhoto = src && failed !== src;\n\n return (\n <span {...rest} className={cx(styles.avatar({ size, shape }), className)}>\n <img\n className={styles.image}\n src={showPhoto ? src : fallback}\n alt={name}\n draggable={false}\n onError={showPhoto ? () => setFailed(src) : undefined}\n />\n </span>\n );\n}\n\nexport interface AvatarGroupProps extends ComponentPropsWithRef<'div'> {\n /** Show at most this many avatars. */\n max?: number;\n /** Total people, when larger than the avatars you pass (e.g. 2,140 going). */\n total?: number;\n /** Text after the stack. Default: \"+N\" for the people not shown. */\n overflowLabel?: (hidden: number) => ReactNode;\n size?: styles.AvatarVariants['size'];\n children: ReactNode;\n}\n\nconst compact = new Intl.NumberFormat(undefined, { notation: 'compact', maximumFractionDigits: 1 });\n\nexport function AvatarGroup({\n max = 4,\n total,\n overflowLabel = (n) => `+${compact.format(n)}`,\n size = 'sm',\n className,\n children,\n ...rest\n}: AvatarGroupProps) {\n const items = Children.toArray(children).filter(isValidElement);\n const shown = items.slice(0, max);\n const hidden = Math.max((total ?? items.length) - shown.length, 0);\n\n return (\n <div {...rest} className={cx(styles.group, className)}>\n {shown.map((child) => (\n <Avatar\n key={child.key}\n {...(child.props as AvatarProps)}\n size={size}\n className={cx(styles.groupItem, (child.props as AvatarProps).className)}\n />\n ))}\n {hidden > 0 && <span className={styles.overflow}>{overflowLabel(hidden)}</span>}\n </div>\n );\n}\n"],"mappings":";;;;;;;AAyBA,SAAgB,OAAO,EAAE,KAAK,MAAM,MAAM,WAAW,MAAM,MAAM,OAAO,WAAW,GAAG,QAAqB;CACzG,MAAM,CAAC,QAAQ,aAAa,SAAwB,IAAI;CACxD,MAAM,WAAW,cAEb,UACEA,OAAe,QAAQ,MAAM;EAAE,MAAM;EAAI,UAAU,WAAW,WAAW,IAAI,IAAI,KAAA;CAAU,CAAC,CAC9F,GACF;EAAC;EAAM;EAAM;CAAQ,CACvB;CACA,MAAM,YAAY,OAAO,WAAW;CAEpC,OACE,oBAAC,QAAD;EAAM,GAAI;EAAM,WAAW,GAAGC,SAAc;GAAE;GAAM;EAAM,CAAC,GAAG,SAAS;EACrE,UAAA,oBAAC,OAAD;GACE,WAAWC;GACX,KAAK,YAAY,MAAM;GACvB,KAAK;GACL,WAAW;GACX,SAAS,kBAAkB,UAAU,GAAG,IAAI,KAAA;EAC7C,CAAA;CACG,CAAA;AAEV;AAaA,MAAM,UAAU,IAAI,KAAK,aAAa,KAAA,GAAW;CAAE,UAAU;CAAW,uBAAuB;AAAE,CAAC;AAElG,SAAgB,YAAY,EAC1B,MAAM,GACN,OACA,iBAAiB,MAAM,IAAI,QAAQ,OAAO,CAAC,KAC3C,OAAO,MACP,WACA,UACA,GAAG,QACgB;CACnB,MAAM,QAAQ,SAAS,QAAQ,QAAQ,CAAC,CAAC,OAAO,cAAc;CAC9D,MAAM,QAAQ,MAAM,MAAM,GAAG,GAAG;CAChC,MAAM,SAAS,KAAK,KAAK,SAAS,MAAM,UAAU,MAAM,QAAQ,CAAC;CAEjE,OACE,qBAAC,OAAD;EAAK,GAAI;EAAM,WAAW,GAAGC,OAAc,SAAS;EAApD,UAAA,CACG,MAAM,KAAK,UACV,oBAAC,QAAD;GAEE,GAAK,MAAM;GACL;GACN,WAAW,GAAGC,WAAmB,MAAM,MAAsB,SAAS;EACvE,GAJM,MAAM,GAIZ,CACF,GACA,SAAS,KAAK,oBAAC,QAAD;GAAM,WAAW;GAAkB,UAAA,cAAc,MAAM;EAAQ,CAAA,CAC3E;;AAET"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"badge.css.d.ts","names":[],"sources":["../../../src/components/badge/badge.css.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"badge.css.d.ts","names":[],"sources":["../../../src/components/badge/badge.css.ts"],"mappings":";;cAOM;cACA;cACA;;qBAIO,0CAAK;;;;SAiBQ;SAA6B;SAAwB;;;;;SACtD;SAA0B;SAAyB;;;;;SAClD;SAA2B;SAA0B;;;;;SACrD;SAA2B;SAA0B;;;;;SACtD;SAA0B;SAAyB;;;;;;;SAGrD;SAAc;;;;;;YAOzB,gBAAgB,YAAY,sBAAsB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"badge.d.ts","names":[],"sources":["../../../src/components/badge/badge.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"badge.d.ts","names":[],"sources":["../../../src/components/badge/badge.tsx"],"mappings":";;;iBAIiB,mBAAmB,KAAK;EACvC,OAAO;;EAEP;;EAEA;;wBAGc,QAAQ,MAAM,OAAO,MAAc,WAAW,aAAa,QAAQ,6BAAU,IAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"badge.js","names":[],"sources":["../../../src/components/badge/badge.tsx"],"sourcesContent":["import type { ComponentPropsWithRef } from 'react';\nimport { cx } from '../../utils/cx';\nimport { badge, sealMark, type BadgeVariants } from './badge.css';\n\nexport interface BadgeProps extends Omit<ComponentPropsWithRef<'span'>, 'color'> {\n tone?: BadgeVariants['tone'];\n /** Filled stamp instead of tinted. */\n solid?: boolean;\n /** Leading square seal. */\n seal?: boolean;\n}\n\nexport function Badge({ tone, solid, seal = false, className, children, ...rest }: BadgeProps) {\n return (\n <span {...rest} className={cx(badge({ tone, solid }), className)}>\n {seal && <span className={sealMark} aria-hidden=\"true\" />}\n {children}\n </span>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"badge.js","names":[],"sources":["../../../src/components/badge/badge.tsx"],"sourcesContent":["import type { ComponentPropsWithRef } from 'react';\nimport { cx } from '../../utils/cx';\nimport { badge, sealMark, type BadgeVariants } from './badge.css';\n\nexport interface BadgeProps extends Omit<ComponentPropsWithRef<'span'>, 'color'> {\n tone?: BadgeVariants['tone'];\n /** Filled stamp instead of tinted. */\n solid?: boolean;\n /** Leading square seal. */\n seal?: boolean;\n}\n\nexport function Badge({ tone, solid, seal = false, className, children, ...rest }: BadgeProps) {\n return (\n <span {...rest} className={cx(badge({ tone, solid }), className)}>\n {seal && <span className={sealMark} aria-hidden=\"true\" />}\n {children}\n </span>\n );\n}\n"],"mappings":";;;;;AAYA,SAAgB,MAAM,EAAE,MAAM,OAAO,OAAO,OAAO,WAAW,UAAU,GAAG,QAAoB;CAC7F,OACE,qBAAC,QAAD;EAAM,GAAI;EAAM,WAAW,GAAG,MAAM;GAAE;GAAM;EAAM,CAAC,GAAG,SAAS;EAA/D,UAAA,CACG,QAAQ,oBAAC,QAAD;GAAM,WAAA;GAAqB,eAAY;EAAQ,CAAA,GACvD,QACG;;AAEV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"box.d.ts","names":[],"sources":["../../../src/components/box/box.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"box.d.ts","names":[],"sources":["../../../src/components/box/box.tsx"],"mappings":";;;YAIY,WAAW,KAAK,oCAAoC,aAC9D;EACE,KAAK;;;wBAIO,eAAe,UAAU,yBAAyB,OAAO;EAO9D,OAAgB;EAAW,MAAc,KAAK,SAAS;;;;;;wBAOlD,MAAM,IAAI,WAAmB,cAAc,SAAS,2BAAQ,IAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"box.js","names":[],"sources":["../../../src/components/box/box.tsx"],"sourcesContent":["import type { ComponentPropsWithRef, ElementType } from 'react';\nimport { sprinkles, type Sprinkles } from '@mohirlab/sprinkles';\nimport { cx } from '../../utils/cx';\n\nexport type BoxProps = Omit<ComponentPropsWithRef<'div'>, keyof Sprinkles> &\n Sprinkles & {\n as?: ElementType;\n };\n\n/** Split props into sprinkles (style) props and everything else. */\nexport function splitSprinkles<T extends Record<string, unknown>>(props: T) {\n const style: Record<string, unknown> = {};\n const rest: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(props)) {\n if (sprinkles.properties.has(key as keyof Sprinkles)) style[key] = value;\n else rest[key] = value;\n }\n return { style: style as Sprinkles, rest: rest as Omit<T, keyof Sprinkles> };\n}\n\n/**\n * The layout primitive. Every sprinkles property is a prop, with responsive\n * values: `<Box padding={{ mobile: '3', desktop: '6' }} />`.\n */\nexport function Box({ as: Component = 'div', className, ...props }: BoxProps) {\n const { style, rest } = splitSprinkles(props);\n return <Component {...rest} className={cx(sprinkles(style), className)} />;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"box.js","names":[],"sources":["../../../src/components/box/box.tsx"],"sourcesContent":["import type { ComponentPropsWithRef, ElementType } from 'react';\nimport { sprinkles, type Sprinkles } from '@mohirlab/sprinkles';\nimport { cx } from '../../utils/cx';\n\nexport type BoxProps = Omit<ComponentPropsWithRef<'div'>, keyof Sprinkles> &\n Sprinkles & {\n as?: ElementType;\n };\n\n/** Split props into sprinkles (style) props and everything else. */\nexport function splitSprinkles<T extends Record<string, unknown>>(props: T) {\n const style: Record<string, unknown> = {};\n const rest: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(props)) {\n if (sprinkles.properties.has(key as keyof Sprinkles)) style[key] = value;\n else rest[key] = value;\n }\n return { style: style as Sprinkles, rest: rest as Omit<T, keyof Sprinkles> };\n}\n\n/**\n * The layout primitive. Every sprinkles property is a prop, with responsive\n * values: `<Box padding={{ mobile: '3', desktop: '6' }} />`.\n */\nexport function Box({ as: Component = 'div', className, ...props }: BoxProps) {\n const { style, rest } = splitSprinkles(props);\n return <Component {...rest} className={cx(sprinkles(style), className)} />;\n}\n"],"mappings":";;;;;;AAUA,SAAgB,eAAkD,OAAU;CAC1E,MAAM,QAAiC,CAAC;CACxC,MAAM,OAAgC,CAAC;CACvC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,GAC7C,IAAI,UAAU,WAAW,IAAI,GAAsB,GAAG,MAAM,OAAO;MAC9D,KAAK,OAAO;CAEnB,OAAO;EAAS;EAA0B;CAAiC;AAC7E;;;;;AAMA,SAAgB,IAAI,EAAE,IAAI,YAAY,OAAO,WAAW,GAAG,SAAmB;CAC5E,MAAM,EAAE,OAAO,SAAS,eAAe,KAAK;CAC5C,OAAO,oBAAC,WAAD;EAAW,GAAI;EAAM,WAAW,GAAG,UAAU,KAAK,GAAG,SAAS;CAAI,CAAA;AAC3E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack.d.ts","names":[],"sources":["../../../src/components/box/stack.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"stack.d.ts","names":[],"sources":["../../../src/components/box/stack.tsx"],"mappings":";;;iBAGiB,mBAAmB,KAClC;;EAIA,YAAY;EACZ,QAAQ;EACR,UAAU;EACV;;;wBAIc,QAAQ,WAAsB,OAAO,SAAS,MAAM,QAAc,QAAQ,6BAAU,IAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack.js","names":[],"sources":["../../../src/components/box/stack.tsx"],"sourcesContent":["import type { Sprinkles } from '@mohirlab/sprinkles';\nimport { Box, type BoxProps } from './box';\n\nexport interface StackProps extends Omit<\n BoxProps,\n 'display' | 'flexDirection' | 'alignItems' | 'justifyContent' | 'flexWrap'\n> {\n /** `column` stacks vertically (default), `row` lays out inline. Responsive. */\n direction?: Sprinkles['flexDirection'];\n align?: Sprinkles['alignItems'];\n justify?: Sprinkles['justifyContent'];\n wrap?: boolean;\n}\n\n/** Flex layout with token gaps. */\nexport function Stack({ direction = 'column', align, justify, wrap, gap = '3', ...rest }: StackProps) {\n return (\n <Box\n display=\"flex\"\n flexDirection={direction}\n alignItems={align}\n justifyContent={justify}\n flexWrap={wrap ? 'wrap' : undefined}\n gap={gap}\n {...rest}\n />\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"stack.js","names":[],"sources":["../../../src/components/box/stack.tsx"],"sourcesContent":["import type { Sprinkles } from '@mohirlab/sprinkles';\nimport { Box, type BoxProps } from './box';\n\nexport interface StackProps extends Omit<\n BoxProps,\n 'display' | 'flexDirection' | 'alignItems' | 'justifyContent' | 'flexWrap'\n> {\n /** `column` stacks vertically (default), `row` lays out inline. Responsive. */\n direction?: Sprinkles['flexDirection'];\n align?: Sprinkles['alignItems'];\n justify?: Sprinkles['justifyContent'];\n wrap?: boolean;\n}\n\n/** Flex layout with token gaps. */\nexport function Stack({ direction = 'column', align, justify, wrap, gap = '3', ...rest }: StackProps) {\n return (\n <Box\n display=\"flex\"\n flexDirection={direction}\n alignItems={align}\n justifyContent={justify}\n flexWrap={wrap ? 'wrap' : undefined}\n gap={gap}\n {...rest}\n />\n );\n}\n"],"mappings":";;;;;AAeA,SAAgB,MAAM,EAAE,YAAY,UAAU,OAAO,SAAS,MAAM,MAAM,KAAK,GAAG,QAAoB;CACpG,OACE,oBAAC,KAAD;EACE,SAAQ;EACR,eAAe;EACf,YAAY;EACZ,gBAAgB;EAChB,UAAU,OAAO,SAAS,KAAA;EACrB;EACL,GAAI;CACL,CAAA;AAEL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.css.d.ts","names":[],"sources":["../../../src/components/button/button.css.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"button.css.d.ts","names":[],"sources":["../../../src/components/button/button.css.ts"],"mappings":";;cAkBM;cACA;cACA;cACA;cACA;cACA;qBAIO,2CAAM;;;;SA8BR;SACA;SACA;SACA;SACA;SACA;;;;;SAKA;SACA;SACA;SACA;SACA;SACA;;;;;SAKA;SACA;SACA;SACA;SACA;SACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA0EC,iBAAiB,YAAY,sBAAsB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","names":[],"sources":["../../../src/components/button/button.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"button.d.ts","names":[],"sources":["../../../src/components/button/button.tsx"],"mappings":";;;iBAIiB,oBAAoB,KAAK;;EAExC,OAAO;;EAEP,aAAa;EACb,OAAO;EACP;;EAEA,QAAQ;;EAER,MAAM;;EAEN;;EAEA;;wBAGc,SACd,MACA,YACA,MACA,WACA,UACA,OACA,KACA,SACA,UACA,WACA,UACA,MACA,YACG,QACF,8BAAW,IAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","names":[],"sources":["../../../src/components/button/button.tsx"],"sourcesContent":["import type { ComponentPropsWithRef, ReactNode } from 'react';\nimport { cx } from '../../utils/cx';\nimport { button, hiddenLabel, slot, spinner, spinnerOverlay, type ButtonVariants } from './button.css';\n\nexport interface ButtonProps extends Omit<ComponentPropsWithRef<'button'>, 'color'> {\n /** Color role. */\n tone?: ButtonVariants['tone'];\n /** How much visual weight the button carries. */\n appearance?: ButtonVariants['appearance'];\n size?: ButtonVariants['size'];\n fullWidth?: boolean;\n /** Content before the label, usually an icon. */\n start?: ReactNode;\n /** Content after the label. */\n end?: ReactNode;\n /** Square button for a single icon. Give it an `aria-label`. */\n iconOnly?: boolean;\n /** Shows a spinner, keeps the width, and blocks activation. */\n loading?: boolean;\n}\n\nexport function Button({\n tone,\n appearance,\n size,\n fullWidth,\n iconOnly,\n start,\n end,\n loading = false,\n disabled,\n className,\n children,\n type = 'button',\n onClick,\n ...rest\n}: ButtonProps) {\n return (\n <button\n {...rest}\n type={type}\n className={cx(button({ tone, appearance, size, fullWidth, iconOnly }), className)}\n disabled={disabled}\n // Loading keeps the button focusable (so focus is not lost) but inert.\n aria-disabled={loading || undefined}\n aria-busy={loading || undefined}\n onClick={loading ? (event) => event.preventDefault() : onClick}\n >\n <span className={cx(slot, loading && hiddenLabel)}>\n {start}\n {children}\n {end}\n </span>\n {loading && (\n <span className={spinnerOverlay} aria-hidden=\"true\">\n <span className={spinner} />\n </span>\n )}\n </button>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"button.js","names":[],"sources":["../../../src/components/button/button.tsx"],"sourcesContent":["import type { ComponentPropsWithRef, ReactNode } from 'react';\nimport { cx } from '../../utils/cx';\nimport { button, hiddenLabel, slot, spinner, spinnerOverlay, type ButtonVariants } from './button.css';\n\nexport interface ButtonProps extends Omit<ComponentPropsWithRef<'button'>, 'color'> {\n /** Color role. */\n tone?: ButtonVariants['tone'];\n /** How much visual weight the button carries. */\n appearance?: ButtonVariants['appearance'];\n size?: ButtonVariants['size'];\n fullWidth?: boolean;\n /** Content before the label, usually an icon. */\n start?: ReactNode;\n /** Content after the label. */\n end?: ReactNode;\n /** Square button for a single icon. Give it an `aria-label`. */\n iconOnly?: boolean;\n /** Shows a spinner, keeps the width, and blocks activation. */\n loading?: boolean;\n}\n\nexport function Button({\n tone,\n appearance,\n size,\n fullWidth,\n iconOnly,\n start,\n end,\n loading = false,\n disabled,\n className,\n children,\n type = 'button',\n onClick,\n ...rest\n}: ButtonProps) {\n return (\n <button\n {...rest}\n type={type}\n className={cx(button({ tone, appearance, size, fullWidth, iconOnly }), className)}\n disabled={disabled}\n // Loading keeps the button focusable (so focus is not lost) but inert.\n aria-disabled={loading || undefined}\n aria-busy={loading || undefined}\n onClick={loading ? (event) => event.preventDefault() : onClick}\n >\n <span className={cx(slot, loading && hiddenLabel)}>\n {start}\n {children}\n {end}\n </span>\n {loading && (\n <span className={spinnerOverlay} aria-hidden=\"true\">\n <span className={spinner} />\n </span>\n )}\n </button>\n );\n}\n"],"mappings":";;;;;AAqBA,SAAgB,OAAO,EACrB,MACA,YACA,MACA,WACA,UACA,OACA,KACA,UAAU,OACV,UACA,WACA,UACA,OAAO,UACP,SACA,GAAG,QACW;CACd,OACE,qBAAC,UAAD;EACE,GAAI;EACE;EACN,WAAW,GAAG,OAAO;GAAE;GAAM;GAAY;GAAM;GAAW;EAAS,CAAC,GAAG,SAAS;EACtE;EAEV,iBAAe,WAAW,KAAA;EAC1B,aAAW,WAAW,KAAA;EACtB,SAAS,WAAW,UAAU,MAAM,eAAe,IAAI;EARzD,UAAA,CAUE,qBAAC,QAAD;GAAM,WAAW,GAAG,MAAM,WAAA,YAAsB;GAAhD,UAAA;IACG;IACA;IACA;GACG;EACL,CAAA,GAAA,WACC,oBAAC,QAAD;GAAM,WAAA;GAA2B,eAAY;GAC3C,UAAA,oBAAC,QAAD,EAAM,WAAA,aAAqB,CAAA;EACvB,CAAA,CAEF;;AAEZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card-media.d.ts","names":[],"sources":["../../../src/components/card/card-media.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"card-media.d.ts","names":[],"sources":["../../../src/components/card/card-media.tsx"],"mappings":";;;iBAKiB,uBAAuB,KAAK;;EAE3C;;EAEA;;EAEA;EACA,UAAU,KAAK;;EAEf;;EAEA;;EAEA,WAAW;;wBAGG,YACd,KACA,KACA,MACA,SAAS,gBACT,OACA,OACA,WACA,OACA,aACG,QACF,iCAAc,IAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card-media.js","names":["styles.media","styles.mediaImage"],"sources":["../../../src/components/card/card-media.tsx"],"sourcesContent":["import { useMemo, type ComponentPropsWithRef, type ReactNode } from 'react';\nimport { artwork, toDataUri, type ArtworkOptions } from '@mohirlab/assets';\nimport { cx } from '../../utils/cx';\nimport * as styles from './card.css';\n\nexport interface CardMediaProps extends Omit<ComponentPropsWithRef<'div'>, 'children'> {\n /** Image URL. */\n src?: string;\n /** Alt text for `src`. Use \"\" for decorative images. */\n alt?: string;\n /** Without `src`: seed for generated artwork, so placeholders stay stable. */\n seed?: string;\n artwork?: Omit<ArtworkOptions, 'width' | 'height'>;\n /** Width / height. Default 16 / 10. */\n ratio?: number;\n /** Bleed to the card edges instead of sitting inset with its own corners. */\n bleed?: boolean;\n /** Overlay content, such as a badge or a bookmark button, pinned to a corner. */\n children?: ReactNode;\n}\n\nexport function CardMedia({\n src,\n alt = '',\n seed = 'mohirlab',\n artwork: artworkOptions,\n ratio = 16 / 10,\n bleed = false,\n className,\n style,\n children,\n ...rest\n}: CardMediaProps) {\n const generated = useMemo(\n () =>\n src\n ? undefined\n : toDataUri(artwork(seed, { ...artworkOptions, width: 640, height: Math.round(640 / ratio) })),\n [src, seed, artworkOptions, ratio],\n );\n\n return (\n <div\n {...rest}\n className={cx(styles.media, bleed && styles.mediaBleed, className)}\n style={{ aspectRatio: String(ratio), ...style }}\n >\n <img\n className={styles.mediaImage}\n src={src ?? generated}\n alt={src ? alt : ''}\n loading=\"lazy\"\n decoding=\"async\"\n />\n {children && <div className={styles.mediaOverlay}>{children}</div>}\n </div>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"card-media.js","names":["styles.media","styles.mediaImage"],"sources":["../../../src/components/card/card-media.tsx"],"sourcesContent":["import { useMemo, type ComponentPropsWithRef, type ReactNode } from 'react';\nimport { artwork, toDataUri, type ArtworkOptions } from '@mohirlab/assets';\nimport { cx } from '../../utils/cx';\nimport * as styles from './card.css';\n\nexport interface CardMediaProps extends Omit<ComponentPropsWithRef<'div'>, 'children'> {\n /** Image URL. */\n src?: string;\n /** Alt text for `src`. Use \"\" for decorative images. */\n alt?: string;\n /** Without `src`: seed for generated artwork, so placeholders stay stable. */\n seed?: string;\n artwork?: Omit<ArtworkOptions, 'width' | 'height'>;\n /** Width / height. Default 16 / 10. */\n ratio?: number;\n /** Bleed to the card edges instead of sitting inset with its own corners. */\n bleed?: boolean;\n /** Overlay content, such as a badge or a bookmark button, pinned to a corner. */\n children?: ReactNode;\n}\n\nexport function CardMedia({\n src,\n alt = '',\n seed = 'mohirlab',\n artwork: artworkOptions,\n ratio = 16 / 10,\n bleed = false,\n className,\n style,\n children,\n ...rest\n}: CardMediaProps) {\n const generated = useMemo(\n () =>\n src\n ? undefined\n : toDataUri(artwork(seed, { ...artworkOptions, width: 640, height: Math.round(640 / ratio) })),\n [src, seed, artworkOptions, ratio],\n );\n\n return (\n <div\n {...rest}\n className={cx(styles.media, bleed && styles.mediaBleed, className)}\n style={{ aspectRatio: String(ratio), ...style }}\n >\n <img\n className={styles.mediaImage}\n src={src ?? generated}\n alt={src ? alt : ''}\n loading=\"lazy\"\n decoding=\"async\"\n />\n {children && <div className={styles.mediaOverlay}>{children}</div>}\n </div>\n );\n}\n"],"mappings":";;;;;;;AAqBA,SAAgB,UAAU,EACxB,KACA,MAAM,IACN,OAAO,YACP,SAAS,gBACT,QAAQ,KAAK,IACb,QAAQ,OACR,WACA,OACA,UACA,GAAG,QACc;CACjB,MAAM,YAAY,cAEd,MACI,KAAA,IACA,UAAU,QAAQ,MAAM;EAAE,GAAG;EAAgB,OAAO;EAAK,QAAQ,KAAK,MAAM,MAAM,KAAK;CAAE,CAAC,CAAC,GACjG;EAAC;EAAK;EAAM;EAAgB;CAAK,CACnC;CAEA,OACE,qBAAC,OAAD;EACE,GAAI;EACJ,WAAW,GAAGA,OAAc,SAAS,eAAmB,SAAS;EACjE,OAAO;GAAE,aAAa,OAAO,KAAK;GAAG,GAAG;EAAM;EAHhD,UAAA,CAKE,oBAAC,OAAD;GACE,WAAWC;GACX,KAAK,OAAO;GACZ,KAAK,MAAM,MAAM;GACjB,SAAQ;GACR,UAAS;EACV,CAAA,GACA,YAAY,oBAAC,OAAD;GAAK,WAAW;GAAsB;EAAc,CAAA,CAC9D;;AAET"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card.css.d.ts","names":[],"sources":["../../../src/components/card/card.css.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"card.css.d.ts","names":[],"sources":["../../../src/components/card/card.css.ts"],"mappings":";;qBASa,yCAAI;;;;;;;;;MAcH;MAAgC;;;;;;;;;;;;;IAYxC;MAAQ;;IACR;MAAM;;IACN;MAAM;;IACN;MAAM;;;;YAMA,eAAe,YAAY,sBAAsB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card.d.ts","names":[],"sources":["../../../src/components/card/card.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"card.d.ts","names":[],"sources":["../../../src/components/card/card.tsx"],"mappings":";;;iBAIiB,kBAAkB;EACjC,YAAY;EACZ,UAAU;;EAEV,KAAK;;wBAGS,OAAO,WAAW,SAAS,IAAI,WAAmB,cAAc,QAAQ,4BAAS,IAAA;wBAIjF,aAAa,cAAc,QAAQ,+CAA4B,IAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card.js","names":[],"sources":["../../../src/components/card/card.tsx"],"sourcesContent":["import type { ComponentPropsWithRef, ElementType } from 'react';\nimport { cx } from '../../utils/cx';\nimport { card, cardHeader, type CardVariants } from './card.css';\n\nexport interface CardProps extends ComponentPropsWithRef<'div'> {\n elevation?: CardVariants['elevation'];\n padding?: CardVariants['padding'];\n /** Render as another element, such as `section` or `article`. */\n as?: ElementType;\n}\n\nexport function Card({ elevation, padding, as: Component = 'div', className, ...rest }: CardProps) {\n return <Component {...rest} className={cx(card({ elevation, padding }), className)} />;\n}\n\nexport function CardHeader({ className, ...rest }: ComponentPropsWithRef<'div'>) {\n return <div {...rest} className={cx(cardHeader, className)} />;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"card.js","names":[],"sources":["../../../src/components/card/card.tsx"],"sourcesContent":["import type { ComponentPropsWithRef, ElementType } from 'react';\nimport { cx } from '../../utils/cx';\nimport { card, cardHeader, type CardVariants } from './card.css';\n\nexport interface CardProps extends ComponentPropsWithRef<'div'> {\n elevation?: CardVariants['elevation'];\n padding?: CardVariants['padding'];\n /** Render as another element, such as `section` or `article`. */\n as?: ElementType;\n}\n\nexport function Card({ elevation, padding, as: Component = 'div', className, ...rest }: CardProps) {\n return <Component {...rest} className={cx(card({ elevation, padding }), className)} />;\n}\n\nexport function CardHeader({ className, ...rest }: ComponentPropsWithRef<'div'>) {\n return <div {...rest} className={cx(cardHeader, className)} />;\n}\n"],"mappings":";;;;;AAWA,SAAgB,KAAK,EAAE,WAAW,SAAS,IAAI,YAAY,OAAO,WAAW,GAAG,QAAmB;CACjG,OAAO,oBAAC,WAAD;EAAW,GAAI;EAAM,WAAW,GAAG,KAAK;GAAE;GAAW;EAAQ,CAAC,GAAG,SAAS;CAAI,CAAA;AACvF;AAEA,SAAgB,WAAW,EAAE,WAAW,GAAG,QAAsC;CAC/E,OAAO,oBAAC,OAAD;EAAK,GAAI;EAAM,WAAW,GAAG,YAAY,SAAS;CAAI,CAAA;AAC/D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choice.d.ts","names":[],"sources":["../../../src/components/choice/choice.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"choice.d.ts","names":[],"sources":["../../../src/components/choice/choice.tsx"],"mappings":";;KAeK,cAAc,KAAK;UAEd;;EAER,OAAO;;EAEP,cAAc;EACd;;iBAmCe,sBAAsB,aAAa;;EAElD;;;wBAIc,WACd,OACA,aACA,SACA,eACA,WACA,QACG,QACF,gCAAa,IAAA;iBAkCC,oBAAoB,aAAa;;;;;wBAMlC,SAAS,OAAO,aAAa,SAAS,cAAc,QAAQ,8BAAW,IAAA;iBAwCtE,wBAAwB,KACvC;;EAIA,QAAQ;;EAER;EACA;EACA;EACA,iBAAiB;EACjB,OAAO;EACP,QAAQ;EACR;EACA,UAAU;;;;;;wBAOI,aACd,QACA,MACA,OACA,cACA,eACA,MACA,OACA,aACA,UACA,WACA,aACG,QACF,kCAAe,IAAA;iBAiDD,mBAAmB,KAAK,sBAAsB,KAAK;EAClE;;;wBAIc,QAAQ,OAAO,aAAa,OAAO,cAAc,QAAQ,6BAAU,IAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choice.js","names":["label","description","styles.item","styles.row","styles.label","styles.box","styles.checkbox","styles.check","styles.dash","styles.track","styles.thumb","legend","styles.group","styles.legend","styles.options","styles.radio","styles.dot"],"sources":["../../../src/components/choice/choice.tsx"],"sourcesContent":["import {\n createContext,\n useContext,\n useEffect,\n useId,\n useRef,\n type ChangeEvent,\n type ComponentPropsWithRef,\n type ReactNode,\n} from 'react';\nimport { iconCheck, iconMinus } from '@mohirlab/icons';\nimport { cx } from '../../utils/cx';\nimport { Icon } from '../icon';\nimport * as styles from './choice.css';\n\ntype NativeInput = Omit<ComponentPropsWithRef<'input'>, 'type' | 'size'>;\n\ninterface ChoiceText {\n /** Visible label. The whole row is clickable. */\n label: ReactNode;\n /** Secondary text under the label, linked with `aria-describedby`. */\n description?: ReactNode;\n invalid?: boolean;\n}\n\nfunction Row({\n control,\n label,\n description,\n descriptionId,\n className,\n kind,\n}: {\n control: ReactNode;\n label: ReactNode;\n description?: ReactNode;\n descriptionId: string;\n className?: string;\n kind?: 'switch';\n}) {\n // The description stays outside the <label>: inside, it would become part of the\n // accessible name. It is linked with aria-describedby instead.\n return (\n <div className={cx(styles.item, className)} data-kind={kind}>\n <label className={styles.row}>\n {control}\n <span className={styles.label}>{label}</span>\n </label>\n {description && (\n <span id={descriptionId} className={styles.description}>\n {description}\n </span>\n )}\n </div>\n );\n}\n\nexport interface CheckboxProps extends NativeInput, ChoiceText {\n /** Mixed state, e.g. \"some items selected\". Shown as a dash; clicking resolves it. */\n indeterminate?: boolean;\n}\n\n/** A native checkbox, drawn in the Mohirlab style. */\nexport function Checkbox({\n label,\n description,\n invalid,\n indeterminate = false,\n className,\n ref,\n ...rest\n}: CheckboxProps) {\n const descriptionId = useId();\n const inner = useRef<HTMLInputElement>(null);\n useEffect(() => {\n if (inner.current) inner.current.indeterminate = indeterminate;\n }, [indeterminate]);\n return (\n <Row\n className={className}\n label={label}\n description={description}\n descriptionId={descriptionId}\n control={\n <span className={styles.box}>\n <input\n {...rest}\n ref={(el) => {\n inner.current = el;\n if (typeof ref === 'function') ref(el);\n else if (ref) ref.current = el;\n }}\n type=\"checkbox\"\n className={styles.checkbox}\n aria-invalid={invalid || undefined}\n aria-describedby={description ? descriptionId : rest['aria-describedby']}\n />\n <Icon icon={iconCheck} size={14} strokeWidth={2.25} className={styles.check} />\n <Icon icon={iconMinus} size={14} strokeWidth={2.25} className={styles.dash} />\n </span>\n }\n />\n );\n}\n\nexport interface SwitchProps extends NativeInput, ChoiceText {}\n\n/**\n * An on/off setting that applies immediately (no Save button). A native checkbox with\n * `role=\"switch\"`, so it is announced as a switch and submits with forms.\n */\nexport function Switch({ label, description, invalid, className, ...rest }: SwitchProps) {\n const descriptionId = useId();\n return (\n <Row\n kind=\"switch\"\n className={className}\n label={label}\n description={description}\n descriptionId={descriptionId}\n control={\n <span className={styles.box}>\n <input\n {...rest}\n type=\"checkbox\"\n // The browser exposes a native checkbox's checked state to the switch role;\n // a hand-set aria-checked could only drift out of sync.\n // oxlint-disable-next-line jsx-a11y/role-has-required-aria-props\n role=\"switch\"\n className={styles.track}\n aria-invalid={invalid || undefined}\n aria-describedby={description ? descriptionId : rest['aria-describedby']}\n />\n <span className={styles.thumb} aria-hidden=\"true\" />\n </span>\n }\n />\n );\n}\n\ninterface RadioGroupContextValue {\n name: string;\n value?: string;\n defaultValue?: string;\n disabled?: boolean;\n invalid: boolean;\n onChange?: (event: ChangeEvent<HTMLInputElement>) => void;\n}\n\nconst RadioGroupContext = createContext<RadioGroupContextValue | null>(null);\n\nexport interface RadioGroupProps extends Omit<\n ComponentPropsWithRef<'fieldset'>,\n 'onChange' | 'defaultValue'\n> {\n /** Names the group for assistive technology. */\n legend: ReactNode;\n /** Shared `name`; generated if omitted. */\n name?: string;\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n hint?: ReactNode;\n error?: ReactNode;\n orientation?: 'vertical' | 'horizontal';\n children: ReactNode;\n}\n\n/**\n * A `<fieldset>` of radios: arrow keys move between options natively, the legend names\n * the group, and hint and error are linked to it.\n */\nexport function RadioGroup({\n legend,\n name,\n value,\n defaultValue,\n onValueChange,\n hint,\n error,\n orientation = 'vertical',\n disabled,\n className,\n children,\n ...rest\n}: RadioGroupProps) {\n const generated = useId();\n const hintId = useId();\n const errorId = useId();\n const legendId = useId();\n const describedBy = [error ? errorId : null, hint ? hintId : null].filter(Boolean).join(' ') || undefined;\n return (\n // role=\"radiogroup\" (rather than the fieldset's implicit \"group\") is what carries\n // aria-invalid for the whole set; individual radios cannot.\n <fieldset\n {...rest}\n role=\"radiogroup\"\n disabled={disabled}\n aria-labelledby={legendId}\n aria-describedby={describedBy}\n aria-invalid={error ? true : undefined}\n className={cx(styles.group, className)}\n >\n <legend id={legendId} className={styles.legend}>\n {legend}\n </legend>\n <RadioGroupContext.Provider\n value={{\n name: name ?? `ml-radio-${generated}`,\n value,\n defaultValue,\n disabled,\n invalid: Boolean(error),\n onChange: onValueChange ? (event) => onValueChange(event.target.value) : undefined,\n }}\n >\n <div className={styles.options} data-orientation={orientation}>\n {children}\n </div>\n </RadioGroupContext.Provider>\n {error && (\n <p id={errorId} className={styles.groupError}>\n {error}\n </p>\n )}\n {hint && (\n <p id={hintId} className={styles.groupHint}>\n {hint}\n </p>\n )}\n </fieldset>\n );\n}\n\nexport interface RadioProps extends Omit<NativeInput, 'name'>, Omit<ChoiceText, 'invalid'> {\n value: string;\n}\n\n/** One option of a `RadioGroup`. */\nexport function Radio({ label, description, value, className, ...rest }: RadioProps) {\n const group = useContext(RadioGroupContext);\n const descriptionId = useId();\n if (!group) throw new Error('<Radio> must be used inside <RadioGroup>.');\n const controlled = group.value !== undefined;\n return (\n <Row\n className={className}\n label={label}\n description={description}\n descriptionId={descriptionId}\n control={\n <span className={styles.box}>\n <input\n {...rest}\n type=\"radio\"\n name={group.name}\n value={value}\n checked={controlled ? group.value === value : undefined}\n defaultChecked={\n !controlled && group.defaultValue !== undefined ? group.defaultValue === value : undefined\n }\n onChange={(event) => {\n rest.onChange?.(event);\n group.onChange?.(event);\n }}\n className={styles.radio}\n aria-describedby={description ? descriptionId : undefined}\n />\n <span className={styles.dot} aria-hidden=\"true\" />\n </span>\n }\n />\n );\n}\n"],"mappings":";;;;;;;AAyBA,SAAS,IAAI,EACX,SACAA,OAAAA,SACAC,aAAAA,eACA,eACA,WACA,QAQC;CAGD,OACE,qBAAC,OAAD;EAAK,WAAW,GAAGC,MAAa,SAAS;EAAG,aAAW;EAAvD,UAAA,CACE,qBAAC,SAAD;GAAO,WAAWC;GAAlB,UAAA,CACG,SACD,oBAAC,QAAD;IAAM,WAAWC;IAAeJ,UAAAA;GAAY,CAAA,CACvC;EACNC,CAAAA,GAAAA,iBACC,oBAAC,QAAD;GAAM,IAAI;GAAe,WAAW;GACjCA,UAAAA;EACG,CAAA,CAEL;;AAET;;AAQA,SAAgB,SAAS,EACvB,OACA,aACA,SACA,gBAAgB,OAChB,WACA,KACA,GAAG,QACa;CAChB,MAAM,gBAAgB,MAAM;CAC5B,MAAM,QAAQ,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,gBACE,CAAC,cAAc,MAAM,iBAAiB,KAAA,IAAY,MAAM,iBAAiB,QAAQ,KAAA;IAEnF,WAAW,UAAU;KACnB,KAAK,WAAW,KAAK;KACrB,MAAM,WAAW,KAAK;IACxB;IACA,WAAWU;IACX,oBAAkB,cAAc,gBAAgB,KAAA;GACjD,CAAA,GACD,oBAAC,QAAD;IAAM,WAAWC;IAAY,eAAY;GAAQ,CAAA,CAC7C;;CAET,CAAA;AAEL"}
|
|
1
|
+
{"version":3,"file":"choice.js","names":["label","description","styles.item","styles.row","styles.label","styles.box","styles.checkbox","styles.check","styles.dash","styles.track","styles.thumb","legend","styles.group","styles.legend","styles.options","styles.radio","styles.dot"],"sources":["../../../src/components/choice/choice.tsx"],"sourcesContent":["import {\n createContext,\n useContext,\n useEffect,\n useId,\n useRef,\n type ChangeEvent,\n type ComponentPropsWithRef,\n type ReactNode,\n} from 'react';\nimport { iconCheck, iconMinus } from '@mohirlab/icons';\nimport { cx } from '../../utils/cx';\nimport { Icon } from '../icon';\nimport * as styles from './choice.css';\n\ntype NativeInput = Omit<ComponentPropsWithRef<'input'>, 'type' | 'size'>;\n\ninterface ChoiceText {\n /** Visible label. The whole row is clickable. */\n label: ReactNode;\n /** Secondary text under the label, linked with `aria-describedby`. */\n description?: ReactNode;\n invalid?: boolean;\n}\n\nfunction Row({\n control,\n label,\n description,\n descriptionId,\n className,\n kind,\n}: {\n control: ReactNode;\n label: ReactNode;\n description?: ReactNode;\n descriptionId: string;\n className?: string;\n kind?: 'switch';\n}) {\n // The description stays outside the <label>: inside, it would become part of the\n // accessible name. It is linked with aria-describedby instead.\n return (\n <div className={cx(styles.item, className)} data-kind={kind}>\n <label className={styles.row}>\n {control}\n <span className={styles.label}>{label}</span>\n </label>\n {description && (\n <span id={descriptionId} className={styles.description}>\n {description}\n </span>\n )}\n </div>\n );\n}\n\nexport interface CheckboxProps extends NativeInput, ChoiceText {\n /** Mixed state, e.g. \"some items selected\". Shown as a dash; clicking resolves it. */\n indeterminate?: boolean;\n}\n\n/** A native checkbox, drawn in the Mohirlab style. */\nexport function Checkbox({\n label,\n description,\n invalid,\n indeterminate = false,\n className,\n ref,\n ...rest\n}: CheckboxProps) {\n const descriptionId = useId();\n const inner = useRef<HTMLInputElement>(null);\n useEffect(() => {\n if (inner.current) inner.current.indeterminate = indeterminate;\n }, [indeterminate]);\n return (\n <Row\n className={className}\n label={label}\n description={description}\n descriptionId={descriptionId}\n control={\n <span className={styles.box}>\n <input\n {...rest}\n ref={(el) => {\n inner.current = el;\n if (typeof ref === 'function') ref(el);\n else if (ref) ref.current = el;\n }}\n type=\"checkbox\"\n className={styles.checkbox}\n aria-invalid={invalid || undefined}\n aria-describedby={description ? descriptionId : rest['aria-describedby']}\n />\n <Icon icon={iconCheck} size={14} strokeWidth={2.25} className={styles.check} />\n <Icon icon={iconMinus} size={14} strokeWidth={2.25} className={styles.dash} />\n </span>\n }\n />\n );\n}\n\nexport interface SwitchProps extends NativeInput, ChoiceText {}\n\n/**\n * An on/off setting that applies immediately (no Save button). A native checkbox with\n * `role=\"switch\"`, so it is announced as a switch and submits with forms.\n */\nexport function Switch({ label, description, invalid, className, ...rest }: SwitchProps) {\n const descriptionId = useId();\n return (\n <Row\n kind=\"switch\"\n className={className}\n label={label}\n description={description}\n descriptionId={descriptionId}\n control={\n <span className={styles.box}>\n <input\n {...rest}\n type=\"checkbox\"\n // The browser exposes a native checkbox's checked state to the switch role;\n // a hand-set aria-checked could only drift out of sync.\n // oxlint-disable-next-line jsx-a11y/role-has-required-aria-props\n role=\"switch\"\n className={styles.track}\n aria-invalid={invalid || undefined}\n aria-describedby={description ? descriptionId : rest['aria-describedby']}\n />\n <span className={styles.thumb} aria-hidden=\"true\" />\n </span>\n }\n />\n );\n}\n\ninterface RadioGroupContextValue {\n name: string;\n value?: string;\n defaultValue?: string;\n disabled?: boolean;\n invalid: boolean;\n onChange?: (event: ChangeEvent<HTMLInputElement>) => void;\n}\n\nconst RadioGroupContext = createContext<RadioGroupContextValue | null>(null);\n\nexport interface RadioGroupProps extends Omit<\n ComponentPropsWithRef<'fieldset'>,\n 'onChange' | 'defaultValue'\n> {\n /** Names the group for assistive technology. */\n legend: ReactNode;\n /** Shared `name`; generated if omitted. */\n name?: string;\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n hint?: ReactNode;\n error?: ReactNode;\n orientation?: 'vertical' | 'horizontal';\n children: ReactNode;\n}\n\n/**\n * A `<fieldset>` of radios: arrow keys move between options natively, the legend names\n * the group, and hint and error are linked to it.\n */\nexport function RadioGroup({\n legend,\n name,\n value,\n defaultValue,\n onValueChange,\n hint,\n error,\n orientation = 'vertical',\n disabled,\n className,\n children,\n ...rest\n}: RadioGroupProps) {\n const generated = useId();\n const hintId = useId();\n const errorId = useId();\n const legendId = useId();\n const describedBy = [error ? errorId : null, hint ? hintId : null].filter(Boolean).join(' ') || undefined;\n return (\n // role=\"radiogroup\" (rather than the fieldset's implicit \"group\") is what carries\n // aria-invalid for the whole set; individual radios cannot.\n <fieldset\n {...rest}\n role=\"radiogroup\"\n disabled={disabled}\n aria-labelledby={legendId}\n aria-describedby={describedBy}\n aria-invalid={error ? true : undefined}\n className={cx(styles.group, className)}\n >\n <legend id={legendId} className={styles.legend}>\n {legend}\n </legend>\n <RadioGroupContext.Provider\n value={{\n name: name ?? `ml-radio-${generated}`,\n value,\n defaultValue,\n disabled,\n invalid: Boolean(error),\n onChange: onValueChange ? (event) => onValueChange(event.target.value) : undefined,\n }}\n >\n <div className={styles.options} data-orientation={orientation}>\n {children}\n </div>\n </RadioGroupContext.Provider>\n {error && (\n <p id={errorId} className={styles.groupError}>\n {error}\n </p>\n )}\n {hint && (\n <p id={hintId} className={styles.groupHint}>\n {hint}\n </p>\n )}\n </fieldset>\n );\n}\n\nexport interface RadioProps extends Omit<NativeInput, 'name'>, Omit<ChoiceText, 'invalid'> {\n value: string;\n}\n\n/** One option of a `RadioGroup`. */\nexport function Radio({ label, description, value, className, ...rest }: RadioProps) {\n const group = useContext(RadioGroupContext);\n const descriptionId = useId();\n if (!group) throw new Error('<Radio> must be used inside <RadioGroup>.');\n const controlled = group.value !== undefined;\n return (\n <Row\n className={className}\n label={label}\n description={description}\n descriptionId={descriptionId}\n control={\n <span className={styles.box}>\n <input\n {...rest}\n type=\"radio\"\n name={group.name}\n value={value}\n checked={controlled ? group.value === value : undefined}\n defaultChecked={\n !controlled && group.defaultValue !== undefined ? group.defaultValue === value : undefined\n }\n onChange={(event) => {\n rest.onChange?.(event);\n group.onChange?.(event);\n }}\n className={styles.radio}\n aria-describedby={description ? descriptionId : undefined}\n />\n <span className={styles.dot} aria-hidden=\"true\" />\n </span>\n }\n />\n );\n}\n"],"mappings":";;;;;;;;AAyBA,SAAS,IAAI,EACX,SACAA,OAAAA,SACAC,aAAAA,eACA,eACA,WACA,QAQC;CAGD,OACE,qBAAC,OAAD;EAAK,WAAW,GAAGC,MAAa,SAAS;EAAG,aAAW;EAAvD,UAAA,CACE,qBAAC,SAAD;GAAO,WAAWC;GAAlB,UAAA,CACG,SACD,oBAAC,QAAD;IAAM,WAAWC;IAAeJ,UAAAA;GAAY,CAAA,CACvC;EACNC,CAAAA,GAAAA,iBACC,oBAAC,QAAD;GAAM,IAAI;GAAe,WAAW;GACjCA,UAAAA;EACG,CAAA,CAEL;;AAET;;AAQA,SAAgB,SAAS,EACvB,OACA,aACA,SACA,gBAAgB,OAChB,WACA,KACA,GAAG,QACa;CAChB,MAAM,gBAAgB,MAAM;CAC5B,MAAM,QAAQ,OAAyB,IAAI;CAC3C,gBAAgB;EACd,IAAI,MAAM,SAAS,MAAM,QAAQ,gBAAgB;CACnD,GAAG,CAAC,aAAa,CAAC;CAClB,OACE,oBAAC,KAAD;EACa;EACJ;EACM;EACE;EACf,SACE,qBAAC,QAAD;GAAM,WAAWI;GAAjB,UAAA;IACE,oBAAC,SAAD;KACE,GAAI;KACJ,MAAM,OAAO;MACX,MAAM,UAAU;MAChB,IAAI,OAAO,QAAQ,YAAY,IAAI,EA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+1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.css.d.ts","names":[],"sources":["../../../src/components/dialog/dialog.css.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"dialog.css.d.ts","names":[],"sources":["../../../src/components/dialog/dialog.css.ts"],"mappings":";;cAWM;qBAmBO,2CAAM;;;;;;;;;;SA4BE;;;;;SACA;;;;;SACA;;;;;YAMT,iBAAiB,YAAY,sBAAsB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.d.ts","names":["styles.DialogVariants"],"sources":["../../../src/components/dialog/dialog.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"dialog.d.ts","names":["styles.DialogVariants"],"sources":["../../../src/components/dialog/dialog.tsx"],"mappings":";;;iBAiBiB,oBAAoB,KAAK;EACxC;EACA,eAAe;;EAEf,OAAO;EACP,cAAc;;EAEd,YAAYA;EACZ,OAAOA;;;;;EAKP;EACA;;EAEA;EACA,WAAW;;;;;;wBAUG,SACd,MACA,cACA,OACA,aACA,WACA,MACA,aACA,MACA,YACA,WACA,aACG,QACF,8BAAW,IAAA;;wBAgJE,aAAa,cAAc,QAAQ,+CAA4B,IAAA;;;;;wBAQ/D,gBAAgB,cAAc,QAAQ,+CAA4B,IAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.js","names":["title","description","styles.dialog","styles.dragArea","styles.handle","styles.header","styles.title","styles.body","styles.actions"],"sources":["../../../src/components/dialog/dialog.tsx"],"sourcesContent":["import {\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n type ComponentPropsWithRef,\n type PointerEvent as ReactPointerEvent,\n type ReactNode,\n} from 'react';\nimport { iconClose } from '@mohirlab/icons';\nimport { mq } from '@mohirlab/sprinkles';\nimport { usePresence } from '../../hooks/use-presence';\nimport { cx } from '../../utils/cx';\nimport { Button } from '../button';\nimport { Icon } from '../icon';\nimport * as styles from './dialog.css';\n\nexport interface DialogProps extends Omit<ComponentPropsWithRef<'dialog'>, 'open' | 'title' | 'role'> {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** Required: names the dialog for assistive technology. */\n title: ReactNode;\n description?: ReactNode;\n /** `auto` (default): bottom sheet on phones, centered from tablet up. */\n placement?: styles.DialogVariants['placement'];\n size?: styles.DialogVariants['size'];\n /**\n * Whether Escape, the backdrop and the close button may dismiss it. Turn off for\n * decisions the user must make; pair with `role=\"alertdialog\"`.\n */\n dismissible?: boolean;\n role?: 'dialog' | 'alertdialog';\n /** Label of the close button, for localisation. */\n closeLabel?: string;\n children?: ReactNode;\n}\n\nconst DISMISS_DISTANCE = 0.3; // fraction of the sheet's height\nconst DISMISS_VELOCITY = 0.6; // px per ms\n\n/**\n * A modal dialog on the native `<dialog>` element: the browser traps focus, makes the\n * rest of the page inert, handles Escape and returns focus when it closes.\n */\nexport function Dialog({\n open,\n onOpenChange,\n title,\n description,\n placement = 'auto',\n size,\n dismissible = true,\n role = 'dialog',\n closeLabel = 'Close',\n className,\n children,\n ...rest\n}: DialogProps) {\n const ref = useRef<HTMLDialogElement>(null);\n const titleId = useId();\n const descriptionId = useId();\n const { mounted, state } = usePresence(open, ref, {\n onExitComplete: () => ref.current?.open && ref.current.close(),\n });\n\n // Open as a modal as soon as the element exists.\n useLayoutEffect(() => {\n const el = ref.current;\n if (mounted && open && el && !el.open) el.showModal();\n }, [mounted, open]);\n\n // The page behind must not scroll while a modal is open.\n useEffect(() => {\n if (!mounted) return;\n const root = document.documentElement;\n const previous = root.style.overflow;\n root.style.overflow = 'hidden';\n return () => {\n root.style.overflow = previous;\n };\n }, [mounted]);\n\n const requestClose = () => {\n if (dismissible) onOpenChange(false);\n };\n\n // --- Drag a sheet down to dismiss it --------------------------------------------\n const drag = useRef<{ startY: number; startTime: number; dy: number } | null>(null);\n const isSheetNow = () =>\n placement === 'sheet' || (placement === 'auto' && !window.matchMedia(mq('tablet')).matches);\n\n const onPointerDown = (event: ReactPointerEvent<HTMLDivElement>) => {\n if (!dismissible || !isSheetNow() || (event.target as Element).closest('button, a, input')) return;\n event.currentTarget.setPointerCapture(event.pointerId);\n drag.current = { startY: event.clientY, startTime: performance.now(), dy: 0 };\n };\n const onPointerMove = (event: ReactPointerEvent<HTMLDivElement>) => {\n const el = ref.current;\n if (!drag.current || !el) return;\n drag.current.dy = Math.max(0, event.clientY - drag.current.startY);\n el.style.transition = 'none';\n el.style.transform = `translateY(${drag.current.dy}px)`;\n };\n const onPointerUp = () => {\n const el = ref.current;\n const current = drag.current;\n drag.current = null;\n if (!current || !el) return;\n const velocity = current.dy / Math.max(1, performance.now() - current.startTime);\n if (current.dy > el.offsetHeight * DISMISS_DISTANCE || velocity > DISMISS_VELOCITY) {\n // The exit animation continues from where the finger let go.\n onOpenChange(false);\n return;\n }\n el.style.transition = '';\n el.style.transform = '';\n };\n\n // Reset any drag offset once the sheet has gone.\n useEffect(() => {\n if (!mounted && ref.current) {\n ref.current.style.transform = '';\n ref.current.style.transition = '';\n }\n }, [mounted]);\n\n if (!mounted) return null;\n\n return (\n // oxlint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions -- backdrop click; Escape is the keyboard equivalent\n <dialog\n {...rest}\n ref={ref}\n role={role === 'alertdialog' ? 'alertdialog' : undefined}\n aria-modal=\"true\"\n aria-labelledby={titleId}\n aria-describedby={description ? descriptionId : undefined}\n data-state={state}\n data-placement={placement}\n className={cx(styles.dialog({ placement, size }), className)}\n onCancel={(event) => {\n // Escape: we close through state so the exit animation can run.\n event.preventDefault();\n requestClose();\n }}\n onClose={() => {\n // Closed by the browser or a <form method=\"dialog\">: keep state in sync.\n if (open) onOpenChange(false);\n }}\n onClick={(event) => {\n // A click on the backdrop lands on the <dialog> itself, outside its box.\n if (event.target !== ref.current) return;\n const box = ref.current.getBoundingClientRect();\n const inside =\n event.clientX >= box.left &&\n event.clientX <= box.right &&\n event.clientY >= box.top &&\n event.clientY <= box.bottom;\n if (!inside) requestClose();\n }}\n >\n <div\n className={styles.dragArea}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerUp}\n onPointerCancel={onPointerUp}\n >\n <span className={styles.handle} aria-hidden=\"true\" />\n <div className={styles.header}>\n <h2 id={titleId} className={styles.title}>\n {title}\n </h2>\n {description && (\n <p id={descriptionId} className={styles.description}>\n {description}\n </p>\n )}\n </div>\n </div>\n {children}\n {/* Last in tab order, so focus starts in the content; shown top-right. */}\n {dismissible && (\n <span className={styles.close}>\n <Button\n appearance=\"ghost\"\n tone=\"neutral\"\n size=\"sm\"\n iconOnly\n aria-label={closeLabel}\n onClick={requestClose}\n >\n <Icon icon={iconClose} />\n </Button>\n </span>\n )}\n </dialog>\n );\n}\n\n/** Scrollable content area of a dialog. */\nexport function DialogBody({ className, ...rest }: ComponentPropsWithRef<'div'>) {\n return <div {...rest} className={cx(styles.body, className)} />;\n}\n\n/**\n * The dialog's buttons. Put the primary action last: it lands on the right of a\n * centered dialog and on top of the full-width stack in a sheet.\n */\nexport function DialogActions({ className, ...rest }: ComponentPropsWithRef<'div'>) {\n return <div {...rest} className={cx(styles.actions, className)} />;\n}\n"],"mappings":";;;;;;;;;;AAqCA,MAAM,mBAAmB;AACzB,MAAM,mBAAmB;;;;;AAMzB,SAAgB,OAAO,EACrB,MACA,cACAA,OAAAA,SACAC,aAAAA,eACA,YAAY,QACZ,MACA,cAAc,MACd,OAAO,UACP,aAAa,SACb,WACA,UACA,GAAG,QACW;CACd,MAAM,MAAM,OAA0B,IAAI;CAC1C,MAAM,UAAU,MAAM;CACtB,MAAM,gBAAgB,MAAM;CAC5B,MAAM,EAAE,SAAS,UAAU,YAAY,MAAM,KAAK,EAChD,sBAAsB,IAAI,SAAS,QAAQ,IAAI,QAAQ,MAAM,EAC/D,CAAC;CAGD,sBAAsB;EACpB,MAAM,KAAK,IAAI;EACf,IAAI,WAAW,QAAQ,MAAM,CAAC,GAAG,MAAM,GAAG,UAAU;CACtD,GAAG,CAAC,SAAS,IAAI,CAAC;CAGlB,g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A;GACJ,CAAA;EAEF;;AAEZ;;AAGA,SAAgB,WAAW,EAAE,WAAW,GAAG,QAAsC;CAC/E,OAAO,oBAAC,OAAD;EAAK,GAAI;EAAM,WAAW,GAAGM,MAAa,SAAS;CAAI,CAAA;AAChE;;;;;AAMA,SAAgB,cAAc,EAAE,WAAW,GAAG,QAAsC;CAClF,OAAO,oBAAC,OAAD;EAAK,GAAI;EAAM,WAAW,GAAGC,SAAgB,SAAS;CAAI,CAAA;AACnE"}
|
|
1
|
+
{"version":3,"file":"dialog.js","names":["title","description","styles.dialog","styles.dragArea","styles.handle","styles.header","styles.title","styles.body","styles.actions"],"sources":["../../../src/components/dialog/dialog.tsx"],"sourcesContent":["import {\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n type ComponentPropsWithRef,\n type PointerEvent as ReactPointerEvent,\n type ReactNode,\n} from 'react';\nimport { iconClose } from '@mohirlab/icons';\nimport { mq } from '@mohirlab/sprinkles';\nimport { usePresence } from '../../hooks/use-presence';\nimport { cx } from '../../utils/cx';\nimport { Button } from '../button';\nimport { Icon } from '../icon';\nimport * as styles from './dialog.css';\n\nexport interface DialogProps extends Omit<ComponentPropsWithRef<'dialog'>, 'open' | 'title' | 'role'> {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** Required: names the dialog for assistive technology. */\n title: ReactNode;\n description?: ReactNode;\n /** `auto` (default): bottom sheet on phones, centered from tablet up. */\n placement?: styles.DialogVariants['placement'];\n size?: styles.DialogVariants['size'];\n /**\n * Whether Escape, the backdrop and the close button may dismiss it. Turn off for\n * decisions the user must make; pair with `role=\"alertdialog\"`.\n */\n dismissible?: boolean;\n role?: 'dialog' | 'alertdialog';\n /** Label of the close button, for localisation. */\n closeLabel?: string;\n children?: ReactNode;\n}\n\nconst DISMISS_DISTANCE = 0.3; // fraction of the sheet's height\nconst DISMISS_VELOCITY = 0.6; // px per ms\n\n/**\n * A modal dialog on the native `<dialog>` element: the browser traps focus, makes the\n * rest of the page inert, handles Escape and returns focus when it closes.\n */\nexport function Dialog({\n open,\n onOpenChange,\n title,\n description,\n placement = 'auto',\n size,\n dismissible = true,\n role = 'dialog',\n closeLabel = 'Close',\n className,\n children,\n ...rest\n}: DialogProps) {\n const ref = useRef<HTMLDialogElement>(null);\n const titleId = useId();\n const descriptionId = useId();\n const { mounted, state } = usePresence(open, ref, {\n onExitComplete: () => ref.current?.open && ref.current.close(),\n });\n\n // Open as a modal as soon as the element exists.\n useLayoutEffect(() => {\n const el = ref.current;\n if (mounted && open && el && !el.open) el.showModal();\n }, [mounted, open]);\n\n // The page behind must not scroll while a modal is open.\n useEffect(() => {\n if (!mounted) return;\n const root = document.documentElement;\n const previous = root.style.overflow;\n root.style.overflow = 'hidden';\n return () => {\n root.style.overflow = previous;\n };\n }, [mounted]);\n\n const requestClose = () => {\n if (dismissible) onOpenChange(false);\n };\n\n // --- Drag a sheet down to dismiss it --------------------------------------------\n const drag = useRef<{ startY: number; startTime: number; dy: number } | null>(null);\n const isSheetNow = () =>\n placement === 'sheet' || (placement === 'auto' && !window.matchMedia(mq('tablet')).matches);\n\n const onPointerDown = (event: ReactPointerEvent<HTMLDivElement>) => {\n if (!dismissible || !isSheetNow() || (event.target as Element).closest('button, a, input')) return;\n event.currentTarget.setPointerCapture(event.pointerId);\n drag.current = { startY: event.clientY, startTime: performance.now(), dy: 0 };\n };\n const onPointerMove = (event: ReactPointerEvent<HTMLDivElement>) => {\n const el = ref.current;\n if (!drag.current || !el) return;\n drag.current.dy = Math.max(0, event.clientY - drag.current.startY);\n el.style.transition = 'none';\n el.style.transform = `translateY(${drag.current.dy}px)`;\n };\n const onPointerUp = () => {\n const el = ref.current;\n const current = drag.current;\n drag.current = null;\n if (!current || !el) return;\n const velocity = current.dy / Math.max(1, performance.now() - current.startTime);\n if (current.dy > el.offsetHeight * DISMISS_DISTANCE || velocity > DISMISS_VELOCITY) {\n // The exit animation continues from where the finger let go.\n onOpenChange(false);\n return;\n }\n el.style.transition = '';\n el.style.transform = '';\n };\n\n // Reset any drag offset once the sheet has gone.\n useEffect(() => {\n if (!mounted && ref.current) {\n ref.current.style.transform = '';\n ref.current.style.transition = '';\n }\n }, [mounted]);\n\n if (!mounted) return null;\n\n return (\n // oxlint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions -- backdrop click; Escape is the keyboard equivalent\n <dialog\n {...rest}\n ref={ref}\n role={role === 'alertdialog' ? 'alertdialog' : undefined}\n aria-modal=\"true\"\n aria-labelledby={titleId}\n aria-describedby={description ? descriptionId : undefined}\n data-state={state}\n data-placement={placement}\n className={cx(styles.dialog({ placement, size }), className)}\n onCancel={(event) => {\n // Escape: we close through state so the exit animation can run.\n event.preventDefault();\n requestClose();\n }}\n onClose={() => {\n // Closed by the browser or a <form method=\"dialog\">: keep state in sync.\n if (open) onOpenChange(false);\n }}\n onClick={(event) => {\n // A click on the backdrop lands on the <dialog> itself, outside its box.\n if (event.target !== ref.current) return;\n const box = ref.current.getBoundingClientRect();\n const inside =\n event.clientX >= box.left &&\n event.clientX <= box.right &&\n event.clientY >= box.top &&\n event.clientY <= box.bottom;\n if (!inside) requestClose();\n }}\n >\n <div\n className={styles.dragArea}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerUp}\n onPointerCancel={onPointerUp}\n >\n <span className={styles.handle} aria-hidden=\"true\" />\n <div className={styles.header}>\n <h2 id={titleId} className={styles.title}>\n {title}\n </h2>\n {description && (\n <p id={descriptionId} className={styles.description}>\n {description}\n </p>\n )}\n </div>\n </div>\n {children}\n {/* Last in tab order, so focus starts in the content; shown top-right. */}\n {dismissible && (\n <span className={styles.close}>\n <Button\n appearance=\"ghost\"\n tone=\"neutral\"\n size=\"sm\"\n iconOnly\n aria-label={closeLabel}\n onClick={requestClose}\n >\n <Icon icon={iconClose} />\n </Button>\n </span>\n )}\n </dialog>\n );\n}\n\n/** Scrollable content area of a dialog. */\nexport function DialogBody({ className, ...rest }: ComponentPropsWithRef<'div'>) {\n return <div {...rest} className={cx(styles.body, className)} />;\n}\n\n/**\n * The dialog's buttons. Put the primary action last: it lands on the right of a\n * centered dialog and on top of the full-width stack in a sheet.\n */\nexport function DialogActions({ className, ...rest }: ComponentPropsWithRef<'div'>) {\n return <div {...rest} className={cx(styles.actions, className)} />;\n}\n"],"mappings":";;;;;;;;;;;AAqCA,MAAM,mBAAmB;AACzB,MAAM,mBAAmB;;;;;AAMzB,SAAgB,OAAO,EACrB,MACA,cACAA,OAAAA,SACAC,aAAAA,eACA,YAAY,QACZ,MACA,cAAc,MACd,OAAO,UACP,aAAa,SACb,WACA,UACA,GAAG,QACW;CACd,MAAM,MAAM,OAA0B,IAAI;CAC1C,MAAM,UAAU,MAAM;CACtB,MAAM,gBAAgB,MAAM;CAC5B,MAAM,EAAE,SAAS,UAAU,YAAY,MAAM,KAAK,EAChD,sBAAsB,IAAI,SAAS,QAAQ,IAAI,QAAQ,MAAM,EAC/D,CAAC;CAGD,sBAAsB;EACpB,MAAM,KAAK,IAAI;EACf,IAAI,WAAW,QAAQ,MAAM,CAAC,GAAG,MAAM,GAAG,UAAU;CACtD,GAAG,CAAC,SAAS,IAAI,CAAC;CAGlB,gBAAgB;EACd,IAAI,CAAC,SAAS;EACd,MAAM,OAAO,SAAS;EACtB,MAAM,WAAW,KAAK,MAAM;EAC5B,KAAK,MAAM,WAAW;EACtB,aAAa;GACX,KAAK,MAAM,WAAW;EACxB;CACF,GAAG,CAAC,OAAO,CAAC;CAEZ,MAAM,qBAAqB;EACzB,IAAI,aAAa,aAAa,KAAK;CACrC;CAGA,MAAM,OAAO,OAAiE,IAAI;CAClF,MAAM,mBACJ,cAAc,WAAY,cAAc,UAAU,CAAC,OAAO,WAAW,GAAG,QAAQ,CAAC,CAAC,CAAC;CAErF,MAAM,iBAAiB,UAA6C;EAClE,IAAI,CAAC,eAAe,CAAC,WAAW,KAAM,MAAM,OAAmB,QAAQ,kBAAkB,GAAG;EAC5F,MAAM,cAAc,kBAAkB,MAAM,SAA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AW,IAAI,SAAS;GAClC,MAAM,MAAM,IAAI,QAAQ,sBAAsB;GAM9C,IAAI,EAJF,MAAM,WAAW,IAAI,QACrB,MAAM,WAAW,IAAI,SACrB,MAAM,WAAW,IAAI,OACrB,MAAM,WAAW,IAAI,SACV,aAAa;EAC5B;EA7BF,UAAA;GA+BE,qBAAC,OAAD;IACE,WAAWC;IACI;IACA;IACF;IACb,iBAAiB;IALnB,UAAA,CAOE,oBAAC,QAAD;KAAM,WAAWC;KAAe,eAAY;IAAQ,CAAA,GACpD,qBAAC,OAAD;KAAK,WAAWC;KAAhB,UAAA,CACE,oBAAC,MAAD;MAAI,IAAI;MAAS,WAAWC;MACzBN,UAAAA;KACC,CAAA,GACHC,iBACC,oBAAC,KAAD;MAAG,IAAI;MAAe,WAAW;MAC9BA,UAAAA;KACA,CAAA,CAEF;IACF,CAAA,CAAA;;GACJ;GAEA,eACC,oBAAC,QAAD;IAAM,WAAW;IACf,UAAA,oBAAC,QAAD;KACE,YAAW;KACX,MAAK;KACL,MAAK;KACL,UAAA;KACA,cAAY;KACZ,SAAS;KAET,UAAA,oBAAC,MAAD,EAAM,MAAM,UAAY,CAAA;IAClB,CAAA;GACJ,CAAA;EAEF;;AAEZ;;AAGA,SAAgB,WAAW,EAAE,WAAW,GAAG,QAAsC;CAC/E,OAAO,oBAAC,OAAD;EAAK,GAAI;EAAM,WAAW,GAAGM,MAAa,SAAS;CAAI,CAAA;AAChE;;;;;AAMA,SAAgB,cAAc,EAAE,WAAW,GAAG,QAAsC;CAClF,OAAO,oBAAC,OAAD;EAAK,GAAI;EAAM,WAAW,GAAGC,SAAgB,SAAS;CAAI,CAAA;AACnE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-context.d.ts","names":[],"sources":["../../../src/components/field/field-context.ts"],"mappings":"A,iBAEiB;EACf;EACA;EACA;EACA;EACA;;;qBAMW,gBAAQ"}
|
|
1
|
+
{"version":3,"file":"field-context.d.ts","names":[],"sources":["../../../src/components/field/field-context.ts"],"mappings":";A,iBAEiB;EACf;EACA;EACA;EACA;EACA;;;qBAMW,gBAAQ"}
|