@atelier-ui/react 0.0.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/package.json +28 -0
- package/src/index.d.ts +24 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +24 -0
- package/src/index.js.map +1 -0
- package/src/lib/accordion/llm-accordion.d.ts +59 -0
- package/src/lib/accordion/llm-accordion.d.ts.map +1 -0
- package/src/lib/accordion/llm-accordion.js +122 -0
- package/src/lib/accordion/llm-accordion.js.map +1 -0
- package/src/lib/alert/llm-alert.d.ts +29 -0
- package/src/lib/alert/llm-alert.d.ts.map +1 -0
- package/src/lib/alert/llm-alert.js +11 -0
- package/src/lib/alert/llm-alert.js.map +1 -0
- package/src/lib/avatar/llm-avatar.d.ts +58 -0
- package/src/lib/avatar/llm-avatar.d.ts.map +1 -0
- package/src/lib/avatar/llm-avatar.js +39 -0
- package/src/lib/avatar/llm-avatar.js.map +1 -0
- package/src/lib/badge/llm-badge.d.ts +25 -0
- package/src/lib/badge/llm-badge.d.ts.map +1 -0
- package/src/lib/badge/llm-badge.js +11 -0
- package/src/lib/badge/llm-badge.js.map +1 -0
- package/src/lib/breadcrumbs/llm-breadcrumbs.d.ts +38 -0
- package/src/lib/breadcrumbs/llm-breadcrumbs.d.ts.map +1 -0
- package/src/lib/breadcrumbs/llm-breadcrumbs.js +28 -0
- package/src/lib/breadcrumbs/llm-breadcrumbs.js.map +1 -0
- package/src/lib/button/llm-button.d.ts +17 -0
- package/src/lib/button/llm-button.d.ts.map +1 -0
- package/src/lib/button/llm-button.js +21 -0
- package/src/lib/button/llm-button.js.map +1 -0
- package/src/lib/card/llm-card.d.ts +52 -0
- package/src/lib/card/llm-card.d.ts.map +1 -0
- package/src/lib/card/llm-card.js +30 -0
- package/src/lib/card/llm-card.js.map +1 -0
- package/src/lib/checkbox/llm-checkbox.d.ts +41 -0
- package/src/lib/checkbox/llm-checkbox.d.ts.map +1 -0
- package/src/lib/checkbox/llm-checkbox.js +29 -0
- package/src/lib/checkbox/llm-checkbox.js.map +1 -0
- package/src/lib/dialog/llm-dialog.d.ts +68 -0
- package/src/lib/dialog/llm-dialog.d.ts.map +1 -0
- package/src/lib/dialog/llm-dialog.js +76 -0
- package/src/lib/dialog/llm-dialog.js.map +1 -0
- package/src/lib/drawer/llm-drawer.d.ts +64 -0
- package/src/lib/drawer/llm-drawer.d.ts.map +1 -0
- package/src/lib/drawer/llm-drawer.js +83 -0
- package/src/lib/drawer/llm-drawer.js.map +1 -0
- package/src/lib/input/llm-input.d.ts +41 -0
- package/src/lib/input/llm-input.d.ts.map +1 -0
- package/src/lib/input/llm-input.js +25 -0
- package/src/lib/input/llm-input.js.map +1 -0
- package/src/lib/menu/llm-menu.d.ts +66 -0
- package/src/lib/menu/llm-menu.d.ts.map +1 -0
- package/src/lib/menu/llm-menu.js +64 -0
- package/src/lib/menu/llm-menu.js.map +1 -0
- package/src/lib/pagination/llm-pagination.d.ts +33 -0
- package/src/lib/pagination/llm-pagination.d.ts.map +1 -0
- package/src/lib/pagination/llm-pagination.js +54 -0
- package/src/lib/pagination/llm-pagination.js.map +1 -0
- package/src/lib/progress/llm-progress.d.ts +33 -0
- package/src/lib/progress/llm-progress.d.ts.map +1 -0
- package/src/lib/progress/llm-progress.js +18 -0
- package/src/lib/progress/llm-progress.js.map +1 -0
- package/src/lib/radio/llm-radio.d.ts +25 -0
- package/src/lib/radio/llm-radio.d.ts.map +1 -0
- package/src/lib/radio/llm-radio.js +23 -0
- package/src/lib/radio/llm-radio.js.map +1 -0
- package/src/lib/radio-group/llm-radio-group.d.ts +84 -0
- package/src/lib/radio-group/llm-radio-group.d.ts.map +1 -0
- package/src/lib/radio-group/llm-radio-group.js +40 -0
- package/src/lib/radio-group/llm-radio-group.js.map +1 -0
- package/src/lib/select/llm-select.d.ts +58 -0
- package/src/lib/select/llm-select.d.ts.map +1 -0
- package/src/lib/select/llm-select.js +26 -0
- package/src/lib/select/llm-select.js.map +1 -0
- package/src/lib/skeleton/llm-skeleton.d.ts +29 -0
- package/src/lib/skeleton/llm-skeleton.d.ts.map +1 -0
- package/src/lib/skeleton/llm-skeleton.js +27 -0
- package/src/lib/skeleton/llm-skeleton.js.map +1 -0
- package/src/lib/tabs/llm-tabs.d.ts +53 -0
- package/src/lib/tabs/llm-tabs.d.ts.map +1 -0
- package/src/lib/tabs/llm-tabs.js +75 -0
- package/src/lib/tabs/llm-tabs.js.map +1 -0
- package/src/lib/textarea/llm-textarea.d.ts +33 -0
- package/src/lib/textarea/llm-textarea.d.ts.map +1 -0
- package/src/lib/textarea/llm-textarea.js +39 -0
- package/src/lib/textarea/llm-textarea.js.map +1 -0
- package/src/lib/toast/llm-toast.d.ts +54 -0
- package/src/lib/toast/llm-toast.d.ts.map +1 -0
- package/src/lib/toast/llm-toast.js +70 -0
- package/src/lib/toast/llm-toast.js.map +1 -0
- package/src/lib/toggle/llm-toggle.d.ts +29 -0
- package/src/lib/toggle/llm-toggle.d.ts.map +1 -0
- package/src/lib/toggle/llm-toggle.js +23 -0
- package/src/lib/toggle/llm-toggle.js.map +1 -0
- package/src/lib/tooltip/llm-tooltip.d.ts +17 -0
- package/src/lib/tooltip/llm-tooltip.d.ts.map +1 -0
- package/src/lib/tooltip/llm-tooltip.js +68 -0
- package/src/lib/tooltip/llm-tooltip.js.map +1 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ButtonHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import type { LlmButtonSpec } from '@atelier-ui/spec';
|
|
3
|
+
import './llm-button.css';
|
|
4
|
+
/**
|
|
5
|
+
* Properties for the LlmButton component.
|
|
6
|
+
*/
|
|
7
|
+
export interface LlmButtonProps extends ButtonHTMLAttributes<HTMLButtonElement>, LlmButtonSpec {
|
|
8
|
+
/**
|
|
9
|
+
* The content to be rendered inside the button.
|
|
10
|
+
*/
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A versatile button component that supports various styles, sizes, and states.
|
|
15
|
+
*/
|
|
16
|
+
export declare const LlmButton: import("react").ForwardRefExoticComponent<LlmButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
17
|
+
//# sourceMappingURL=llm-button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-button.d.ts","sourceRoot":"","sources":["../../../../../../libs/react/src/lib/button/llm-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAc,MAAM,OAAO,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,kBAAkB,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,aAAa;IAC5F;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;GAEG;AACH,eAAO,MAAM,SAAS,8GAoCpB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import './llm-button.css';
|
|
4
|
+
/**
|
|
5
|
+
* A versatile button component that supports various styles, sizes, and states.
|
|
6
|
+
*/
|
|
7
|
+
export const LlmButton = forwardRef(function LlmButton({ variant = 'primary', size = 'md', disabled = false, loading = false, children, className, ...rest }, ref) {
|
|
8
|
+
const isDisabled = disabled || loading;
|
|
9
|
+
const classes = [
|
|
10
|
+
'llm-button',
|
|
11
|
+
`variant-${variant}`,
|
|
12
|
+
`size-${size}`,
|
|
13
|
+
isDisabled && 'is-disabled',
|
|
14
|
+
loading && 'is-loading',
|
|
15
|
+
className,
|
|
16
|
+
]
|
|
17
|
+
.filter(Boolean)
|
|
18
|
+
.join(' ');
|
|
19
|
+
return (_jsxs("button", { ref: ref, className: classes, disabled: isDisabled, "aria-disabled": isDisabled || undefined, ...rest, children: [loading && _jsx("span", { className: "spinner", "aria-hidden": "true" }), children] }));
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=llm-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-button.js","sourceRoot":"","sources":["../../../../../../libs/react/src/lib/button/llm-button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAmC,UAAU,EAAE,MAAM,OAAO,CAAC;AAEpE,OAAO,kBAAkB,CAAC;AAY1B;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAoC,SAAS,SAAS,CACvF,EACE,OAAO,GAAG,SAAS,EACnB,IAAI,GAAG,IAAI,EACX,QAAQ,GAAG,KAAK,EAChB,OAAO,GAAG,KAAK,EACf,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EACR,EACD,GAAG;IAEH,MAAM,UAAU,GAAG,QAAQ,IAAI,OAAO,CAAC;IACvC,MAAM,OAAO,GAAG;QACd,YAAY;QACZ,WAAW,OAAO,EAAE;QACpB,QAAQ,IAAI,EAAE;QACd,UAAU,IAAI,aAAa;QAC3B,OAAO,IAAI,YAAY;QACvB,SAAS;KACV;SACE,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAC;IAEb,OAAO,CACL,kBACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,UAAU,mBACL,UAAU,IAAI,SAAS,KAClC,IAAI,aAEP,OAAO,IAAI,eAAM,SAAS,EAAC,SAAS,iBAAa,MAAM,GAAG,EAC1D,QAAQ,IACF,CACV,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { ButtonHTMLAttributes, ReactNode, forwardRef } from 'react';\nimport type { LlmButtonSpec } from '@atelier-ui/spec';\nimport './llm-button.css';\n\n/**\n * Properties for the LlmButton component.\n */\nexport interface LlmButtonProps extends ButtonHTMLAttributes<HTMLButtonElement>, LlmButtonSpec {\n /**\n * The content to be rendered inside the button.\n */\n children?: ReactNode;\n}\n\n/**\n * A versatile button component that supports various styles, sizes, and states.\n */\nexport const LlmButton = forwardRef<HTMLButtonElement, LlmButtonProps>(function LlmButton(\n {\n variant = 'primary',\n size = 'md',\n disabled = false,\n loading = false,\n children,\n className,\n ...rest\n },\n ref\n) {\n const isDisabled = disabled || loading;\n const classes = [\n 'llm-button',\n `variant-${variant}`,\n `size-${size}`,\n isDisabled && 'is-disabled',\n loading && 'is-loading',\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n return (\n <button\n ref={ref}\n className={classes}\n disabled={isDisabled}\n aria-disabled={isDisabled || undefined}\n {...rest}\n >\n {loading && <span className=\"spinner\" aria-hidden=\"true\" />}\n {children}\n </button>\n );\n});\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import type { LlmCardSpec } from '@atelier-ui/spec';
|
|
3
|
+
import './llm-card.css';
|
|
4
|
+
/**
|
|
5
|
+
* Properties for the LlmCard component.
|
|
6
|
+
*/
|
|
7
|
+
export interface LlmCardProps extends HTMLAttributes<HTMLDivElement>, LlmCardSpec {
|
|
8
|
+
/**
|
|
9
|
+
* The visual style variant of the card.
|
|
10
|
+
*/
|
|
11
|
+
variant?: 'elevated' | 'outlined' | 'flat';
|
|
12
|
+
/**
|
|
13
|
+
* The padding size within the card.
|
|
14
|
+
*/
|
|
15
|
+
padding?: 'none' | 'sm' | 'md' | 'lg';
|
|
16
|
+
/**
|
|
17
|
+
* The content to be rendered inside the card.
|
|
18
|
+
*/
|
|
19
|
+
children?: ReactNode;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A card component for grouping related content.
|
|
23
|
+
*/
|
|
24
|
+
export declare function LlmCard({ variant, padding, children, className, ...rest }: LlmCardProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
/**
|
|
26
|
+
* The header component for an LlmCard.
|
|
27
|
+
*/
|
|
28
|
+
export declare function LlmCardHeader({ children, className, ...rest }: HTMLAttributes<HTMLDivElement> & {
|
|
29
|
+
/**
|
|
30
|
+
* The content of the card header.
|
|
31
|
+
*/
|
|
32
|
+
children?: ReactNode;
|
|
33
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
/**
|
|
35
|
+
* The main content component for an LlmCard.
|
|
36
|
+
*/
|
|
37
|
+
export declare function LlmCardContent({ children, className, ...rest }: HTMLAttributes<HTMLDivElement> & {
|
|
38
|
+
/**
|
|
39
|
+
* The main content of the card.
|
|
40
|
+
*/
|
|
41
|
+
children?: ReactNode;
|
|
42
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
43
|
+
/**
|
|
44
|
+
* The footer component for an LlmCard.
|
|
45
|
+
*/
|
|
46
|
+
export declare function LlmCardFooter({ children, className, ...rest }: HTMLAttributes<HTMLDivElement> & {
|
|
47
|
+
/**
|
|
48
|
+
* The content of the card footer.
|
|
49
|
+
*/
|
|
50
|
+
children?: ReactNode;
|
|
51
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
52
|
+
//# sourceMappingURL=llm-card.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-card.d.ts","sourceRoot":"","sources":["../../../../../../libs/react/src/lib/card/llm-card.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,gBAAgB,CAAC;AAExB;;GAEG;AACH,MAAM,WAAW,YACf,SAAQ,cAAc,CAAC,cAAc,CAAC,EACpC,WAAW;IACb;;OAEG;IACH,OAAO,CAAC,EAAE,UAAU,GAAG,UAAU,GAAG,MAAM,CAAC;IAC3C;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACtC;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,EACtB,OAAoB,EACpB,OAAc,EACd,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EACR,EAAE,YAAY,2CASd;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EACR,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG;IAClC;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,2CAMA;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EACR,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG;IAClC;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,2CAMA;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EACR,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG;IAClC;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,2CAMA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import './llm-card.css';
|
|
3
|
+
/**
|
|
4
|
+
* A card component for grouping related content.
|
|
5
|
+
*/
|
|
6
|
+
export function LlmCard({ variant = 'elevated', padding = 'md', children, className, ...rest }) {
|
|
7
|
+
const classes = ['llm-card', `variant-${variant}`, `padding-${padding}`, className]
|
|
8
|
+
.filter(Boolean)
|
|
9
|
+
.join(' ');
|
|
10
|
+
return (_jsx("div", { className: classes, ...rest, children: children }));
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The header component for an LlmCard.
|
|
14
|
+
*/
|
|
15
|
+
export function LlmCardHeader({ children, className, ...rest }) {
|
|
16
|
+
return (_jsx("div", { className: ['llm-card-header', className].filter(Boolean).join(' '), ...rest, children: children }));
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The main content component for an LlmCard.
|
|
20
|
+
*/
|
|
21
|
+
export function LlmCardContent({ children, className, ...rest }) {
|
|
22
|
+
return (_jsx("div", { className: ['llm-card-content', className].filter(Boolean).join(' '), ...rest, children: children }));
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The footer component for an LlmCard.
|
|
26
|
+
*/
|
|
27
|
+
export function LlmCardFooter({ children, className, ...rest }) {
|
|
28
|
+
return (_jsx("div", { className: ['llm-card-footer', className].filter(Boolean).join(' '), ...rest, children: children }));
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=llm-card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-card.js","sourceRoot":"","sources":["../../../../../../libs/react/src/lib/card/llm-card.tsx"],"names":[],"mappings":";AAEA,OAAO,gBAAgB,CAAC;AAsBxB;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,EACtB,OAAO,GAAG,UAAU,EACpB,OAAO,GAAG,IAAI,EACd,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EACM;IACb,MAAM,OAAO,GAAG,CAAC,UAAU,EAAE,WAAW,OAAO,EAAE,EAAE,WAAW,OAAO,EAAE,EAAE,SAAS,CAAC;SAChF,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAC;IACb,OAAO,CACL,cAAK,SAAS,EAAE,OAAO,KAAM,IAAI,YAC9B,QAAQ,GACL,CACP,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,EAC5B,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EAMR;IACC,OAAO,CACL,cAAK,SAAS,EAAE,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAM,IAAI,YAC/E,QAAQ,GACL,CACP,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,EAC7B,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EAMR;IACC,OAAO,CACL,cAAK,SAAS,EAAE,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAM,IAAI,YAChF,QAAQ,GACL,CACP,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,EAC5B,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EAMR;IACC,OAAO,CACL,cAAK,SAAS,EAAE,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAM,IAAI,YAC/E,QAAQ,GACL,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { HTMLAttributes, ReactNode } from 'react';\nimport type { LlmCardSpec } from '@atelier-ui/spec';\nimport './llm-card.css';\n\n/**\n * Properties for the LlmCard component.\n */\nexport interface LlmCardProps\n extends HTMLAttributes<HTMLDivElement>,\n LlmCardSpec {\n /**\n * The visual style variant of the card.\n */\n variant?: 'elevated' | 'outlined' | 'flat';\n /**\n * The padding size within the card.\n */\n padding?: 'none' | 'sm' | 'md' | 'lg';\n /**\n * The content to be rendered inside the card.\n */\n children?: ReactNode;\n}\n\n/**\n * A card component for grouping related content.\n */\nexport function LlmCard({\n variant = 'elevated',\n padding = 'md',\n children,\n className,\n ...rest\n}: LlmCardProps) {\n const classes = ['llm-card', `variant-${variant}`, `padding-${padding}`, className]\n .filter(Boolean)\n .join(' ');\n return (\n <div className={classes} {...rest}>\n {children}\n </div>\n );\n}\n\n/**\n * The header component for an LlmCard.\n */\nexport function LlmCardHeader({\n children,\n className,\n ...rest\n}: HTMLAttributes<HTMLDivElement> & {\n /**\n * The content of the card header.\n */\n children?: ReactNode;\n}) {\n return (\n <div className={['llm-card-header', className].filter(Boolean).join(' ')} {...rest}>\n {children}\n </div>\n );\n}\n\n/**\n * The main content component for an LlmCard.\n */\nexport function LlmCardContent({\n children,\n className,\n ...rest\n}: HTMLAttributes<HTMLDivElement> & {\n /**\n * The main content of the card.\n */\n children?: ReactNode;\n}) {\n return (\n <div className={['llm-card-content', className].filter(Boolean).join(' ')} {...rest}>\n {children}\n </div>\n );\n}\n\n/**\n * The footer component for an LlmCard.\n */\nexport function LlmCardFooter({\n children,\n className,\n ...rest\n}: HTMLAttributes<HTMLDivElement> & {\n /**\n * The content of the card footer.\n */\n children?: ReactNode;\n}) {\n return (\n <div className={['llm-card-footer', className].filter(Boolean).join(' ')} {...rest}>\n {children}\n </div>\n );\n}\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { InputHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import type { LlmCheckboxSpec } from '@atelier-ui/spec';
|
|
3
|
+
import './llm-checkbox.css';
|
|
4
|
+
/**
|
|
5
|
+
* Properties for the LlmCheckbox component.
|
|
6
|
+
*/
|
|
7
|
+
export interface LlmCheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'checked' | 'onChange' | 'readOnly'>, LlmCheckboxSpec {
|
|
8
|
+
/**
|
|
9
|
+
* Whether the checkbox is checked.
|
|
10
|
+
*/
|
|
11
|
+
checked?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Callback triggered when the checked state changes.
|
|
14
|
+
*/
|
|
15
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Whether the checkbox is in an indeterminate state.
|
|
18
|
+
*/
|
|
19
|
+
indeterminate?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Whether the checkbox is in an invalid state.
|
|
22
|
+
*/
|
|
23
|
+
invalid?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Array of error messages to display.
|
|
26
|
+
*/
|
|
27
|
+
errors?: string[];
|
|
28
|
+
/**
|
|
29
|
+
* Whether the checkbox is read-only.
|
|
30
|
+
*/
|
|
31
|
+
readOnly?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The content to be rendered as the label for the checkbox.
|
|
34
|
+
*/
|
|
35
|
+
children?: ReactNode;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A checkbox component for selecting one or more options.
|
|
39
|
+
*/
|
|
40
|
+
export declare function LlmCheckbox({ checked, onCheckedChange, indeterminate, invalid, errors, disabled, readOnly: reactReadOnly, readonly: specReadOnly, required, children, className, id, name, ...rest }: LlmCheckboxProps): import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
//# sourceMappingURL=llm-checkbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-checkbox.d.ts","sourceRoot":"","sources":["../../../../../../libs/react/src/lib/checkbox/llm-checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAA4B,MAAM,OAAO,CAAC;AACjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,oBAAoB,CAAC;AAE5B;;GAEG;AACH,MAAM,WAAW,gBACf,SAAQ,IAAI,CACR,mBAAmB,CAAC,gBAAgB,CAAC,EACrC,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,CAC7C,EACD,eAAe;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,EAC1B,OAAe,EACf,eAAe,EACf,aAAqB,EACrB,OAAe,EACf,MAAW,EACX,QAAgB,EAChB,QAAQ,EAAE,aAAa,EACvB,QAAQ,EAAE,YAAY,EACtB,QAAgB,EAChB,QAAQ,EACR,SAAS,EACT,EAAE,EACF,IAAI,EACJ,GAAG,IAAI,EACR,EAAE,gBAAgB,2CAsDlB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useEffect, useId } from 'react';
|
|
3
|
+
import './llm-checkbox.css';
|
|
4
|
+
/**
|
|
5
|
+
* A checkbox component for selecting one or more options.
|
|
6
|
+
*/
|
|
7
|
+
export function LlmCheckbox({ checked = false, onCheckedChange, indeterminate = false, invalid = false, errors = [], disabled = false, readOnly: reactReadOnly, readonly: specReadOnly, required = false, children, className, id, name, ...rest }) {
|
|
8
|
+
const readOnly = reactReadOnly ?? specReadOnly ?? false;
|
|
9
|
+
const inputRef = useRef(null);
|
|
10
|
+
const generatedId = useId();
|
|
11
|
+
const inputId = id || `checkbox-${generatedId}`;
|
|
12
|
+
const errorId = `${inputId}-errors`;
|
|
13
|
+
const classes = [
|
|
14
|
+
'llm-checkbox',
|
|
15
|
+
checked && 'is-checked',
|
|
16
|
+
invalid && 'is-invalid',
|
|
17
|
+
disabled && 'is-disabled',
|
|
18
|
+
className,
|
|
19
|
+
]
|
|
20
|
+
.filter(Boolean)
|
|
21
|
+
.join(' ');
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (inputRef.current) {
|
|
24
|
+
inputRef.current.indeterminate = indeterminate;
|
|
25
|
+
}
|
|
26
|
+
}, [indeterminate]);
|
|
27
|
+
return (_jsxs("div", { className: classes, children: [_jsxs("label", { htmlFor: inputId, children: [_jsx("input", { ref: inputRef, type: "checkbox", id: inputId, checked: checked, onChange: (e) => onCheckedChange?.(e.target.checked), disabled: disabled, readOnly: readOnly, required: required, "aria-invalid": invalid || undefined, "aria-required": required || undefined, "aria-describedby": errors.length > 0 ? errorId : undefined, name: name, ...rest }), children] }), errors.length > 0 && (_jsx("div", { className: "errors", id: errorId, "aria-live": "polite", children: errors.map((err, i) => (_jsx("p", { className: "error-message", children: err }, i))) }))] }));
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=llm-checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-checkbox.js","sourceRoot":"","sources":["../../../../../../libs/react/src/lib/checkbox/llm-checkbox.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAEjF,OAAO,oBAAoB,CAAC;AAyC5B;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,EAC1B,OAAO,GAAG,KAAK,EACf,eAAe,EACf,aAAa,GAAG,KAAK,EACrB,OAAO,GAAG,KAAK,EACf,MAAM,GAAG,EAAE,EACX,QAAQ,GAAG,KAAK,EAChB,QAAQ,EAAE,aAAa,EACvB,QAAQ,EAAE,YAAY,EACtB,QAAQ,GAAG,KAAK,EAChB,QAAQ,EACR,SAAS,EACT,EAAE,EACF,IAAI,EACJ,GAAG,IAAI,EACU;IACjB,MAAM,QAAQ,GAAG,aAAa,IAAI,YAAY,IAAI,KAAK,CAAC;IACxD,MAAM,QAAQ,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;IAChD,MAAM,WAAW,GAAG,KAAK,EAAE,CAAC;IAC5B,MAAM,OAAO,GAAG,EAAE,IAAI,YAAY,WAAW,EAAE,CAAC;IAChD,MAAM,OAAO,GAAG,GAAG,OAAO,SAAS,CAAC;IAEpC,MAAM,OAAO,GAAG;QACd,cAAc;QACd,OAAO,IAAI,YAAY;QACvB,OAAO,IAAI,YAAY;QACvB,QAAQ,IAAI,aAAa;QACzB,SAAS;KACV;SACE,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAC;IAEb,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;YACrB,QAAQ,CAAC,OAAO,CAAC,aAAa,GAAG,aAAa,CAAC;QACjD,CAAC;IACH,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,OAAO,CACL,eAAK,SAAS,EAAE,OAAO,aACrB,iBAAO,OAAO,EAAE,OAAO,aACrB,gBACE,GAAG,EAAE,QAAQ,EACb,IAAI,EAAC,UAAU,EACf,EAAE,EAAE,OAAO,EACX,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,EACpD,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,kBACJ,OAAO,IAAI,SAAS,mBACnB,QAAQ,IAAI,SAAS,sBAClB,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EACzD,IAAI,EAAE,IAAI,KACN,IAAI,GACR,EACD,QAAQ,IACH,EACP,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,CACpB,cAAK,SAAS,EAAC,QAAQ,EAAC,EAAE,EAAE,OAAO,eAAY,QAAQ,YACpD,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CACtB,YAAW,SAAS,EAAC,eAAe,YACjC,GAAG,IADE,CAAC,CAEL,CACL,CAAC,GACE,CACP,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { InputHTMLAttributes, ReactNode, useRef, useEffect, useId } from 'react';\nimport type { LlmCheckboxSpec } from '@atelier-ui/spec';\nimport './llm-checkbox.css';\n\n/**\n * Properties for the LlmCheckbox component.\n */\nexport interface LlmCheckboxProps\n extends Omit<\n InputHTMLAttributes<HTMLInputElement>,\n 'type' | 'checked' | 'onChange' | 'readOnly'\n >,\n LlmCheckboxSpec {\n /**\n * Whether the checkbox is checked.\n */\n checked?: boolean;\n /**\n * Callback triggered when the checked state changes.\n */\n onCheckedChange?: (checked: boolean) => void;\n /**\n * Whether the checkbox is in an indeterminate state.\n */\n indeterminate?: boolean;\n /**\n * Whether the checkbox is in an invalid state.\n */\n invalid?: boolean;\n /**\n * Array of error messages to display.\n */\n errors?: string[];\n /**\n * Whether the checkbox is read-only.\n */\n readOnly?: boolean;\n /**\n * The content to be rendered as the label for the checkbox.\n */\n children?: ReactNode;\n}\n\n/**\n * A checkbox component for selecting one or more options.\n */\nexport function LlmCheckbox({\n checked = false,\n onCheckedChange,\n indeterminate = false,\n invalid = false,\n errors = [],\n disabled = false,\n readOnly: reactReadOnly,\n readonly: specReadOnly,\n required = false,\n children,\n className,\n id,\n name,\n ...rest\n}: LlmCheckboxProps) {\n const readOnly = reactReadOnly ?? specReadOnly ?? false;\n const inputRef = useRef<HTMLInputElement>(null);\n const generatedId = useId();\n const inputId = id || `checkbox-${generatedId}`;\n const errorId = `${inputId}-errors`;\n\n const classes = [\n 'llm-checkbox',\n checked && 'is-checked',\n invalid && 'is-invalid',\n disabled && 'is-disabled',\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n useEffect(() => {\n if (inputRef.current) {\n inputRef.current.indeterminate = indeterminate;\n }\n }, [indeterminate]);\n\n return (\n <div className={classes}>\n <label htmlFor={inputId}>\n <input\n ref={inputRef}\n type=\"checkbox\"\n id={inputId}\n checked={checked}\n onChange={(e) => onCheckedChange?.(e.target.checked)}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n aria-invalid={invalid || undefined}\n aria-required={required || undefined}\n aria-describedby={errors.length > 0 ? errorId : undefined}\n name={name}\n {...rest}\n />\n {children}\n </label>\n {errors.length > 0 && (\n <div className=\"errors\" id={errorId} aria-live=\"polite\">\n {errors.map((err, i) => (\n <p key={i} className=\"error-message\">\n {err}\n </p>\n ))}\n </div>\n )}\n </div>\n );\n}\n"]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ReactNode, HTMLAttributes } from 'react';
|
|
2
|
+
import type { LlmDialogSpec } from '@atelier-ui/spec';
|
|
3
|
+
import './llm-dialog.css';
|
|
4
|
+
/**
|
|
5
|
+
* Properties for the LlmDialog component.
|
|
6
|
+
*/
|
|
7
|
+
export interface LlmDialogProps extends LlmDialogSpec {
|
|
8
|
+
/**
|
|
9
|
+
* Whether the dialog is open.
|
|
10
|
+
*/
|
|
11
|
+
open?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Callback triggered when the open state changes.
|
|
14
|
+
*/
|
|
15
|
+
onOpenChange?: (open: boolean) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Whether to close the dialog when clicking on the backdrop.
|
|
18
|
+
*/
|
|
19
|
+
closeOnBackdrop?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The size of the dialog.
|
|
22
|
+
*/
|
|
23
|
+
size?: 'sm' | 'md' | 'lg' | 'xl' | 'full';
|
|
24
|
+
/**
|
|
25
|
+
* Accessible label for the dialog.
|
|
26
|
+
*/
|
|
27
|
+
'aria-label'?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Accessible label provided by another element.
|
|
30
|
+
*/
|
|
31
|
+
'aria-labelledby'?: string;
|
|
32
|
+
/**
|
|
33
|
+
* The content of the dialog.
|
|
34
|
+
*/
|
|
35
|
+
children?: ReactNode;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A dialog (modal) component for displaying content on top of the main UI.
|
|
39
|
+
*/
|
|
40
|
+
export declare function LlmDialog({ open, onOpenChange, closeOnBackdrop, size, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, children, }: LlmDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
/**
|
|
42
|
+
* The header component for an LlmDialog.
|
|
43
|
+
*/
|
|
44
|
+
export declare function LlmDialogHeader({ children, className, ...rest }: HTMLAttributes<HTMLDivElement> & {
|
|
45
|
+
/**
|
|
46
|
+
* The content of the dialog header.
|
|
47
|
+
*/
|
|
48
|
+
children?: ReactNode;
|
|
49
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
50
|
+
/**
|
|
51
|
+
* The main content component for an LlmDialog.
|
|
52
|
+
*/
|
|
53
|
+
export declare function LlmDialogContent({ children, className, ...rest }: HTMLAttributes<HTMLDivElement> & {
|
|
54
|
+
/**
|
|
55
|
+
* The main content of the dialog.
|
|
56
|
+
*/
|
|
57
|
+
children?: ReactNode;
|
|
58
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
59
|
+
/**
|
|
60
|
+
* The footer component for an LlmDialog.
|
|
61
|
+
*/
|
|
62
|
+
export declare function LlmDialogFooter({ children, className, ...rest }: HTMLAttributes<HTMLDivElement> & {
|
|
63
|
+
/**
|
|
64
|
+
* The content of the dialog footer.
|
|
65
|
+
*/
|
|
66
|
+
children?: ReactNode;
|
|
67
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
68
|
+
//# sourceMappingURL=llm-dialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-dialog.d.ts","sourceRoot":"","sources":["../../../../../../libs/react/src/lib/dialog/llm-dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,SAAS,EACT,cAAc,EAEf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,kBAAkB,CAAC;AAY1B;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;IAC1C;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,EACxB,IAAY,EACZ,YAAY,EACZ,eAAsB,EACtB,IAAW,EACX,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,cAAc,EACjC,QAAQ,GACT,EAAE,cAAc,2CA2DhB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EACR,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG;IAClC;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,2CAiCA;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EACR,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG;IAClC;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,2CASA;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EACR,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG;IAClC;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,2CASA"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useId, createContext, useContext, } from 'react';
|
|
3
|
+
import './llm-dialog.css';
|
|
4
|
+
const DialogContext = createContext({
|
|
5
|
+
headerId: '',
|
|
6
|
+
close: () => undefined,
|
|
7
|
+
});
|
|
8
|
+
/**
|
|
9
|
+
* A dialog (modal) component for displaying content on top of the main UI.
|
|
10
|
+
*/
|
|
11
|
+
export function LlmDialog({ open = false, onOpenChange, closeOnBackdrop = true, size = 'md', 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, children, }) {
|
|
12
|
+
const dialogRef = useRef(null);
|
|
13
|
+
const headerId = useId();
|
|
14
|
+
const triggerElRef = useRef(null);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const dialog = dialogRef.current;
|
|
17
|
+
if (!dialog)
|
|
18
|
+
return;
|
|
19
|
+
if (open) {
|
|
20
|
+
triggerElRef.current = document.activeElement;
|
|
21
|
+
if (!dialog.open)
|
|
22
|
+
dialog.showModal();
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
if (dialog.open)
|
|
26
|
+
dialog.close();
|
|
27
|
+
triggerElRef.current?.focus();
|
|
28
|
+
triggerElRef.current = null;
|
|
29
|
+
}
|
|
30
|
+
}, [open]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
const dialog = dialogRef.current;
|
|
33
|
+
if (!dialog)
|
|
34
|
+
return;
|
|
35
|
+
const onClose = () => onOpenChange?.(false);
|
|
36
|
+
const onCancel = (e) => {
|
|
37
|
+
e.preventDefault();
|
|
38
|
+
onOpenChange?.(false);
|
|
39
|
+
};
|
|
40
|
+
dialog.addEventListener('close', onClose);
|
|
41
|
+
dialog.addEventListener('cancel', onCancel);
|
|
42
|
+
return () => {
|
|
43
|
+
dialog.removeEventListener('close', onClose);
|
|
44
|
+
dialog.removeEventListener('cancel', onCancel);
|
|
45
|
+
};
|
|
46
|
+
}, [onOpenChange]);
|
|
47
|
+
const handleBackdropClick = (e) => {
|
|
48
|
+
if (!closeOnBackdrop)
|
|
49
|
+
return;
|
|
50
|
+
if (e.target === dialogRef.current) {
|
|
51
|
+
onOpenChange?.(false);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const effectiveAriaLabelledby = ariaLabel ? undefined : (ariaLabelledby ?? headerId);
|
|
55
|
+
return (_jsx(DialogContext.Provider, { value: { headerId, close: () => onOpenChange?.(false) }, children: _jsx("dialog", { ref: dialogRef, className: `llm-dialog${open ? ' is-open' : ''}`, "aria-label": ariaLabel || undefined, "aria-labelledby": effectiveAriaLabelledby, "aria-modal": "true", onClick: handleBackdropClick, children: _jsx("div", { className: `panel size-${size}`, onClick: (e) => e.stopPropagation(), children: children }) }) }));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The header component for an LlmDialog.
|
|
59
|
+
*/
|
|
60
|
+
export function LlmDialogHeader({ children, className, ...rest }) {
|
|
61
|
+
const ctx = useContext(DialogContext);
|
|
62
|
+
return (_jsxs("div", { id: ctx.headerId, className: ['llm-dialog-header', className].filter(Boolean).join(' '), ...rest, children: [children, _jsx("button", { className: "close-btn", type: "button", "aria-label": "Close dialog", onClick: ctx.close, children: _jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [_jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), _jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })] }) })] }));
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The main content component for an LlmDialog.
|
|
66
|
+
*/
|
|
67
|
+
export function LlmDialogContent({ children, className, ...rest }) {
|
|
68
|
+
return (_jsx("div", { className: ['llm-dialog-content', className].filter(Boolean).join(' '), ...rest, children: children }));
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The footer component for an LlmDialog.
|
|
72
|
+
*/
|
|
73
|
+
export function LlmDialogFooter({ children, className, ...rest }) {
|
|
74
|
+
return (_jsx("div", { className: ['llm-dialog-footer', className].filter(Boolean).join(' '), ...rest, children: children }));
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=llm-dialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-dialog.js","sourceRoot":"","sources":["../../../../../../libs/react/src/lib/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CACL,cACE,SAAS,EAAE,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAClE,IAAI,YAEP,QAAQ,GACL,CACP,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,EAC9B,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EAMR;IACC,OAAO,CACL,cACE,SAAS,EAAE,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KACjE,IAAI,YAEP,QAAQ,GACL,CACP,CAAC;AACJ,CAAC","sourcesContent":["import {\n useEffect,\n useRef,\n useId,\n createContext,\n useContext,\n ReactNode,\n HTMLAttributes,\n MouseEvent,\n} from 'react';\nimport type { LlmDialogSpec } from '@atelier-ui/spec';\nimport './llm-dialog.css';\n\ninterface DialogContextValue {\n headerId: string;\n close: () => void;\n}\n\nconst DialogContext = createContext<DialogContextValue>({\n headerId: '',\n close: () => undefined,\n});\n\n/**\n * Properties for the LlmDialog component.\n */\nexport interface LlmDialogProps extends LlmDialogSpec {\n /**\n * Whether the dialog is open.\n */\n open?: boolean;\n /**\n * Callback triggered when the open state changes.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * Whether to close the dialog when clicking on the backdrop.\n */\n closeOnBackdrop?: boolean;\n /**\n * The size of the dialog.\n */\n size?: 'sm' | 'md' | 'lg' | 'xl' | 'full';\n /**\n * Accessible label for the dialog.\n */\n 'aria-label'?: string;\n /**\n * Accessible label provided by another element.\n */\n 'aria-labelledby'?: string;\n /**\n * The content of the dialog.\n */\n children?: ReactNode;\n}\n\n/**\n * A dialog (modal) component for displaying content on top of the main UI.\n */\nexport function LlmDialog({\n open = false,\n onOpenChange,\n closeOnBackdrop = true,\n size = 'md',\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n children,\n}: LlmDialogProps) {\n const dialogRef = useRef<HTMLDialogElement>(null);\n const headerId = useId();\n const triggerElRef = useRef<Element | null>(null);\n\n useEffect(() => {\n const dialog = dialogRef.current;\n if (!dialog) return;\n if (open) {\n triggerElRef.current = document.activeElement;\n if (!dialog.open) dialog.showModal();\n } else {\n if (dialog.open) dialog.close();\n (triggerElRef.current as HTMLElement | null)?.focus();\n triggerElRef.current = null;\n }\n }, [open]);\n\n useEffect(() => {\n const dialog = dialogRef.current;\n if (!dialog) return;\n const onClose = () => onOpenChange?.(false);\n const onCancel = (e: Event) => {\n e.preventDefault();\n onOpenChange?.(false);\n };\n dialog.addEventListener('close', onClose);\n dialog.addEventListener('cancel', onCancel);\n return () => {\n dialog.removeEventListener('close', onClose);\n dialog.removeEventListener('cancel', onCancel);\n };\n }, [onOpenChange]);\n\n const handleBackdropClick = (e: MouseEvent<HTMLDialogElement>) => {\n if (!closeOnBackdrop) return;\n if (e.target === dialogRef.current) {\n onOpenChange?.(false);\n }\n };\n\n const effectiveAriaLabelledby = ariaLabel ? undefined : (ariaLabelledby ?? headerId);\n\n return (\n <DialogContext.Provider value={{ headerId, close: () => onOpenChange?.(false) }}>\n <dialog\n ref={dialogRef}\n className={`llm-dialog${open ? ' is-open' : ''}`}\n aria-label={ariaLabel || undefined}\n aria-labelledby={effectiveAriaLabelledby}\n aria-modal=\"true\"\n onClick={handleBackdropClick}\n >\n <div className={`panel size-${size}`} onClick={(e) => e.stopPropagation()}>\n {children}\n </div>\n </dialog>\n </DialogContext.Provider>\n );\n}\n\n/**\n * The header component for an LlmDialog.\n */\nexport function LlmDialogHeader({\n children,\n className,\n ...rest\n}: HTMLAttributes<HTMLDivElement> & {\n /**\n * The content of the dialog header.\n */\n children?: ReactNode;\n}) {\n const ctx = useContext(DialogContext);\n return (\n <div\n id={ctx.headerId}\n className={['llm-dialog-header', className].filter(Boolean).join(' ')}\n {...rest}\n >\n {children}\n <button\n className=\"close-btn\"\n type=\"button\"\n aria-label=\"Close dialog\"\n onClick={ctx.close}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n </button>\n </div>\n );\n}\n\n/**\n * The main content component for an LlmDialog.\n */\nexport function LlmDialogContent({\n children,\n className,\n ...rest\n}: HTMLAttributes<HTMLDivElement> & {\n /**\n * The main content of the dialog.\n */\n children?: ReactNode;\n}) {\n return (\n <div\n className={['llm-dialog-content', className].filter(Boolean).join(' ')}\n {...rest}\n >\n {children}\n </div>\n );\n}\n\n/**\n * The footer component for an LlmDialog.\n */\nexport function LlmDialogFooter({\n children,\n className,\n ...rest\n}: HTMLAttributes<HTMLDivElement> & {\n /**\n * The content of the dialog footer.\n */\n children?: ReactNode;\n}) {\n return (\n <div\n className={['llm-dialog-footer', className].filter(Boolean).join(' ')}\n {...rest}\n >\n {children}\n </div>\n );\n}\n"]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ReactNode, HTMLAttributes } from 'react';
|
|
2
|
+
import type { LlmDrawerSpec } from '@atelier-ui/spec';
|
|
3
|
+
import './llm-drawer.css';
|
|
4
|
+
/**
|
|
5
|
+
* Properties for the LlmDrawer component.
|
|
6
|
+
*/
|
|
7
|
+
export interface LlmDrawerProps extends LlmDrawerSpec {
|
|
8
|
+
/**
|
|
9
|
+
* Whether the drawer is open.
|
|
10
|
+
*/
|
|
11
|
+
open?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Callback triggered when the open state changes.
|
|
14
|
+
*/
|
|
15
|
+
onOpenChange?: (open: boolean) => void;
|
|
16
|
+
/**
|
|
17
|
+
* The position of the drawer on the screen.
|
|
18
|
+
*/
|
|
19
|
+
position?: 'left' | 'right' | 'top' | 'bottom';
|
|
20
|
+
/**
|
|
21
|
+
* The size of the drawer.
|
|
22
|
+
*/
|
|
23
|
+
size?: 'sm' | 'md' | 'lg' | 'full';
|
|
24
|
+
/**
|
|
25
|
+
* Whether to close the drawer when clicking on the backdrop.
|
|
26
|
+
*/
|
|
27
|
+
closeOnBackdrop?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* The content of the drawer.
|
|
30
|
+
*/
|
|
31
|
+
children?: ReactNode;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A drawer component that slides in from the edge of the screen.
|
|
35
|
+
*/
|
|
36
|
+
export declare function LlmDrawer({ open, onOpenChange, position, size, closeOnBackdrop, children, }: LlmDrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
/**
|
|
38
|
+
* The header component for an LlmDrawer.
|
|
39
|
+
*/
|
|
40
|
+
export declare function LlmDrawerHeader({ children, className, ...rest }: HTMLAttributes<HTMLDivElement> & {
|
|
41
|
+
/**
|
|
42
|
+
* The content of the drawer header.
|
|
43
|
+
*/
|
|
44
|
+
children?: ReactNode;
|
|
45
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
46
|
+
/**
|
|
47
|
+
* The main content component for an LlmDrawer.
|
|
48
|
+
*/
|
|
49
|
+
export declare function LlmDrawerContent({ children, className, ...rest }: HTMLAttributes<HTMLDivElement> & {
|
|
50
|
+
/**
|
|
51
|
+
* The main content of the drawer.
|
|
52
|
+
*/
|
|
53
|
+
children?: ReactNode;
|
|
54
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
55
|
+
/**
|
|
56
|
+
* The footer component for an LlmDrawer.
|
|
57
|
+
*/
|
|
58
|
+
export declare function LlmDrawerFooter({ children, className, ...rest }: HTMLAttributes<HTMLDivElement> & {
|
|
59
|
+
/**
|
|
60
|
+
* The content of the drawer footer.
|
|
61
|
+
*/
|
|
62
|
+
children?: ReactNode;
|
|
63
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
64
|
+
//# sourceMappingURL=llm-drawer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-drawer.d.ts","sourceRoot":"","sources":["../../../../../../libs/react/src/lib/drawer/llm-drawer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,SAAS,EACT,cAAc,EAEf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,kBAAkB,CAAC;AAY1B;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;IAC/C;;OAEG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;IACnC;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,EACxB,IAAY,EACZ,YAAY,EACZ,QAAkB,EAClB,IAAW,EACX,eAAsB,EACtB,QAAQ,GACT,EAAE,cAAc,2CAkEhB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EACR,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG;IAClC;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,2CAiCA;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EACR,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG;IAClC;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,2CASA;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EACR,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG;IAClC;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,2CASA"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useId, createContext, useContext, } from 'react';
|
|
3
|
+
import './llm-drawer.css';
|
|
4
|
+
const DrawerContext = createContext({
|
|
5
|
+
headerId: '',
|
|
6
|
+
close: () => undefined,
|
|
7
|
+
});
|
|
8
|
+
/**
|
|
9
|
+
* A drawer component that slides in from the edge of the screen.
|
|
10
|
+
*/
|
|
11
|
+
export function LlmDrawer({ open = false, onOpenChange, position = 'right', size = 'md', closeOnBackdrop = true, children, }) {
|
|
12
|
+
const dialogRef = useRef(null);
|
|
13
|
+
const headerId = useId();
|
|
14
|
+
const triggerElRef = useRef(null);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const dialog = dialogRef.current;
|
|
17
|
+
if (!dialog)
|
|
18
|
+
return;
|
|
19
|
+
if (open) {
|
|
20
|
+
triggerElRef.current = document.activeElement;
|
|
21
|
+
if (!dialog.open)
|
|
22
|
+
dialog.showModal();
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
if (dialog.open)
|
|
26
|
+
dialog.close();
|
|
27
|
+
triggerElRef.current?.focus();
|
|
28
|
+
triggerElRef.current = null;
|
|
29
|
+
}
|
|
30
|
+
}, [open]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
const dialog = dialogRef.current;
|
|
33
|
+
if (!dialog)
|
|
34
|
+
return;
|
|
35
|
+
const onClose = () => onOpenChange?.(false);
|
|
36
|
+
const onCancel = (e) => {
|
|
37
|
+
e.preventDefault();
|
|
38
|
+
onOpenChange?.(false);
|
|
39
|
+
};
|
|
40
|
+
dialog.addEventListener('close', onClose);
|
|
41
|
+
dialog.addEventListener('cancel', onCancel);
|
|
42
|
+
return () => {
|
|
43
|
+
dialog.removeEventListener('close', onClose);
|
|
44
|
+
dialog.removeEventListener('cancel', onCancel);
|
|
45
|
+
};
|
|
46
|
+
}, [onOpenChange]);
|
|
47
|
+
const handleBackdropClick = (e) => {
|
|
48
|
+
if (!closeOnBackdrop)
|
|
49
|
+
return;
|
|
50
|
+
if (e.target === dialogRef.current) {
|
|
51
|
+
onOpenChange?.(false);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const hostClass = [
|
|
55
|
+
'llm-drawer-host',
|
|
56
|
+
`position-${position}`,
|
|
57
|
+
`size-${size}`,
|
|
58
|
+
open && 'is-open',
|
|
59
|
+
]
|
|
60
|
+
.filter(Boolean)
|
|
61
|
+
.join(' ');
|
|
62
|
+
return (_jsx(DrawerContext.Provider, { value: { headerId, close: () => onOpenChange?.(false) }, children: _jsx("div", { className: hostClass, children: _jsx("dialog", { ref: dialogRef, "aria-labelledby": headerId, "aria-modal": "true", onClick: handleBackdropClick, children: _jsx("div", { className: "panel", onClick: (e) => e.stopPropagation(), children: children }) }) }) }));
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The header component for an LlmDrawer.
|
|
66
|
+
*/
|
|
67
|
+
export function LlmDrawerHeader({ children, className, ...rest }) {
|
|
68
|
+
const ctx = useContext(DrawerContext);
|
|
69
|
+
return (_jsxs("div", { id: ctx.headerId, className: ['llm-drawer-header', className].filter(Boolean).join(' '), ...rest, children: [children, _jsx("button", { className: "close-btn", type: "button", "aria-label": "Close drawer", onClick: ctx.close, children: _jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [_jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), _jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })] }) })] }));
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The main content component for an LlmDrawer.
|
|
73
|
+
*/
|
|
74
|
+
export function LlmDrawerContent({ children, className, ...rest }) {
|
|
75
|
+
return (_jsx("div", { className: ['llm-drawer-content', className].filter(Boolean).join(' '), ...rest, children: children }));
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The footer component for an LlmDrawer.
|
|
79
|
+
*/
|
|
80
|
+
export function LlmDrawerFooter({ children, className, ...rest }) {
|
|
81
|
+
return (_jsx("div", { className: ['llm-drawer-footer', className].filter(Boolean).join(' '), ...rest, children: children }));
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=llm-drawer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-drawer.js","sourceRoot":"","sources":["../../../../../../libs/react/src/lib/drawer/llm-drawer.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,SAAS,EACT,MAAM,EACN,KAAK,EACL,aAAa,EACb,UAAU,GAIX,MAAM,OAAO,CAAC;AAEf,OAAO,kBAAkB,CAAC;AAO1B,MAAM,aAAa,GAAG,aAAa,CAAqB;IACtD,QAAQ,EAAE,EAAE;IACZ,KAAK,EAAE,GAAG,EAAE,CAAC,SAAS;CACvB,CAAC,CAAC;AAgCH;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,EACxB,IAAI,GAAG,KAAK,EACZ,YAAY,EACZ,QAAQ,GAAG,OAAO,EAClB,IAAI,GAAG,IAAI,EACX,eAAe,GAAG,IAAI,EACtB,QAAQ,GACO;IACf,MAAM,SAAS,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IAClD,MAAM,QAAQ,GAAG,KAAK,EAAE,CAAC;IACzB,MAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAElD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,MAAM,GA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C,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,KAAK,EACjB,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,iBACV,MAAM,aAElB,eAAM,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,IAAI,GAAG,EACtC,eAAM,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,GAAG,IAClC,GACC,IACL,CACP,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAC/B,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EAMR;IACC,OAAO,CACL,cACE,SAAS,EAAE,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAClE,IAAI,YAEP,QAAQ,GACL,CACP,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,EAC9B,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EAMR;IACC,OAAO,CACL,cACE,SAAS,EAAE,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KACjE,IAAI,YAEP,QAAQ,GACL,CACP,CAAC;AACJ,CAAC","sourcesContent":["import {\n useEffect,\n useRef,\n useId,\n createContext,\n useContext,\n ReactNode,\n HTMLAttributes,\n MouseEvent,\n} from 'react';\nimport type { LlmDrawerSpec } from '@atelier-ui/spec';\nimport './llm-drawer.css';\n\ninterface DrawerContextValue {\n headerId: string;\n close: () => void;\n}\n\nconst DrawerContext = createContext<DrawerContextValue>({\n headerId: '',\n close: () => undefined,\n});\n\n/**\n * Properties for the LlmDrawer component.\n */\nexport interface LlmDrawerProps extends LlmDrawerSpec {\n /**\n * Whether the drawer is open.\n */\n open?: boolean;\n /**\n * Callback triggered when the open state changes.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * The position of the drawer on the screen.\n */\n position?: 'left' | 'right' | 'top' | 'bottom';\n /**\n * The size of the drawer.\n */\n size?: 'sm' | 'md' | 'lg' | 'full';\n /**\n * Whether to close the drawer when clicking on the backdrop.\n */\n closeOnBackdrop?: boolean;\n /**\n * The content of the drawer.\n */\n children?: ReactNode;\n}\n\n/**\n * A drawer component that slides in from the edge of the screen.\n */\nexport function LlmDrawer({\n open = false,\n onOpenChange,\n position = 'right',\n size = 'md',\n closeOnBackdrop = true,\n children,\n}: LlmDrawerProps) {\n const dialogRef = useRef<HTMLDialogElement>(null);\n const headerId = useId();\n const triggerElRef = useRef<Element | null>(null);\n\n useEffect(() => {\n const dialog = dialogRef.current;\n if (!dialog) return;\n if (open) {\n triggerElRef.current = document.activeElement;\n if (!dialog.open) dialog.showModal();\n } else {\n if (dialog.open) dialog.close();\n (triggerElRef.current as HTMLElement | null)?.focus();\n triggerElRef.current = null;\n }\n }, [open]);\n\n useEffect(() => {\n const dialog = dialogRef.current;\n if (!dialog) return;\n const onClose = () => onOpenChange?.(false);\n const onCancel = (e: Event) => {\n e.preventDefault();\n onOpenChange?.(false);\n };\n dialog.addEventListener('close', onClose);\n dialog.addEventListener('cancel', onCancel);\n return () => {\n dialog.removeEventListener('close', onClose);\n dialog.removeEventListener('cancel', onCancel);\n };\n }, [onOpenChange]);\n\n const handleBackdropClick = (e: MouseEvent<HTMLDialogElement>) => {\n if (!closeOnBackdrop) return;\n if (e.target === dialogRef.current) {\n onOpenChange?.(false);\n }\n };\n\n const hostClass = [\n 'llm-drawer-host',\n `position-${position}`,\n `size-${size}`,\n open && 'is-open',\n ]\n .filter(Boolean)\n .join(' ');\n\n return (\n <DrawerContext.Provider value={{ headerId, close: () => onOpenChange?.(false) }}>\n <div className={hostClass}>\n <dialog\n ref={dialogRef}\n aria-labelledby={headerId}\n aria-modal=\"true\"\n onClick={handleBackdropClick}\n >\n <div className=\"panel\" onClick={(e) => e.stopPropagation()}>\n {children}\n </div>\n </dialog>\n </div>\n </DrawerContext.Provider>\n );\n}\n\n/**\n * The header component for an LlmDrawer.\n */\nexport function LlmDrawerHeader({\n children,\n className,\n ...rest\n}: HTMLAttributes<HTMLDivElement> & {\n /**\n * The content of the drawer header.\n */\n children?: ReactNode;\n}) {\n const ctx = useContext(DrawerContext);\n return (\n <div\n id={ctx.headerId}\n className={['llm-drawer-header', className].filter(Boolean).join(' ')}\n {...rest}\n >\n {children}\n <button\n className=\"close-btn\"\n type=\"button\"\n aria-label=\"Close drawer\"\n onClick={ctx.close}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n </button>\n </div>\n );\n}\n\n/**\n * The main content component for an LlmDrawer.\n */\nexport function LlmDrawerContent({\n children,\n className,\n ...rest\n}: HTMLAttributes<HTMLDivElement> & {\n /**\n * The main content of the drawer.\n */\n children?: ReactNode;\n}) {\n return (\n <div\n className={['llm-drawer-content', className].filter(Boolean).join(' ')}\n {...rest}\n >\n {children}\n </div>\n );\n}\n\n/**\n * The footer component for an LlmDrawer.\n */\nexport function LlmDrawerFooter({\n children,\n className,\n ...rest\n}: HTMLAttributes<HTMLDivElement> & {\n /**\n * The content of the drawer footer.\n */\n children?: ReactNode;\n}) {\n return (\n <div\n className={['llm-drawer-footer', className].filter(Boolean).join(' ')}\n {...rest}\n >\n {children}\n </div>\n );\n}\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { InputHTMLAttributes } from 'react';
|
|
2
|
+
import type { LlmInputSpec } from '@atelier-ui/spec';
|
|
3
|
+
import './llm-input.css';
|
|
4
|
+
/**
|
|
5
|
+
* Properties for the LlmInput component.
|
|
6
|
+
*/
|
|
7
|
+
export interface LlmInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'readOnly'>, LlmInputSpec {
|
|
8
|
+
/**
|
|
9
|
+
* The type of input to render.
|
|
10
|
+
*/
|
|
11
|
+
type?: 'text' | 'email' | 'password' | 'number' | 'tel' | 'url';
|
|
12
|
+
/**
|
|
13
|
+
* The current value of the input.
|
|
14
|
+
*/
|
|
15
|
+
value?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Callback triggered when the value changes.
|
|
18
|
+
*/
|
|
19
|
+
onValueChange?: (value: string) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Whether the input is in an invalid state.
|
|
22
|
+
*/
|
|
23
|
+
invalid?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Array of error messages to display.
|
|
26
|
+
*/
|
|
27
|
+
errors?: string[];
|
|
28
|
+
/**
|
|
29
|
+
* The label for the input.
|
|
30
|
+
*/
|
|
31
|
+
label?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Whether the input is read-only.
|
|
34
|
+
*/
|
|
35
|
+
readOnly?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A versatile input component for text entry.
|
|
39
|
+
*/
|
|
40
|
+
export declare function LlmInput({ type, value, onChange, onValueChange, invalid, errors, disabled, readOnly: reactReadOnly, readonly: specReadOnly, required, label, className, id, ...rest }: LlmInputProps): import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
//# sourceMappingURL=llm-input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-input.d.ts","sourceRoot":"","sources":["../../../../../../libs/react/src/lib/input/llm-input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,iBAAiB,CAAC;AAEzB;;GAEG;AACH,MAAM,WAAW,aACf,SAAQ,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC,EACtE,YAAY;IACd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,GAAG,KAAK,GAAG,KAAK,CAAC;IAChE;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,EACvB,IAAa,EACb,KAAK,EACL,QAAQ,EACR,aAAa,EACb,OAAe,EACf,MAAW,EACX,QAAgB,EAChB,QAAQ,EAAE,aAAa,EACvB,QAAQ,EAAE,YAAY,EACtB,QAAgB,EAChB,KAAK,EACL,SAAS,EACT,EAAE,EACF,GAAG,IAAI,EACR,EAAE,aAAa,2CAgDf"}
|