@chayns-ui/core 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -3
- package/dist/accordion.css +66 -2
- package/dist/badge.css +3 -3
- package/dist/banner.css +89 -0
- package/dist/button.css +16 -2
- package/dist/card.css +29 -2
- package/dist/checkbox.css +24 -13
- package/dist/combo-box.css +20 -2
- package/dist/components/accordion/Accordion.d.ts +10 -2
- package/dist/components/accordion/Accordion.d.ts.map +1 -1
- package/dist/components/accordion/Accordion.js +120 -46
- package/dist/components/accordion/Accordion.js.map +1 -1
- package/dist/components/accordion/Accordion.types.d.ts +24 -1
- package/dist/components/accordion/Accordion.types.d.ts.map +1 -1
- package/dist/components/accordion/Accordion.types.js +6 -0
- package/dist/components/accordion/Accordion.types.js.map +1 -0
- package/dist/components/accordion/AccordionContext.d.ts +9 -0
- package/dist/components/accordion/AccordionContext.d.ts.map +1 -1
- package/dist/components/accordion/AccordionContext.js +8 -2
- package/dist/components/accordion/AccordionContext.js.map +1 -1
- package/dist/components/accordion-group/AccordionGroup.d.ts +1 -1
- package/dist/components/accordion-group/AccordionGroup.d.ts.map +1 -1
- package/dist/components/accordion-group/AccordionGroup.js +3 -3
- package/dist/components/accordion-group/AccordionGroup.js.map +1 -1
- package/dist/components/avatar/Avatar.js +1 -1
- package/dist/components/avatar-group/AvatarGroup.js +1 -1
- package/dist/components/badge/Badge.js +1 -1
- package/dist/components/banner/Banner.d.ts +3 -0
- package/dist/components/banner/Banner.d.ts.map +1 -0
- package/dist/components/banner/Banner.js +46 -0
- package/dist/components/banner/Banner.js.map +1 -0
- package/dist/components/banner/Banner.types.d.ts +24 -0
- package/dist/components/banner/Banner.types.d.ts.map +1 -0
- package/dist/components/banner/Banner.types.js +11 -0
- package/dist/components/banner/Banner.types.js.map +1 -0
- package/dist/components/button/Button.d.ts +1 -1
- package/dist/components/button/Button.d.ts.map +1 -1
- package/dist/components/button/Button.js +8 -3
- package/dist/components/button/Button.js.map +1 -1
- package/dist/components/button/Button.types.d.ts +15 -11
- package/dist/components/button/Button.types.d.ts.map +1 -1
- package/dist/components/button/Button.types.js.map +1 -1
- package/dist/components/button/button-icon/ButtonIcon.d.ts.map +1 -1
- package/dist/components/button/button-icon/ButtonIcon.js +18 -12
- package/dist/components/button/button-icon/ButtonIcon.js.map +1 -1
- package/dist/components/card/Card.d.ts +4 -2
- package/dist/components/card/Card.d.ts.map +1 -1
- package/dist/components/card/Card.js +24 -8
- package/dist/components/card/Card.js.map +1 -1
- package/dist/components/card/Card.types.d.ts +10 -12
- package/dist/components/card/Card.types.d.ts.map +1 -1
- package/dist/components/checkbox/Checkbox.d.ts +1 -1
- package/dist/components/checkbox/Checkbox.d.ts.map +1 -1
- package/dist/components/checkbox/Checkbox.js +15 -6
- package/dist/components/checkbox/Checkbox.js.map +1 -1
- package/dist/components/checkbox/Checkbox.types.d.ts +2 -0
- package/dist/components/checkbox/Checkbox.types.d.ts.map +1 -1
- package/dist/components/combo-box/ComboBox.d.ts.map +1 -1
- package/dist/components/combo-box/ComboBox.js +19 -2
- package/dist/components/combo-box/ComboBox.js.map +1 -1
- package/dist/components/date-time-picker/DateTimePicker.d.ts +4 -0
- package/dist/components/date-time-picker/DateTimePicker.d.ts.map +1 -0
- package/dist/components/date-time-picker/DateTimePicker.js +339 -0
- package/dist/components/date-time-picker/DateTimePicker.js.map +1 -0
- package/dist/components/date-time-picker/DateTimePicker.types.d.ts +26 -0
- package/dist/components/date-time-picker/DateTimePicker.types.d.ts.map +1 -0
- package/dist/components/date-time-picker/DateTimePicker.types.js +12 -0
- package/dist/components/date-time-picker/DateTimePicker.types.js.map +1 -0
- package/dist/components/icon-button/IconButton.d.ts +7 -2
- package/dist/components/icon-button/IconButton.d.ts.map +1 -1
- package/dist/components/icon-button/IconButton.js +8 -3
- package/dist/components/icon-button/IconButton.js.map +1 -1
- package/dist/components/icon-button/IconButton.types.d.ts +7 -4
- package/dist/components/icon-button/IconButton.types.d.ts.map +1 -1
- package/dist/components/list/List.js +1 -1
- package/dist/components/popup/Popup.js +1 -1
- package/dist/components/popup/PopupList.js +1 -1
- package/dist/components/radio-group/RadioGroup.d.ts.map +1 -1
- package/dist/components/radio-group/RadioGroup.js +17 -8
- package/dist/components/radio-group/RadioGroup.js.map +1 -1
- package/dist/components/radio-group/RadioGroup.types.d.ts +5 -3
- package/dist/components/radio-group/RadioGroup.types.d.ts.map +1 -1
- package/dist/components/segmented-control/SegmentedControl.d.ts.map +1 -1
- package/dist/components/segmented-control/SegmentedControl.js +12 -5
- package/dist/components/segmented-control/SegmentedControl.js.map +1 -1
- package/dist/components/segmented-control/SegmentedControl.types.d.ts +5 -2
- package/dist/components/segmented-control/SegmentedControl.types.d.ts.map +1 -1
- package/dist/components/split-button/SplitButton.d.ts +1 -1
- package/dist/components/split-button/SplitButton.d.ts.map +1 -1
- package/dist/components/split-button/SplitButton.js +9 -17
- package/dist/components/split-button/SplitButton.js.map +1 -1
- package/dist/components/switch/Switch.d.ts +1 -1
- package/dist/components/switch/Switch.d.ts.map +1 -1
- package/dist/components/switch/Switch.js +13 -5
- package/dist/components/switch/Switch.js.map +1 -1
- package/dist/components/switch/Switch.types.d.ts +2 -0
- package/dist/components/switch/Switch.types.d.ts.map +1 -1
- package/dist/components/text-area/TextArea.d.ts +1 -1
- package/dist/components/text-area/TextArea.d.ts.map +1 -1
- package/dist/components/text-area/TextArea.js +5 -4
- package/dist/components/text-area/TextArea.js.map +1 -1
- package/dist/components/text-field/TextField.d.ts +1 -1
- package/dist/components/text-field/TextField.d.ts.map +1 -1
- package/dist/components/text-field/TextField.js +5 -4
- package/dist/components/text-field/TextField.js.map +1 -1
- package/dist/date-time-picker.css +121 -0
- package/dist/index.d.ts +9 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/list.css +4 -4
- package/dist/radio-group.css +13 -1
- package/dist/segmented-control.css +24 -7
- package/dist/split-button.css +1 -1
- package/dist/styles.css +2 -1
- package/dist/switch.css +18 -5
- package/dist/text-area.css +2 -2
- package/dist/text-field.css +1 -1
- package/package.json +3 -2
- package/dist/components/message-box/MessageBox.d.ts +0 -4
- package/dist/components/message-box/MessageBox.d.ts.map +0 -1
- package/dist/components/message-box/MessageBox.js +0 -19
- package/dist/components/message-box/MessageBox.js.map +0 -1
- package/dist/components/message-box/MessageBox.types.d.ts +0 -13
- package/dist/components/message-box/MessageBox.types.d.ts.map +0 -1
- package/dist/message-box.css +0 -26
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accordion.js","names":[],"sources":["../../../src/components/accordion/Accordion.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"Accordion.js","names":[],"sources":["../../../src/components/accordion/Accordion.tsx"],"sourcesContent":["import {\n Children,\n createElement,\n forwardRef,\n isValidElement,\n useContext,\n useId,\n useState,\n} from 'react';\nimport type { MouseEvent, ReactElement } from 'react';\n\nimport {\n AccordionDepthContext,\n AccordionGroupContext,\n AccordionItemContext,\n useAccordionItemContext,\n} from './AccordionContext.js';\nimport type {\n AccordionContentProps,\n AccordionHeadContentProps,\n AccordionHeadProps,\n AccordionPartProps,\n AccordionProps,\n} from './Accordion.types.js';\n\nfunction Part({ children, className, name }: AccordionPartProps & { name: string }) {\n useAccordionItemContext(name);\n return (\n <span\n className={[`chayns-accordion__${name.toLowerCase()}`, className].filter(Boolean).join(' ')}\n >\n {children}\n </span>\n );\n}\n\nconst HeadLeading = (props: AccordionPartProps) => <Part {...props} name=\"leading\" />;\nconst HeadTrailing = (props: AccordionPartProps) => <Part {...props} name=\"trailing\" />;\n\nfunction HeadContent({ className, subtitle, title }: AccordionHeadContentProps) {\n useAccordionItemContext('Head.Content');\n\n return (\n <span className={['chayns-accordion__head-content', className].filter(Boolean).join(' ')}>\n <span className=\"chayns-accordion__title\">{title}</span>\n {subtitle ? <span className=\"chayns-accordion__subtitle\">{subtitle}</span> : null}\n </span>\n );\n}\n\nconst AccordionHead = forwardRef<HTMLButtonElement, AccordionHeadProps>(function AccordionHead(\n { children, className, onClick, ...buttonProps },\n ref,\n) {\n const { disabled, headerId, isOpen, onToggle, panelId } = useAccordionItemContext('Head');\n\n function handleClick(event: MouseEvent<HTMLButtonElement>) {\n onClick?.(event);\n if (!event.defaultPrevented) onToggle();\n }\n\n return (\n <button\n {...buttonProps}\n aria-controls={panelId}\n aria-expanded={isOpen}\n className={['chayns-accordion__header', className].filter(Boolean).join(' ')}\n disabled={disabled}\n id={headerId}\n onClick={handleClick}\n ref={ref}\n type=\"button\"\n >\n <i aria-hidden=\"true\" className=\"chayns-accordion__chevron far fa-chevron-right\" />\n {children}\n </button>\n );\n});\n\nconst AccordionContent = forwardRef<HTMLDivElement, AccordionContentProps>(\n function AccordionContent({ children, className, ...panelProps }, ref) {\n const depth = useContext(AccordionDepthContext);\n const { headerId, isOpen, panelId } = useAccordionItemContext('Content');\n\n return (\n <div\n {...panelProps}\n aria-hidden={!isOpen}\n aria-labelledby={headerId}\n className={['chayns-accordion__panel', className].filter(Boolean).join(' ')}\n id={panelId}\n inert={!isOpen}\n ref={ref}\n role=\"region\"\n style={{ ...panelProps.style, gridTemplateRows: isOpen ? '1fr' : '0fr' }}\n >\n <div className=\"chayns-accordion__inner\">\n <div className=\"chayns-accordion__content\">\n <AccordionDepthContext.Provider value={depth + 1}>\n {children}\n </AccordionDepthContext.Provider>\n </div>\n </div>\n </div>\n );\n },\n);\n\nconst AccordionRoot = forwardRef<HTMLDivElement, AccordionProps>(function Accordion(\n {\n appearance = 'default',\n children,\n className,\n defaultOpen = false,\n disabled = false,\n id,\n leading,\n onOpenChange,\n open,\n subtitle,\n title,\n ...rootProps\n },\n ref,\n) {\n const depth = useContext(AccordionDepthContext);\n const group = useContext(AccordionGroupContext);\n const generatedId = useId();\n const baseId = id ?? generatedId;\n const headerId = `${baseId}-header`;\n const panelId = `${baseId}-panel`;\n const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);\n const isGrouped = group !== null && depth === 0;\n const isOpen = isGrouped ? group.isOpen(baseId) : (open ?? uncontrolledOpen);\n const wrapped = depth > 0;\n const isList = appearance === 'list';\n\n function handleToggle() {\n if (isGrouped) {\n group.toggle(baseId);\n return;\n }\n\n const nextOpen = !isOpen;\n if (open === undefined) setUncontrolledOpen(nextOpen);\n onOpenChange?.(nextOpen);\n }\n\n const variantClassName = isGrouped\n ? 'chayns-accordion--grouped'\n : wrapped\n ? 'chayns-accordion--wrapped'\n : 'chayns-accordion--standalone';\n const directChildren = Children.toArray(children);\n const compoundHead = directChildren.find(\n (child) => isValidElement(child) && child.type === AccordionHead,\n );\n const hasCompoundLeading =\n isValidElement(compoundHead) &&\n Children.toArray((compoundHead as ReactElement<AccordionHeadProps>).props.children).some(\n (child) => isValidElement(child) && child.type === HeadLeading,\n );\n const rootClassName = [\n 'chayns-accordion',\n variantClassName,\n isOpen ? 'chayns-accordion--open' : null,\n disabled ? 'chayns-accordion--disabled' : null,\n leading || hasCompoundLeading ? 'chayns-accordion--has-leading' : null,\n isList ? 'chayns-accordion--list' : null,\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n const hasCompoundHead = compoundHead !== undefined;\n const compoundContent = directChildren.find(\n (child) => isValidElement(child) && child.type === AccordionContent,\n );\n const hasCompoundContent = compoundContent !== undefined;\n const panelChildren = children;\n\n return (\n <div {...rootProps} className={rootClassName} id={id} ref={ref}>\n <AccordionItemContext.Provider\n value={{ disabled, headerId, isOpen, onToggle: handleToggle, panelId }}\n >\n {hasCompoundHead ? (\n compoundHead\n ) : (\n <AccordionHead>\n {leading ? <HeadLeading>{leading}</HeadLeading> : null}\n <HeadContent title={title} subtitle={subtitle} />\n </AccordionHead>\n )}\n {hasCompoundContent ? (\n createElement(AccordionContent, {\n ...(compoundContent as ReactElement<AccordionContentProps>).props,\n })\n ) : (\n <AccordionContent>{panelChildren}</AccordionContent>\n )}\n </AccordionItemContext.Provider>\n </div>\n );\n});\n\nconst Accordion = Object.assign(AccordionRoot, {\n Content: AccordionContent,\n Head: Object.assign(AccordionHead, {\n Content: HeadContent,\n Leading: HeadLeading,\n Trailing: HeadTrailing,\n }),\n});\n\nexport default Accordion;\n"],"mappings":"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"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ComponentPropsWithRef, ReactNode } from 'react';
|
|
2
|
+
export declare const ACCORDION_APPEARANCES: readonly ["default", "list"];
|
|
3
|
+
export type AccordionAppearance = (typeof ACCORDION_APPEARANCES)[number];
|
|
2
4
|
/**
|
|
3
5
|
* @description Props for a single disclosure accordion: a header button that
|
|
4
6
|
* expands and collapses an associated content region. Nesting an `Accordion`
|
|
@@ -11,7 +13,13 @@ export interface AccordionProps extends Omit<ComponentPropsWithRef<'div'>, 'chil
|
|
|
11
13
|
* @description Visible, localized header label used as the accordion's
|
|
12
14
|
* accessible name.
|
|
13
15
|
*/
|
|
14
|
-
title
|
|
16
|
+
title?: ReactNode;
|
|
17
|
+
/** Optional second line used by the list presentation. */
|
|
18
|
+
subtitle?: ReactNode;
|
|
19
|
+
/** Optional leading image or icon used by list-style accordion rows. */
|
|
20
|
+
leading?: ReactNode;
|
|
21
|
+
/** Selects the compact two-line list presentation from Bodywork. */
|
|
22
|
+
appearance?: AccordionAppearance;
|
|
15
23
|
/**
|
|
16
24
|
* @description Panel content revealed when the accordion is open.
|
|
17
25
|
*/
|
|
@@ -79,4 +87,19 @@ export interface AccordionGroupProps extends Omit<ComponentPropsWithRef<'div'>,
|
|
|
79
87
|
*/
|
|
80
88
|
className?: string;
|
|
81
89
|
}
|
|
90
|
+
export interface AccordionHeadProps extends Omit<ComponentPropsWithRef<'button'>, 'children'> {
|
|
91
|
+
children?: ReactNode;
|
|
92
|
+
}
|
|
93
|
+
export interface AccordionHeadContentProps {
|
|
94
|
+
title: ReactNode;
|
|
95
|
+
subtitle?: ReactNode;
|
|
96
|
+
className?: string;
|
|
97
|
+
}
|
|
98
|
+
export interface AccordionPartProps {
|
|
99
|
+
children?: ReactNode;
|
|
100
|
+
className?: string;
|
|
101
|
+
}
|
|
102
|
+
export interface AccordionContentProps extends Omit<ComponentPropsWithRef<'div'>, 'children'> {
|
|
103
|
+
children?: ReactNode;
|
|
104
|
+
}
|
|
82
105
|
//# sourceMappingURL=Accordion.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accordion.types.d.ts","sourceRoot":"","sources":["../../../src/components/accordion/Accordion.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9D;;;;;;GAMG;AACH,MAAM,WAAW,cAAe,SAAQ,IAAI,CAC1C,qBAAqB,CAAC,KAAK,CAAC,EAC5B,UAAU,GAAG,IAAI,GAAG,OAAO,CAC5B;IACC;;;OAGG;IACH,KAAK,EAAE,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Accordion.types.d.ts","sourceRoot":"","sources":["../../../src/components/accordion/Accordion.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9D,eAAO,MAAM,qBAAqB,8BAA+B,CAAC;AAClE,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzE;;;;;;GAMG;AACH,MAAM,WAAW,cAAe,SAAQ,IAAI,CAC1C,qBAAqB,CAAC,KAAK,CAAC,EAC5B,UAAU,GAAG,IAAI,GAAG,OAAO,CAC5B;IACC;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAElB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB,wEAAwE;IACxE,OAAO,CAAC,EAAE,SAAS,CAAC;IAEpB,oEAAoE;IACpE,UAAU,CAAC,EAAE,mBAAmB,CAAC;IAEjC;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAEvC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;OAIG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC;IACzF;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEvB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE9B;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAE/C;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC;IAC3F,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC;IAC3F,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Accordion.types.js","names":[],"sources":["../../../src/components/accordion/Accordion.types.ts"],"sourcesContent":["import type { ComponentPropsWithRef, ReactNode } from 'react';\n\nexport const ACCORDION_APPEARANCES = ['default', 'list'] as const;\nexport type AccordionAppearance = (typeof ACCORDION_APPEARANCES)[number];\n\n/**\n * @description Props for a single disclosure accordion: a header button that\n * expands and collapses an associated content region. Nesting an `Accordion`\n * inside another `Accordion`'s content is automatically detected via React\n * context and rendered as the \"Wrapped\" presentation — there is no separate\n * component or prop for that case.\n */\nexport interface AccordionProps extends Omit<\n ComponentPropsWithRef<'div'>,\n 'children' | 'id' | 'title'\n> {\n /**\n * @description Visible, localized header label used as the accordion's\n * accessible name.\n */\n title?: ReactNode;\n\n /** Optional second line used by the list presentation. */\n subtitle?: ReactNode;\n\n /** Optional leading image or icon used by list-style accordion rows. */\n leading?: ReactNode;\n\n /** Selects the compact two-line list presentation from Bodywork. */\n appearance?: AccordionAppearance;\n\n /**\n * @description Panel content revealed when the accordion is open.\n */\n children?: ReactNode;\n\n /**\n * @description Controlled open state. Ignored when the accordion is\n * rendered inside an `AccordionGroup`, which owns exclusivity instead.\n */\n open?: boolean;\n\n /**\n * @description Uncontrolled initial open state. Ignored when inside an\n * `AccordionGroup`.\n * @default false\n */\n defaultOpen?: boolean;\n\n /**\n * @description Called with the next open state on user toggle, for both\n * the controlled and uncontrolled usage.\n */\n onOpenChange?: (open: boolean) => void;\n\n /**\n * @description Disables the header trigger, preventing toggling.\n * @default false\n */\n disabled?: boolean;\n\n /**\n * @description Stable id used to wire the header and panel via ARIA and,\n * inside an `AccordionGroup`, to identify this item. Falls back to a\n * generated id when omitted.\n */\n id?: string;\n\n /**\n * @description Additional class names appended to the accordion root\n * element.\n */\n className?: string;\n}\n\n/**\n * @description Props for a group of mutually exclusive accordions: at most\n * one child `Accordion` is open at a time, and the group renders its\n * children as one joined surface.\n */\nexport interface AccordionGroupProps extends Omit<ComponentPropsWithRef<'div'>, 'children'> {\n /**\n * @description `Accordion` items belonging to the group.\n */\n children?: ReactNode;\n\n /**\n * @description Controlled id of the currently open item, or `null` when\n * all items are closed.\n */\n openId?: string | null;\n\n /**\n * @description Uncontrolled id of the initially open item.\n * @default null\n */\n defaultOpenId?: string | null;\n\n /**\n * @description Called with the next open item id, or `null` when the group\n * closes entirely, for both the controlled and uncontrolled usage.\n */\n onOpenChange?: (openId: string | null) => void;\n\n /**\n * @description Additional class names appended to the group root element.\n */\n className?: string;\n}\n\nexport interface AccordionHeadProps extends Omit<ComponentPropsWithRef<'button'>, 'children'> {\n children?: ReactNode;\n}\n\nexport interface AccordionHeadContentProps {\n title: ReactNode;\n subtitle?: ReactNode;\n className?: string;\n}\n\nexport interface AccordionPartProps {\n children?: ReactNode;\n className?: string;\n}\n\nexport interface AccordionContentProps extends Omit<ComponentPropsWithRef<'div'>, 'children'> {\n children?: ReactNode;\n}\n"],"mappings":";AAEA,IAAa,wBAAwB,CAAC,WAAW,MAAM"}
|
|
@@ -17,4 +17,13 @@ export interface AccordionGroupContextValue {
|
|
|
17
17
|
* share the group's exclusive open state instead of owning local state.
|
|
18
18
|
*/
|
|
19
19
|
export declare const AccordionGroupContext: import("react").Context<AccordionGroupContextValue | null>;
|
|
20
|
+
export interface AccordionItemContextValue {
|
|
21
|
+
disabled: boolean;
|
|
22
|
+
headerId: string;
|
|
23
|
+
isOpen: boolean;
|
|
24
|
+
panelId: string;
|
|
25
|
+
onToggle: () => void;
|
|
26
|
+
}
|
|
27
|
+
export declare const AccordionItemContext: import("react").Context<AccordionItemContextValue | null>;
|
|
28
|
+
export declare function useAccordionItemContext(part: string): AccordionItemContextValue;
|
|
20
29
|
//# sourceMappingURL=AccordionContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccordionContext.d.ts","sourceRoot":"","sources":["../../../src/components/accordion/AccordionContext.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,iCAA2B,CAAC;AAE9D,gFAAgF;AAChF,MAAM,WAAW,0BAA0B;IACzC,iEAAiE;IACjE,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC;IAEhC,kEAAkE;IAClE,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9B;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,4DAAyD,CAAC"}
|
|
1
|
+
{"version":3,"file":"AccordionContext.d.ts","sourceRoot":"","sources":["../../../src/components/accordion/AccordionContext.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,iCAA2B,CAAC;AAE9D,gFAAgF;AAChF,MAAM,WAAW,0BAA0B;IACzC,iEAAiE;IACjE,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC;IAEhC,kEAAkE;IAClE,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9B;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,4DAAyD,CAAC;AAE5F,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,eAAO,MAAM,oBAAoB,2DAAwD,CAAC;AAE1F,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,6BAQnD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createContext } from "react";
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
2
|
//#region src/components/accordion/AccordionContext.ts
|
|
3
3
|
/**
|
|
4
4
|
* Nesting depth of the current accordion subtree. Depth 0 is a top-level
|
|
@@ -12,7 +12,13 @@ var AccordionDepthContext = createContext(0);
|
|
|
12
12
|
* share the group's exclusive open state instead of owning local state.
|
|
13
13
|
*/
|
|
14
14
|
var AccordionGroupContext = createContext(null);
|
|
15
|
+
var AccordionItemContext = createContext(null);
|
|
16
|
+
function useAccordionItemContext(part) {
|
|
17
|
+
const context = useContext(AccordionItemContext);
|
|
18
|
+
if (context === null) throw new Error(`Accordion.${part} must be used inside Accordion`);
|
|
19
|
+
return context;
|
|
20
|
+
}
|
|
15
21
|
//#endregion
|
|
16
|
-
export { AccordionDepthContext, AccordionGroupContext };
|
|
22
|
+
export { AccordionDepthContext, AccordionGroupContext, AccordionItemContext, useAccordionItemContext };
|
|
17
23
|
|
|
18
24
|
//# sourceMappingURL=AccordionContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccordionContext.js","names":[],"sources":["../../../src/components/accordion/AccordionContext.ts"],"sourcesContent":["import { createContext } from 'react';\n\n/**\n * Nesting depth of the current accordion subtree. Depth 0 is a top-level\n * accordion; any depth greater than 0 renders as an automatically detected\n * wrapped (nested) accordion. Each open panel provides an incremented depth to\n * its content.\n */\nexport const AccordionDepthContext = createContext<number>(0);\n\n/** Exclusive open-state contract shared by an AccordionGroup with its items. */\nexport interface AccordionGroupContextValue {\n /** Whether the item registered under this id is the open one. */\n isOpen: (id: string) => boolean;\n\n /** Toggles the item registered under this id within the group. */\n toggle: (id: string) => void;\n}\n\n/**\n * Present when an Accordion is rendered inside an AccordionGroup. Items then\n * share the group's exclusive open state instead of owning local state.\n */\nexport const AccordionGroupContext = createContext<AccordionGroupContextValue | null>(null);\n"],"mappings":";;;;;;;;AAQA,IAAa,wBAAwB,cAAsB,CAAC;;;;;AAe5D,IAAa,wBAAwB,cAAiD,IAAI"}
|
|
1
|
+
{"version":3,"file":"AccordionContext.js","names":[],"sources":["../../../src/components/accordion/AccordionContext.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\n\n/**\n * Nesting depth of the current accordion subtree. Depth 0 is a top-level\n * accordion; any depth greater than 0 renders as an automatically detected\n * wrapped (nested) accordion. Each open panel provides an incremented depth to\n * its content.\n */\nexport const AccordionDepthContext = createContext<number>(0);\n\n/** Exclusive open-state contract shared by an AccordionGroup with its items. */\nexport interface AccordionGroupContextValue {\n /** Whether the item registered under this id is the open one. */\n isOpen: (id: string) => boolean;\n\n /** Toggles the item registered under this id within the group. */\n toggle: (id: string) => void;\n}\n\n/**\n * Present when an Accordion is rendered inside an AccordionGroup. Items then\n * share the group's exclusive open state instead of owning local state.\n */\nexport const AccordionGroupContext = createContext<AccordionGroupContextValue | null>(null);\n\nexport interface AccordionItemContextValue {\n disabled: boolean;\n headerId: string;\n isOpen: boolean;\n panelId: string;\n onToggle: () => void;\n}\n\nexport const AccordionItemContext = createContext<AccordionItemContextValue | null>(null);\n\nexport function useAccordionItemContext(part: string) {\n const context = useContext(AccordionItemContext);\n\n if (context === null) {\n throw new Error(`Accordion.${part} must be used inside Accordion`);\n }\n\n return context;\n}\n"],"mappings":";;;;;;;;AAQA,IAAa,wBAAwB,cAAsB,CAAC;;;;;AAe5D,IAAa,wBAAwB,cAAiD,IAAI;AAU1F,IAAa,uBAAuB,cAAgD,IAAI;AAExF,SAAgB,wBAAwB,MAAc;CACpD,MAAM,UAAU,WAAW,oBAAoB;CAE/C,IAAI,YAAY,MACd,MAAM,IAAI,MAAM,aAAa,KAAK,+BAA+B;CAGnE,OAAO;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { AccordionGroupProps } from '../accordion/Accordion.types.js';
|
|
2
|
-
declare const AccordionGroup: (
|
|
2
|
+
declare const AccordionGroup: import("react").ForwardRefExoticComponent<Omit<AccordionGroupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
3
3
|
export default AccordionGroup;
|
|
4
4
|
//# sourceMappingURL=AccordionGroup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccordionGroup.d.ts","sourceRoot":"","sources":["../../../src/components/accordion-group/AccordionGroup.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAE3E,QAAA,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"AccordionGroup.d.ts","sourceRoot":"","sources":["../../../src/components/accordion-group/AccordionGroup.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAE3E,QAAA,MAAM,cAAc,6HAkClB,CAAC;AAEH,eAAe,cAAc,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AccordionGroupContext } from "../accordion/AccordionContext.js";
|
|
2
|
+
import { forwardRef, useCallback, useMemo, useState } from "react";
|
|
2
3
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useCallback, useMemo, useState } from "react";
|
|
4
4
|
//#region src/components/accordion-group/AccordionGroup.tsx
|
|
5
|
-
var AccordionGroup = ({ children, className, defaultOpenId = null, onOpenChange, openId,
|
|
5
|
+
var AccordionGroup = forwardRef(function AccordionGroup({ children, className, defaultOpenId = null, onOpenChange, openId, ...rootProps }, ref) {
|
|
6
6
|
const [uncontrolledOpenId, setUncontrolledOpenId] = useState(defaultOpenId);
|
|
7
7
|
const isControlled = openId !== void 0;
|
|
8
8
|
const currentOpenId = isControlled ? openId : uncontrolledOpenId;
|
|
@@ -30,7 +30,7 @@ var AccordionGroup = ({ children, className, defaultOpenId = null, onOpenChange,
|
|
|
30
30
|
children
|
|
31
31
|
})
|
|
32
32
|
});
|
|
33
|
-
};
|
|
33
|
+
});
|
|
34
34
|
//#endregion
|
|
35
35
|
export { AccordionGroup as default };
|
|
36
36
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccordionGroup.js","names":[],"sources":["../../../src/components/accordion-group/AccordionGroup.tsx"],"sourcesContent":["import { useCallback, useMemo, useState } from 'react';\n\nimport { AccordionGroupContext } from '../accordion/AccordionContext.js';\nimport type { AccordionGroupContextValue } from '../accordion/AccordionContext.js';\nimport type { AccordionGroupProps } from '../accordion/Accordion.types.js';\n\nconst AccordionGroup = (
|
|
1
|
+
{"version":3,"file":"AccordionGroup.js","names":[],"sources":["../../../src/components/accordion-group/AccordionGroup.tsx"],"sourcesContent":["import { forwardRef, useCallback, useMemo, useState } from 'react';\n\nimport { AccordionGroupContext } from '../accordion/AccordionContext.js';\nimport type { AccordionGroupContextValue } from '../accordion/AccordionContext.js';\nimport type { AccordionGroupProps } from '../accordion/Accordion.types.js';\n\nconst AccordionGroup = forwardRef<HTMLDivElement, AccordionGroupProps>(function AccordionGroup(\n { children, className, defaultOpenId = null, onOpenChange, openId, ...rootProps },\n ref,\n) {\n const [uncontrolledOpenId, setUncontrolledOpenId] = useState<string | null>(defaultOpenId);\n\n const isControlled = openId !== undefined;\n const currentOpenId = isControlled ? openId : uncontrolledOpenId;\n\n const isOpen = useCallback((id: string) => currentOpenId === id, [currentOpenId]);\n\n const toggle = useCallback(\n (id: string) => {\n const nextOpenId = currentOpenId === id ? null : id;\n if (!isControlled) setUncontrolledOpenId(nextOpenId);\n onOpenChange?.(nextOpenId);\n },\n [currentOpenId, isControlled, onOpenChange],\n );\n\n const contextValue = useMemo<AccordionGroupContextValue>(\n () => ({ isOpen, toggle }),\n [isOpen, toggle],\n );\n\n const rootClassName = ['chayns-accordion-group', className].filter(Boolean).join(' ');\n\n return (\n <AccordionGroupContext.Provider value={contextValue}>\n <div {...rootProps} className={rootClassName} ref={ref}>\n {children}\n </div>\n </AccordionGroupContext.Provider>\n );\n});\n\nexport default AccordionGroup;\n"],"mappings":";;;;AAMA,IAAM,iBAAiB,WAAgD,SAAS,eAC9E,EAAE,UAAU,WAAW,gBAAgB,MAAM,cAAc,QAAQ,GAAG,aACtE,KACA;CACA,MAAM,CAAC,oBAAoB,yBAAyB,SAAwB,aAAa;CAEzF,MAAM,eAAe,WAAW,KAAA;CAChC,MAAM,gBAAgB,eAAe,SAAS;CAE9C,MAAM,SAAS,aAAa,OAAe,kBAAkB,IAAI,CAAC,aAAa,CAAC;CAEhF,MAAM,SAAS,aACZ,OAAe;EACd,MAAM,aAAa,kBAAkB,KAAK,OAAO;EACjD,IAAI,CAAC,cAAc,sBAAsB,UAAU;EACnD,eAAe,UAAU;CAC3B,GACA;EAAC;EAAe;EAAc;CAAY,CAC5C;CAEA,MAAM,eAAe,eACZ;EAAE;EAAQ;CAAO,IACxB,CAAC,QAAQ,MAAM,CACjB;CAEA,MAAM,gBAAgB,CAAC,0BAA0B,SAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;CAEpF,OACE,oBAAC,sBAAsB,UAAvB;EAAgC,OAAO;EACrC,UAAA,oBAAC,OAAD;GAAK,GAAI;GAAW,WAAW;GAAoB;GAChD;EACE,CAAA;CACyB,CAAA;AAEpC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
1
|
import { forwardRef, useState } from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
//#region src/components/avatar/Avatar.tsx
|
|
4
4
|
var getInitials = (name) => {
|
|
5
5
|
const words = name.trim().split(/\s+/).filter(Boolean);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsxs } from "react/jsx-runtime";
|
|
2
1
|
import { Children, cloneElement, forwardRef, isValidElement } from "react";
|
|
2
|
+
import { jsxs } from "react/jsx-runtime";
|
|
3
3
|
//#region src/components/avatar-group/AvatarGroup.tsx
|
|
4
4
|
var AvatarGroup = forwardRef(function AvatarGroup({ children, className, max, size = "default", ...spanProps }, ref) {
|
|
5
5
|
const avatars = Children.toArray(children).filter((child) => isValidElement(child));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
1
|
import { forwardRef } from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
//#region src/components/badge/Badge.tsx
|
|
4
4
|
var Badge = forwardRef(function Badge({ "aria-label": ariaLabel, children, className, size = "sm", tone = "neutral", ...spanProps }, ref) {
|
|
5
5
|
const resolvedClassName = [
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const Banner: import("react").ForwardRefExoticComponent<(Omit<import("./Banner.types.js").StaticBannerProps, "ref"> | Omit<import("./Banner.types.js").ClosableBannerProps, "ref">) & import("react").RefAttributes<HTMLElement>>;
|
|
2
|
+
export default Banner;
|
|
3
|
+
//# sourceMappingURL=Banner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Banner.d.ts","sourceRoot":"","sources":["../../../src/components/banner/Banner.tsx"],"names":[],"mappings":"AAKA,QAAA,MAAM,MAAM,qNAuDV,CAAC;AAEH,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import ButtonIcon from "../button/button-icon/ButtonIcon.js";
|
|
2
|
+
import { forwardRef, useState } from "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/banner/Banner.tsx
|
|
5
|
+
var Banner = forwardRef(function Banner({ children, className, closeLabel, defaultOpen = true, icon, onClose, onOpenChange, open, tone = "neutral", ...asideProps }, ref) {
|
|
6
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
|
|
7
|
+
const isOpen = open ?? uncontrolledOpen;
|
|
8
|
+
function handleClose() {
|
|
9
|
+
if (open === void 0) setUncontrolledOpen(false);
|
|
10
|
+
onOpenChange?.(false);
|
|
11
|
+
onClose?.();
|
|
12
|
+
}
|
|
13
|
+
if (!isOpen) return null;
|
|
14
|
+
const resolvedClassName = [
|
|
15
|
+
"chayns-banner",
|
|
16
|
+
`chayns-banner--${tone}`,
|
|
17
|
+
className
|
|
18
|
+
].filter(Boolean).join(" ");
|
|
19
|
+
return /* @__PURE__ */ jsxs("aside", {
|
|
20
|
+
...asideProps,
|
|
21
|
+
className: resolvedClassName,
|
|
22
|
+
ref,
|
|
23
|
+
children: [
|
|
24
|
+
icon ? /* @__PURE__ */ jsx("span", {
|
|
25
|
+
"aria-hidden": "true",
|
|
26
|
+
className: "chayns-banner__icon",
|
|
27
|
+
children: /* @__PURE__ */ jsx(ButtonIcon, { icon })
|
|
28
|
+
}) : null,
|
|
29
|
+
/* @__PURE__ */ jsx("div", {
|
|
30
|
+
className: "chayns-banner__content",
|
|
31
|
+
children
|
|
32
|
+
}),
|
|
33
|
+
onClose ? /* @__PURE__ */ jsx("button", {
|
|
34
|
+
"aria-label": closeLabel,
|
|
35
|
+
className: "chayns-banner__close",
|
|
36
|
+
onClick: handleClose,
|
|
37
|
+
type: "button",
|
|
38
|
+
children: /* @__PURE__ */ jsx(ButtonIcon, { icon: "fa-xmark" })
|
|
39
|
+
}) : null
|
|
40
|
+
]
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
//#endregion
|
|
44
|
+
export { Banner as default };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=Banner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Banner.js","names":[],"sources":["../../../src/components/banner/Banner.tsx"],"sourcesContent":["import { forwardRef, useState } from 'react';\n\nimport ButtonIcon from '../button/button-icon/ButtonIcon.js';\nimport type { BannerProps } from './Banner.types.js';\n\nconst Banner = forwardRef<HTMLElement, BannerProps>(function Banner(\n {\n children,\n className,\n closeLabel,\n defaultOpen = true,\n icon,\n onClose,\n onOpenChange,\n open,\n tone = 'neutral',\n ...asideProps\n },\n ref,\n) {\n const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);\n const isOpen = open ?? uncontrolledOpen;\n\n function handleClose() {\n if (open === undefined) {\n setUncontrolledOpen(false);\n }\n\n onOpenChange?.(false);\n onClose?.();\n }\n\n if (!isOpen) {\n return null;\n }\n\n const resolvedClassName = ['chayns-banner', `chayns-banner--${tone}`, className]\n .filter(Boolean)\n .join(' ');\n\n return (\n <aside {...asideProps} className={resolvedClassName} ref={ref}>\n {icon ? (\n <span aria-hidden=\"true\" className=\"chayns-banner__icon\">\n <ButtonIcon icon={icon} />\n </span>\n ) : null}\n <div className=\"chayns-banner__content\">{children}</div>\n {onClose ? (\n <button\n aria-label={closeLabel}\n className=\"chayns-banner__close\"\n onClick={handleClose}\n type=\"button\"\n >\n <ButtonIcon icon=\"fa-xmark\" />\n </button>\n ) : null}\n </aside>\n );\n});\n\nexport default Banner;\n"],"mappings":";;;;AAKA,IAAM,SAAS,WAAqC,SAAS,OAC3D,EACE,UACA,WACA,YACA,cAAc,MACd,MACA,SACA,cACA,MACA,OAAO,WACP,GAAG,cAEL,KACA;CACA,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,WAAW;CACpE,MAAM,SAAS,QAAQ;CAEvB,SAAS,cAAc;EACrB,IAAI,SAAS,KAAA,GACX,oBAAoB,KAAK;EAG3B,eAAe,KAAK;EACpB,UAAU;CACZ;CAEA,IAAI,CAAC,QACH,OAAO;CAGT,MAAM,oBAAoB;EAAC;EAAiB,kBAAkB;EAAQ;CAAS,CAAC,CAC7E,OAAO,OAAO,CAAC,CACf,KAAK,GAAG;CAEX,OACE,qBAAC,SAAD;EAAO,GAAI;EAAY,WAAW;EAAwB;EAA1D,UAAA;GACG,OACC,oBAAC,QAAD;IAAM,eAAY;IAAO,WAAU;IACjC,UAAA,oBAAC,YAAD,EAAkB,KAAO,CAAA;GACrB,CAAA,IACJ;GACJ,oBAAC,OAAD;IAAK,WAAU;IAA0B;GAAc,CAAA;GACtD,UACC,oBAAC,UAAD;IACE,cAAY;IACZ,WAAU;IACV,SAAS;IACT,MAAK;IAEL,UAAA,oBAAC,YAAD,EAAY,MAAK,WAAY,CAAA;GACvB,CAAA,IACN;EACC;;AAEX,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef, ReactNode } from 'react';
|
|
2
|
+
import type { ButtonIcon } from '../button/Button.types.js';
|
|
3
|
+
export declare const BANNER_TONES: readonly ["neutral", "success", "warning", "danger"];
|
|
4
|
+
export type BannerTone = (typeof BANNER_TONES)[number];
|
|
5
|
+
interface BannerBaseProps extends Omit<ComponentPropsWithRef<'aside'>, 'children' | 'role'> {
|
|
6
|
+
children: Exclude<ReactNode, boolean | null | undefined>;
|
|
7
|
+
tone?: BannerTone;
|
|
8
|
+
icon?: ButtonIcon;
|
|
9
|
+
open?: boolean;
|
|
10
|
+
defaultOpen?: boolean;
|
|
11
|
+
onOpenChange?: (open: boolean) => void;
|
|
12
|
+
role?: never;
|
|
13
|
+
}
|
|
14
|
+
export interface StaticBannerProps extends BannerBaseProps {
|
|
15
|
+
onClose?: never;
|
|
16
|
+
closeLabel?: never;
|
|
17
|
+
}
|
|
18
|
+
export interface ClosableBannerProps extends BannerBaseProps {
|
|
19
|
+
onClose: () => void;
|
|
20
|
+
closeLabel: string;
|
|
21
|
+
}
|
|
22
|
+
export type BannerProps = StaticBannerProps | ClosableBannerProps;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=Banner.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Banner.types.d.ts","sourceRoot":"","sources":["../../../src/components/banner/Banner.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,eAAO,MAAM,YAAY,sDAAuD,CAAC;AACjF,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD,UAAU,eAAgB,SAAQ,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;IACzF,QAAQ,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IACzD,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,IAAI,CAAC,EAAE,KAAK,CAAC;CACd;AAED,MAAM,WAAW,iBAAkB,SAAQ,eAAe;IACxD,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,UAAU,CAAC,EAAE,KAAK,CAAC;CACpB;AAED,MAAM,WAAW,mBAAoB,SAAQ,eAAe;IAC1D,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,WAAW,GAAG,iBAAiB,GAAG,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Banner.types.js","names":[],"sources":["../../../src/components/banner/Banner.types.ts"],"sourcesContent":["import type { ComponentPropsWithRef, ReactNode } from 'react';\n\nimport type { ButtonIcon } from '../button/Button.types.js';\n\nexport const BANNER_TONES = ['neutral', 'success', 'warning', 'danger'] as const;\nexport type BannerTone = (typeof BANNER_TONES)[number];\n\ninterface BannerBaseProps extends Omit<ComponentPropsWithRef<'aside'>, 'children' | 'role'> {\n children: Exclude<ReactNode, boolean | null | undefined>;\n tone?: BannerTone;\n icon?: ButtonIcon;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n role?: never;\n}\n\nexport interface StaticBannerProps extends BannerBaseProps {\n onClose?: never;\n closeLabel?: never;\n}\n\nexport interface ClosableBannerProps extends BannerBaseProps {\n onClose: () => void;\n closeLabel: string;\n}\n\nexport type BannerProps = StaticBannerProps | ClosableBannerProps;\n"],"mappings":";AAIA,IAAa,eAAe;CAAC;CAAW;CAAW;CAAW;AAAQ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ButtonProps } from './Button.types.js';
|
|
2
|
-
declare
|
|
2
|
+
declare const Button: import("react").ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
3
3
|
export default Button;
|
|
4
4
|
//# sourceMappingURL=Button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/button/Button.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/button/Button.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,QAAA,MAAM,MAAM,wHAoCV,CAAC;AAEH,eAAe,MAAM,CAAC"}
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import ButtonIcon from "./button-icon/ButtonIcon.js";
|
|
2
|
+
import { forwardRef } from "react";
|
|
2
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
4
|
//#region src/components/button/Button.tsx
|
|
4
|
-
function Button({ children, className, icon, type = "button", variant, ...buttonProps }) {
|
|
5
|
+
var Button = forwardRef(function Button({ "aria-busy": ariaBusy, children, className, disabled, icon, loading = false, type = "button", variant, ...buttonProps }, ref) {
|
|
5
6
|
const resolvedClassName = [
|
|
6
7
|
"chayns-button",
|
|
7
8
|
`chayns-button--${variant}`,
|
|
9
|
+
loading ? "chayns-button--loading" : "",
|
|
8
10
|
className
|
|
9
11
|
].filter(Boolean).join(" ");
|
|
10
12
|
return /* @__PURE__ */ jsxs("button", {
|
|
11
13
|
...buttonProps,
|
|
14
|
+
"aria-busy": loading ? true : ariaBusy,
|
|
12
15
|
className: resolvedClassName,
|
|
16
|
+
disabled: loading || disabled,
|
|
17
|
+
ref,
|
|
13
18
|
type,
|
|
14
|
-
children: [icon ? /* @__PURE__ */ jsx(ButtonIcon, { icon }) : null, children]
|
|
19
|
+
children: [loading ? /* @__PURE__ */ jsx(ButtonIcon, { icon: "fa-spinner" }) : icon ? /* @__PURE__ */ jsx(ButtonIcon, { icon }) : null, children]
|
|
15
20
|
});
|
|
16
|
-
}
|
|
21
|
+
});
|
|
17
22
|
//#endregion
|
|
18
23
|
export { Button as default };
|
|
19
24
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","names":[],"sources":["../../../src/components/button/Button.tsx"],"sourcesContent":["import type { ButtonProps } from './Button.types.js';\nimport ButtonIcon from './button-icon/ButtonIcon.js';\n\
|
|
1
|
+
{"version":3,"file":"Button.js","names":[],"sources":["../../../src/components/button/Button.tsx"],"sourcesContent":["import { forwardRef } from 'react';\n\nimport type { ButtonProps } from './Button.types.js';\nimport ButtonIcon from './button-icon/ButtonIcon.js';\n\nconst Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n {\n 'aria-busy': ariaBusy,\n children,\n className,\n disabled,\n icon,\n loading = false,\n type = 'button',\n variant,\n ...buttonProps\n },\n ref,\n) {\n const resolvedClassName = [\n 'chayns-button',\n `chayns-button--${variant}`,\n loading ? 'chayns-button--loading' : '',\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n return (\n <button\n {...buttonProps}\n aria-busy={loading ? true : ariaBusy}\n className={resolvedClassName}\n disabled={loading || disabled}\n ref={ref}\n type={type}\n >\n {loading ? <ButtonIcon icon=\"fa-spinner\" /> : icon ? <ButtonIcon icon={icon} /> : null}\n {children}\n </button>\n );\n});\n\nexport default Button;\n"],"mappings":";;;;AAKA,IAAM,SAAS,WAA2C,SAAS,OACjE,EACE,aAAa,UACb,UACA,WACA,UACA,MACA,UAAU,OACV,OAAO,UACP,SACA,GAAG,eAEL,KACA;CACA,MAAM,oBAAoB;EACxB;EACA,kBAAkB;EAClB,UAAU,2BAA2B;EACrC;CACF,CAAC,CACE,OAAO,OAAO,CAAC,CACf,KAAK,GAAG;CAEX,OACE,qBAAC,UAAD;EACE,GAAI;EACJ,aAAW,UAAU,OAAO;EAC5B,WAAW;EACX,UAAU,WAAW;EAChB;EACC;EANR,UAAA,CAQG,UAAU,oBAAC,YAAD,EAAY,MAAK,aAAc,CAAA,IAAI,OAAO,oBAAC,YAAD,EAAkB,KAAO,CAAA,IAAI,MACjF,QACK;;AAEZ,CAAC"}
|
|
@@ -12,13 +12,13 @@ export type ButtonVariant = 'primary' | 'outline' | 'ghost' | 'danger';
|
|
|
12
12
|
*/
|
|
13
13
|
export declare const BUTTON_VARIANTS: readonly ["primary", "outline", "ghost", "danger"];
|
|
14
14
|
/**
|
|
15
|
-
* @description A FontAwesome Classic icon name
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
15
|
+
* @description A FontAwesome Classic icon name (e.g. `fa-plus`) or a
|
|
16
|
+
* FontAwesome Brands icon including its style prefix (e.g. `fab fa-github`).
|
|
17
|
+
* Classic icons resolve the matching Regular and Solid weights internally;
|
|
18
|
+
* Brands icons are rendered as a single icon and must not be combined with
|
|
19
|
+
* `far` or `fas`.
|
|
20
20
|
*/
|
|
21
|
-
export type ButtonIcon = `fa-${string}`;
|
|
21
|
+
export type ButtonIcon = `fa-${string}` | `fab fa-${string}`;
|
|
22
22
|
/**
|
|
23
23
|
* @description Visible content that gives a `Button` its accessible name.
|
|
24
24
|
* Excludes `boolean`, `null` and `undefined` so a `Button` can never be
|
|
@@ -39,15 +39,19 @@ export interface ButtonProps extends Omit<ComponentPropsWithRef<'button'>, 'chil
|
|
|
39
39
|
*/
|
|
40
40
|
variant: ButtonVariant;
|
|
41
41
|
/**
|
|
42
|
-
* @description Optional leading FontAwesome Classic icon name.
|
|
43
|
-
* rendered before `children`; there is no trailing-icon or icon-only
|
|
44
|
-
* on `Button` itself — use `IconButton` for an icon-only action.
|
|
42
|
+
* @description Optional leading FontAwesome Classic or Brands icon name.
|
|
43
|
+
* Always rendered before `children`; there is no trailing-icon or icon-only
|
|
44
|
+
* mode on `Button` itself — use `IconButton` for an icon-only action.
|
|
45
45
|
*/
|
|
46
46
|
icon?: ButtonIcon;
|
|
47
|
+
/**
|
|
48
|
+
* Shows a spinner while preserving the button label and prevents repeated
|
|
49
|
+
* activation through the native disabled state.
|
|
50
|
+
*/
|
|
51
|
+
loading?: boolean;
|
|
47
52
|
/**
|
|
48
53
|
* @description Visible, non-empty content used as the button label. Loading
|
|
49
|
-
*
|
|
50
|
-
* and navigation are explicitly not part of the Milestone 1 API.
|
|
54
|
+
* preserves this content while adding a spinner.
|
|
51
55
|
*/
|
|
52
56
|
children: ButtonContent;
|
|
53
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.types.d.ts","sourceRoot":"","sources":["../../../src/components/button/Button.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEvE;;;GAGG;AACH,eAAO,MAAM,eAAe,oDAKiB,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"Button.types.d.ts","sourceRoot":"","sources":["../../../src/components/button/Button.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEvE;;;GAGG;AACH,eAAO,MAAM,eAAe,oDAKiB,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,MAAM,EAAE,GAAG,UAAU,MAAM,EAAE,CAAC;AAE7D;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;AAE3E;;;;GAIG;AACH,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC;IACpF;;;;;OAKG;IACH,OAAO,EAAE,aAAa,CAAC;IAEvB;;;;OAIG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAElB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;OAGG;IACH,QAAQ,EAAE,aAAa,CAAC;CACzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.types.js","names":[],"sources":["../../../src/components/button/Button.types.ts"],"sourcesContent":["import type { ComponentPropsWithRef, ReactNode } from 'react';\n\n/**\n * @description Supported visual emphasis levels for {@link ButtonProps} and\n * `IconButtonProps`. Milestone 1 supports exactly these four values; there is\n * no default variant and no fifth value.\n * @see {@link https://tappqa.tobit.com/Bodywork/DesignSystem/#buttons | DesignSystem — Buttons & Aktionen}\n */\nexport type ButtonVariant = 'primary' | 'outline' | 'ghost' | 'danger';\n\n/**\n * Runtime representation of the finite Button variant contract.\n * Keep this list as the single source for Storybook controls and iteration.\n */\nexport const BUTTON_VARIANTS = [\n 'primary',\n 'outline',\n 'ghost',\n 'danger',\n] as const satisfies readonly ButtonVariant[];\n\n/**\n * @description A FontAwesome Classic icon name
|
|
1
|
+
{"version":3,"file":"Button.types.js","names":[],"sources":["../../../src/components/button/Button.types.ts"],"sourcesContent":["import type { ComponentPropsWithRef, ReactNode } from 'react';\n\n/**\n * @description Supported visual emphasis levels for {@link ButtonProps} and\n * `IconButtonProps`. Milestone 1 supports exactly these four values; there is\n * no default variant and no fifth value.\n * @see {@link https://tappqa.tobit.com/Bodywork/DesignSystem/#buttons | DesignSystem — Buttons & Aktionen}\n */\nexport type ButtonVariant = 'primary' | 'outline' | 'ghost' | 'danger';\n\n/**\n * Runtime representation of the finite Button variant contract.\n * Keep this list as the single source for Storybook controls and iteration.\n */\nexport const BUTTON_VARIANTS = [\n 'primary',\n 'outline',\n 'ghost',\n 'danger',\n] as const satisfies readonly ButtonVariant[];\n\n/**\n * @description A FontAwesome Classic icon name (e.g. `fa-plus`) or a\n * FontAwesome Brands icon including its style prefix (e.g. `fab fa-github`).\n * Classic icons resolve the matching Regular and Solid weights internally;\n * Brands icons are rendered as a single icon and must not be combined with\n * `far` or `fas`.\n */\nexport type ButtonIcon = `fa-${string}` | `fab fa-${string}`;\n\n/**\n * @description Visible content that gives a `Button` its accessible name.\n * Excludes `boolean`, `null` and `undefined` so a `Button` can never be\n * rendered without real, visible label content.\n */\nexport type ButtonContent = Exclude<ReactNode, boolean | null | undefined>;\n\n/**\n * @description Props for a visible-label native action button. Renders a\n * native `<button>` and forwards all remaining native button props, events,\n * `className` and `ref`.\n */\nexport interface ButtonProps extends Omit<ComponentPropsWithRef<'button'>, 'children'> {\n /**\n * @description Visual emphasis that communicates the action's role within\n * its action scope. At most one `primary` action should exist per closed\n * action scope (page, card, dialog, drawer, form, wizard step, or closed\n * accordion content).\n */\n variant: ButtonVariant;\n\n /**\n * @description Optional leading FontAwesome Classic or Brands icon name.\n * Always rendered before `children`; there is no trailing-icon or icon-only\n * mode on `Button` itself — use `IconButton` for an icon-only action.\n */\n icon?: ButtonIcon;\n\n /**\n * Shows a spinner while preserving the button label and prevents repeated\n * activation through the native disabled state.\n */\n loading?: boolean;\n\n /**\n * @description Visible, non-empty content used as the button label. Loading\n * preserves this content while adding a spinner.\n */\n children: ButtonContent;\n}\n"],"mappings":";;;;;AAcA,IAAa,kBAAkB;CAC7B;CACA;CACA;CACA;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonIcon.d.ts","sourceRoot":"","sources":["../../../../src/components/button/button-icon/ButtonIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEvE,UAAU,eAAe;IACvB,IAAI,EAAE,cAAc,CAAC;CACtB;AAED,QAAA,MAAM,UAAU,GAAI,UAAU,eAAe,
|
|
1
|
+
{"version":3,"file":"ButtonIcon.d.ts","sourceRoot":"","sources":["../../../../src/components/button/button-icon/ButtonIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEvE,UAAU,eAAe;IACvB,IAAI,EAAE,cAAc,CAAC;CACtB;AAED,QAAA,MAAM,UAAU,GAAI,UAAU,eAAe,gCAqB5C,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
//#region src/components/button/button-icon/ButtonIcon.tsx
|
|
3
|
-
var ButtonIcon = ({ icon }) =>
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
className: "chayns-button-
|
|
8
|
-
children: /* @__PURE__ */ jsx("
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
})
|
|
3
|
+
var ButtonIcon = ({ icon }) => {
|
|
4
|
+
const isBrandIcon = icon.startsWith("fab ");
|
|
5
|
+
return /* @__PURE__ */ jsx("span", {
|
|
6
|
+
"aria-hidden": "true",
|
|
7
|
+
className: "chayns-button-icon",
|
|
8
|
+
children: isBrandIcon ? /* @__PURE__ */ jsx("span", {
|
|
9
|
+
className: "chayns-button-icon__weight",
|
|
10
|
+
children: /* @__PURE__ */ jsx("i", { className: icon })
|
|
11
|
+
}) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
12
|
+
className: "chayns-button-icon__weight",
|
|
13
|
+
children: /* @__PURE__ */ jsx("i", { className: `far ${icon}` })
|
|
14
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
15
|
+
className: "chayns-button-icon__weight chayns-button-icon__weight--active",
|
|
16
|
+
children: /* @__PURE__ */ jsx("i", { className: `fas ${icon}` })
|
|
17
|
+
})] })
|
|
18
|
+
});
|
|
19
|
+
};
|
|
14
20
|
//#endregion
|
|
15
21
|
export { ButtonIcon as default };
|
|
16
22
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonIcon.js","names":[],"sources":["../../../../src/components/button/button-icon/ButtonIcon.tsx"],"sourcesContent":["import type { ButtonIcon as ButtonIconName } from '../Button.types.js';\n\ninterface ButtonIconProps {\n icon: ButtonIconName;\n}\n\nconst ButtonIcon = ({ icon }: ButtonIconProps) => (\n <span aria-hidden=\"true\" className=\"chayns-button-icon\">\n
|
|
1
|
+
{"version":3,"file":"ButtonIcon.js","names":[],"sources":["../../../../src/components/button/button-icon/ButtonIcon.tsx"],"sourcesContent":["import type { ButtonIcon as ButtonIconName } from '../Button.types.js';\n\ninterface ButtonIconProps {\n icon: ButtonIconName;\n}\n\nconst ButtonIcon = ({ icon }: ButtonIconProps) => {\n const isBrandIcon = icon.startsWith('fab ');\n\n return (\n <span aria-hidden=\"true\" className=\"chayns-button-icon\">\n {isBrandIcon ? (\n <span className=\"chayns-button-icon__weight\">\n <i className={icon} />\n </span>\n ) : (\n <>\n <span className=\"chayns-button-icon__weight\">\n <i className={`far ${icon}`} />\n </span>\n <span className=\"chayns-button-icon__weight chayns-button-icon__weight--active\">\n <i className={`fas ${icon}`} />\n </span>\n </>\n )}\n </span>\n );\n};\n\nexport default ButtonIcon;\n"],"mappings":";;AAMA,IAAM,cAAc,EAAE,WAA4B;CAChD,MAAM,cAAc,KAAK,WAAW,MAAM;CAE1C,OACE,oBAAC,QAAD;EAAM,eAAY;EAAO,WAAU;EAChC,UAAA,cACC,oBAAC,QAAD;GAAM,WAAU;GACd,UAAA,oBAAC,KAAD,EAAG,WAAW,KAAO,CAAA;EACjB,CAAA,IAEN,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,QAAD;GAAM,WAAU;GACd,UAAA,oBAAC,KAAD,EAAG,WAAW,OAAO,OAAS,CAAA;EAC1B,CAAA,GACN,oBAAC,QAAD;GAAM,WAAU;GACd,UAAA,oBAAC,KAAD,EAAG,WAAW,OAAO,OAAS,CAAA;EAC1B,CAAA,CACN,EAAA,CAAA;CAEA,CAAA;AAEV"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { CardProps } from './Card.types.js';
|
|
2
|
-
declare const Card: (
|
|
1
|
+
import type { CardHeaderProps, CardProps } from './Card.types.js';
|
|
2
|
+
declare const Card: import("react").ForwardRefExoticComponent<Omit<CardProps, "ref"> & import("react").RefAttributes<HTMLDivElement>> & {
|
|
3
|
+
Header: import("react").ForwardRefExoticComponent<Omit<CardHeaderProps, "ref"> & import("react").RefAttributes<HTMLElement>>;
|
|
4
|
+
};
|
|
3
5
|
export default Card;
|
|
4
6
|
//# sourceMappingURL=Card.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../../src/components/card/Card.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../../src/components/card/Card.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAiClE,QAAA,MAAM,IAAI;;CAAkD,CAAC;AAE7D,eAAe,IAAI,CAAC"}
|
|
@@ -1,17 +1,33 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ButtonIcon from "../button/button-icon/ButtonIcon.js";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
4
|
//#region src/components/card/Card.tsx
|
|
3
|
-
var
|
|
4
|
-
const resolvedClassName = [
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
className
|
|
8
|
-
|
|
5
|
+
var CardHeader = forwardRef(function CardHeader({ children, className, icon, ...headerProps }, ref) {
|
|
6
|
+
const resolvedClassName = ["chayns-card__header", className].filter(Boolean).join(" ");
|
|
7
|
+
return /* @__PURE__ */ jsxs("header", {
|
|
8
|
+
...headerProps,
|
|
9
|
+
className: resolvedClassName,
|
|
10
|
+
ref,
|
|
11
|
+
children: [icon ? /* @__PURE__ */ jsx("span", {
|
|
12
|
+
"aria-hidden": "true",
|
|
13
|
+
className: "chayns-card__header-icon",
|
|
14
|
+
children: /* @__PURE__ */ jsx(ButtonIcon, { icon })
|
|
15
|
+
}) : null, /* @__PURE__ */ jsx("span", {
|
|
16
|
+
className: "chayns-card__header-content",
|
|
17
|
+
children
|
|
18
|
+
})]
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
var CardRoot = forwardRef(function Card({ children, className, ...cardProps }, ref) {
|
|
22
|
+
const resolvedClassName = ["chayns-card", className].filter(Boolean).join(" ");
|
|
9
23
|
return /* @__PURE__ */ jsx("div", {
|
|
10
24
|
...cardProps,
|
|
11
25
|
className: resolvedClassName,
|
|
26
|
+
ref,
|
|
12
27
|
children
|
|
13
28
|
});
|
|
14
|
-
};
|
|
29
|
+
});
|
|
30
|
+
var Card = Object.assign(CardRoot, { Header: CardHeader });
|
|
15
31
|
//#endregion
|
|
16
32
|
export { Card as default };
|
|
17
33
|
|