@oneplatformdev/ui 0.1.10-79 → 0.1.10-80
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlertDialog.d.ts","sourceRoot":"","sources":["../../src/AlertDialog/AlertDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,EAAE,EAEF,iBAAiB,EAGlB,MAAM,OAAO,CAAC;AAYf,OAAO,EAKL,gBAAgB,EAGjB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"AlertDialog.d.ts","sourceRoot":"","sources":["../../src/AlertDialog/AlertDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,EAAE,EAEF,iBAAiB,EAGlB,MAAM,OAAO,CAAC;AAYf,OAAO,EAKL,gBAAgB,EAGjB,MAAM,qBAAqB,CAAC;AAoI7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAiC/D,CAAA;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { jsxs as g, jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { cloneElement as a, useId as j, Children as y } from "react";
|
|
3
|
-
import { AlertDialogRoot as E, AlertDialogContent as
|
|
3
|
+
import { AlertDialogRoot as E, AlertDialogContent as h, AlertDialogTrigger as B, AlertDialogHeader as f, AlertDialogTitle as v, AlertDialogDescription as R, AlertDialogFooter as A, AlertDialogAction as D, AlertDialogCancel as k } from "./AlertDialogRoot.js";
|
|
4
4
|
import { isValidReactElement as s } from "@oneplatformdev/utils";
|
|
5
5
|
const F = (o) => {
|
|
6
6
|
const { slotProps: e = {}, children: r } = o, i = e.trigger ?? {};
|
|
7
|
-
return s(r,
|
|
7
|
+
return s(r, B) ? a(
|
|
8
8
|
r,
|
|
9
9
|
{
|
|
10
10
|
...r.props || {},
|
|
11
11
|
...i
|
|
12
12
|
}
|
|
13
|
-
) : /* @__PURE__ */ t(
|
|
13
|
+
) : /* @__PURE__ */ t(B, { asChild: !0, children: r });
|
|
14
14
|
}, H = (o) => {
|
|
15
15
|
const {
|
|
16
16
|
title: e = "",
|
|
@@ -22,10 +22,10 @@ const F = (o) => {
|
|
|
22
22
|
l,
|
|
23
23
|
{ ...l.props || {}, ...n }
|
|
24
24
|
) : /* @__PURE__ */ t(f, { ...n, children: l }) : /* @__PURE__ */ g(f, { children: [
|
|
25
|
-
e && s(e,
|
|
25
|
+
e && s(e, v) ? a(
|
|
26
26
|
e,
|
|
27
27
|
{ ...e.props || {}, ...d }
|
|
28
|
-
) : /* @__PURE__ */ t(
|
|
28
|
+
) : /* @__PURE__ */ t(v, { ...d, children: e }),
|
|
29
29
|
r && s(r, R) ? a(
|
|
30
30
|
r,
|
|
31
31
|
{ ...r.props || {}, ...c }
|
|
@@ -46,13 +46,12 @@ const F = (o) => {
|
|
|
46
46
|
{ ...r.props || {}, ...m }
|
|
47
47
|
) : /* @__PURE__ */ t(A, { ...m, children: y.map(r, (p, b) => {
|
|
48
48
|
if (!p || !s(p)) return;
|
|
49
|
-
const
|
|
49
|
+
const u = p, P = a(u, { ...u.props || {}, key: u.key || `footer-${x}-action-${b}` });
|
|
50
50
|
return s(p, D) || s(p, k) ? P : /* @__PURE__ */ t(D, { asChild: !0, children: P });
|
|
51
51
|
}) }) : /* @__PURE__ */ g(A, { children: [
|
|
52
52
|
c !== "alert" && /* @__PURE__ */ t(
|
|
53
53
|
k,
|
|
54
54
|
{
|
|
55
|
-
variant: "ghost",
|
|
56
55
|
onClick: i,
|
|
57
56
|
...T,
|
|
58
57
|
children: n
|
|
@@ -79,13 +78,13 @@ const F = (o) => {
|
|
|
79
78
|
} = o, c = l.content ?? {};
|
|
80
79
|
return /* @__PURE__ */ g(E, { ...d, children: [
|
|
81
80
|
/* @__PURE__ */ t(F, { ...o, children: e }),
|
|
82
|
-
n ? s(n,
|
|
81
|
+
n ? s(n, h) ? a(
|
|
83
82
|
n,
|
|
84
83
|
{
|
|
85
84
|
...n.props || {},
|
|
86
85
|
...c
|
|
87
86
|
}
|
|
88
|
-
) : /* @__PURE__ */ t(
|
|
87
|
+
) : /* @__PURE__ */ t(h, { ...c, children: n }) : /* @__PURE__ */ g(h, { ...c, children: [
|
|
89
88
|
/* @__PURE__ */ t(H, { ...o, children: r }),
|
|
90
89
|
/* @__PURE__ */ t(I, { ...o, children: i })
|
|
91
90
|
] })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlertDialog.js","sources":["../../src/AlertDialog/AlertDialog.tsx"],"sourcesContent":["import {\n Children,\n cloneElement,\n FC,\n Key,\n PropsWithChildren,\n ReactElement,\n useId,\n} from 'react';\nimport {\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogRoot,\n AlertDialogTitle,\n AlertDialogTrigger,\n} from './AlertDialogRoot';\nimport {\n AlertDialogContentProps,\n AlertDialogDescriptionProps,\n AlertDialogFooterProps,\n AlertDialogHeaderProps,\n AlertDialogProps,\n AlertDialogTitleProps,\n AlertDialogTriggerProps,\n} from './AlertDialog.types';\n\nimport { isValidReactElement } from '@oneplatformdev/utils';\n\nconst RenderAlertDialogTrigger: FC<PropsWithChildren<AlertDialogProps>> = (\n props\n) => {\n const { slotProps = {}, children } = props;\n\n const triggerProps = slotProps.trigger ?? {};\n\n if (isValidReactElement(children, AlertDialogTrigger)) {\n return cloneElement<AlertDialogTriggerProps>(\n children as ReactElement<AlertDialogTriggerProps>,\n {\n ...((children as ReactElement<AlertDialogTriggerProps>).props || {}),\n ...triggerProps,\n }\n );\n }\n\n return <AlertDialogTrigger asChild>{children}</AlertDialogTrigger>;\n};\n\nconst RenderAlertDialogHeader: FC<PropsWithChildren<AlertDialogProps>> = (props) => {\n const {\n title = '',\n description = '',\n slotProps = {},\n children,\n } = props;\n\n const headerProps = slotProps.header ?? {};\n const titleProps = slotProps.title ?? {};\n const descriptionProps = slotProps.description ?? {};\n\n if(children) {\n return isValidReactElement(children, AlertDialogHeader)\n ? cloneElement<AlertDialogHeaderProps>(\n children as ReactElement<AlertDialogHeaderProps>,\n { ...((children as ReactElement<AlertDialogHeaderProps>).props || {}), ...headerProps }\n )\n : <AlertDialogHeader {...headerProps}>{children}</AlertDialogHeader>\n }\n\n return (\n <AlertDialogHeader>\n {Boolean(title) && isValidReactElement(title, AlertDialogTitle)\n ? cloneElement<AlertDialogTitleProps>(\n title as ReactElement<AlertDialogTitleProps>,\n { ...((title as ReactElement<AlertDialogTitleProps>).props || {}), ...titleProps }\n )\n : <AlertDialogTitle {...titleProps}>{title}</AlertDialogTitle>}\n\n {Boolean(description) && isValidReactElement(description, AlertDialogDescription)\n ? cloneElement<AlertDialogDescriptionProps>(\n description as ReactElement<AlertDialogDescriptionProps>,\n { ...((description as ReactElement<AlertDialogDescriptionProps>).props || {}), ...descriptionProps }\n )\n : <AlertDialogDescription {...descriptionProps}>{description}</AlertDialogDescription>\n }\n </AlertDialogHeader>\n )\n}\n\nconst RenderAlertDialogFooter: FC<PropsWithChildren<AlertDialogProps>> = (props) => {\n const {\n slotProps = {},\n children,\n onCancel,\n onConfirm,\n cancelLabel = 'Cancel',\n actionLabel = 'Continue',\n variant = 'confirm',\n } = props;\n const footerId = useId();\n\n const footerProps = slotProps.footer ?? {};\n const cancelButtonProps = slotProps.cancelButton ?? {};\n const actionButtonProps = slotProps.actionButton ?? {};\n\n if(children) {\n return isValidReactElement(children, AlertDialogFooter)\n ? cloneElement<AlertDialogFooterProps>(\n children as ReactElement<AlertDialogFooterProps>,\n { ...((children as ReactElement<AlertDialogFooterProps>).props || {}), ...footerProps }\n )\n : (\n <AlertDialogFooter {...footerProps}>\n {Children.map(children, (child, i) => {\n if(!child || !isValidReactElement(child)) return;\n\n const reactChild = child as ReactElement;\n const clonedChild = cloneElement(reactChild, {...(reactChild.props || {}), key: (reactChild.key || `footer-${footerId}-action-${i}` as unknown as Key)});\n\n if(isValidReactElement(child, AlertDialogAction) || isValidReactElement(child, AlertDialogCancel)) {\n return clonedChild;\n }\n\n return (\n <AlertDialogAction asChild>\n {clonedChild}\n </AlertDialogAction>\n )\n })}\n </AlertDialogFooter>\n )\n }\n\n return (\n <AlertDialogFooter>\n {variant !== 'alert' && (\n <AlertDialogCancel\n variant='ghost'\n onClick={onCancel}\n {...cancelButtonProps}\n >\n {cancelLabel}\n </AlertDialogCancel>\n )}\n <AlertDialogAction\n onClick={onConfirm}\n {...actionButtonProps}\n variant={\n actionButtonProps.variant || variant === 'destructive' ? 'destructive' : 'default'\n }\n >\n {actionLabel}\n </AlertDialogAction>\n </AlertDialogFooter>\n )\n}\n\n/**\n * Component for show Alert Dialog.\n * @public\n * @see [Documentation](#)\n * @example\n * > Import:\n * ```tsx\n * import { AlertDialog } from '@oneplatformdev/ui/AlertDialog';\n * ```\n * > Simple example:\n * ```tsx\n * <AlertDialog\n * trigger={'Trigger text'} // may be any ReactNode | Button | string\n * variant='alert' // 'confirm' (default) | 'alert' | 'destructive'\n * title='Dialog title'\n * description='Description text...'\n * />\n * ```\n * > Base example:\n * ```tsx\n * <AlertDialog\n * trigger={<Button variant=\"outline\">Simple Trigger</Button>}\n * title='Dialog title'\n * description='Description text...'\n * onCancel={(event) => console.log(event, 'Cancel')}\n * onConfirm={(event) => console.log(event, 'Confirm')}\n * />\n * ```\n * > Trigger example: Button with icon children\n * ```tsx\n * <AlertDialog\n * trigger={<Button variant=\"outline\" size=\"icon\"><PencilLine /></Button>}\n * title=\"Dialog title with icon trigger\"\n * description=\"Description text...\"\n * onCancel={(event) => console.log(event, 'Cancel')}\n * onConfirm={(event) => console.log(event, 'Confirm')}\n * />\n * ```\n *\n * > Full content example:\n * ```tsx\n * <AlertDialog trigger={<Button variant=\"outline\">Full Content Trigger</Button>}>\n * Full Content...\n * </AlertDialog>\n * ```\n *\n * > Full control example:\n * ```tsx\n * <AlertDialog\n * open={true}\n * onOpenChange={(nextState) => console.log(nextState)}\n * trigger={<Button variant=\"outline\">Control Trigger</Button>}\n * header={<div>Custom Header</div>}\n * footer={[\n * <Button key='cancel' variant=\"outline\" onClick={() => {}}>On Action</Button>,\n * <Button key='action' variant=\"outline\" onClick={() => {}}>On Action</Button>,\n * ]}\n * />\n * ```\n */\nexport const AlertDialog: FC<PropsWithChildren<AlertDialogProps>> = (props) => {\n const {\n trigger,\n header,\n footer,\n slotProps = {},\n children,\n ...rest\n } = props;\n\n const contentProps = slotProps.content ?? {};\n\n return (\n <AlertDialogRoot {...rest}>\n <RenderAlertDialogTrigger {...props}>{trigger}</RenderAlertDialogTrigger>\n {children\n ? isValidReactElement(children, AlertDialogContent)\n ? cloneElement<AlertDialogContentProps>(\n children as ReactElement<AlertDialogContentProps>,\n {\n ...((children as ReactElement<AlertDialogContentProps>).props || {}),\n ...contentProps\n })\n : <AlertDialogContent {...contentProps}>{children}</AlertDialogContent>\n : (\n <AlertDialogContent {...contentProps}>\n <RenderAlertDialogHeader {...props}>{header}</RenderAlertDialogHeader>\n <RenderAlertDialogFooter {...props}>{footer}</RenderAlertDialogFooter>\n </AlertDialogContent>\n )\n }\n </AlertDialogRoot>\n )\n}\n\nexport default AlertDialog;\n"],"names":["RenderAlertDialogTrigger","props","slotProps","children","triggerProps","isValidReactElement","AlertDialogTrigger","cloneElement","jsx","RenderAlertDialogHeader","title","description","headerProps","titleProps","descriptionProps","AlertDialogHeader","AlertDialogTitle","AlertDialogDescription","RenderAlertDialogFooter","onCancel","onConfirm","cancelLabel","actionLabel","variant","footerId","useId","footerProps","cancelButtonProps","actionButtonProps","AlertDialogFooter","child","i","reactChild","clonedChild","AlertDialogAction","AlertDialogCancel","AlertDialog","trigger","header","footer","rest","contentProps","jsxs","AlertDialogRoot","AlertDialogContent"],"mappings":";;;;AAgCA,MAAMA,IAAoE,C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A,EAAkB,WAAWL,MAAY,gBAAgB,gBAAgB;AAAA,QAG1E,UAAAD;AAAA,MAAA;AAAA,IAAA;AAAA,EACH,GACF;AAEJ,GA8Dac,IAAuD,CAACnC,MAAU;AAC7E,QAAM;AAAA,IACJ,SAAAoC;AAAA,IACA,QAAAC;AAAA,IACA,QAAAC;AAAA,IACA,WAAArC,IAAY,CAAA;AAAA,IACZ,UAAAC;AAAA,IACA,GAAGqC;AAAA,EAAA,IACDvC,GAEEwC,IAAevC,EAAU,WAAW,CAAA;AAE1C,SACE,gBAAAwC,EAACC,GAAA,EAAiB,GAAGH,GACnB,UAAA;AAAA,IAAA,gBAAAhC,EAACR,GAAA,EAA0B,GAAGC,GAAQ,UAAAoC,EAAA,CAAQ;AAAA,IAC7ClC,IACGE,EAAoBF,GAAUyC,CAAkB,IAC9CrC;AAAA,MACAJ;AAAA,MACA;AAAA,QACE,GAAKA,EAAmD,SAAS,CAAA;AAAA,QACjE,GAAGsC;AAAA,MAAA;AAAA,IACL,IACA,gBAAAjC,EAACoC,GAAA,EAAoB,GAAGH,GAAe,UAAAtC,GAAS,IAElD,gBAAAuC,EAACE,GAAA,EAAoB,GAAGH,GACtB,UAAA;AAAA,MAAA,gBAAAjC,EAACC,GAAA,EAAyB,GAAGR,GAAQ,UAAAqC,EAAA,CAAO;AAAA,MAC5C,gBAAA9B,EAACU,GAAA,EAAyB,GAAGjB,GAAQ,UAAAsC,EAAA,CAAO;AAAA,IAAA,EAAA,CAC9C;AAAA,EAAA,GAGN;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"AlertDialog.js","sources":["../../src/AlertDialog/AlertDialog.tsx"],"sourcesContent":["import {\n Children,\n cloneElement,\n FC,\n Key,\n PropsWithChildren,\n ReactElement,\n useId,\n} from 'react';\nimport {\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogRoot,\n AlertDialogTitle,\n AlertDialogTrigger,\n} from './AlertDialogRoot';\nimport {\n AlertDialogContentProps,\n AlertDialogDescriptionProps,\n AlertDialogFooterProps,\n AlertDialogHeaderProps,\n AlertDialogProps,\n AlertDialogTitleProps,\n AlertDialogTriggerProps,\n} from './AlertDialog.types';\n\nimport { isValidReactElement } from '@oneplatformdev/utils';\n\nconst RenderAlertDialogTrigger: FC<PropsWithChildren<AlertDialogProps>> = (\n props\n) => {\n const { slotProps = {}, children } = props;\n\n const triggerProps = slotProps.trigger ?? {};\n\n if (isValidReactElement(children, AlertDialogTrigger)) {\n return cloneElement<AlertDialogTriggerProps>(\n children as ReactElement<AlertDialogTriggerProps>,\n {\n ...((children as ReactElement<AlertDialogTriggerProps>).props || {}),\n ...triggerProps,\n }\n );\n }\n\n return <AlertDialogTrigger asChild>{children}</AlertDialogTrigger>;\n};\n\nconst RenderAlertDialogHeader: FC<PropsWithChildren<AlertDialogProps>> = (props) => {\n const {\n title = '',\n description = '',\n slotProps = {},\n children,\n } = props;\n\n const headerProps = slotProps.header ?? {};\n const titleProps = slotProps.title ?? {};\n const descriptionProps = slotProps.description ?? {};\n\n if(children) {\n return isValidReactElement(children, AlertDialogHeader)\n ? cloneElement<AlertDialogHeaderProps>(\n children as ReactElement<AlertDialogHeaderProps>,\n { ...((children as ReactElement<AlertDialogHeaderProps>).props || {}), ...headerProps }\n )\n : <AlertDialogHeader {...headerProps}>{children}</AlertDialogHeader>\n }\n\n return (\n <AlertDialogHeader>\n {Boolean(title) && isValidReactElement(title, AlertDialogTitle)\n ? cloneElement<AlertDialogTitleProps>(\n title as ReactElement<AlertDialogTitleProps>,\n { ...((title as ReactElement<AlertDialogTitleProps>).props || {}), ...titleProps }\n )\n : <AlertDialogTitle {...titleProps}>{title}</AlertDialogTitle>}\n\n {Boolean(description) && isValidReactElement(description, AlertDialogDescription)\n ? cloneElement<AlertDialogDescriptionProps>(\n description as ReactElement<AlertDialogDescriptionProps>,\n { ...((description as ReactElement<AlertDialogDescriptionProps>).props || {}), ...descriptionProps }\n )\n : <AlertDialogDescription {...descriptionProps}>{description}</AlertDialogDescription>\n }\n </AlertDialogHeader>\n )\n}\n\nconst RenderAlertDialogFooter: FC<PropsWithChildren<AlertDialogProps>> = (props) => {\n const {\n slotProps = {},\n children,\n onCancel,\n onConfirm,\n cancelLabel = 'Cancel',\n actionLabel = 'Continue',\n variant = 'confirm',\n } = props;\n const footerId = useId();\n\n const footerProps = slotProps.footer ?? {};\n const cancelButtonProps = slotProps.cancelButton ?? {};\n const actionButtonProps = slotProps.actionButton ?? {};\n\n if(children) {\n return isValidReactElement(children, AlertDialogFooter)\n ? cloneElement<AlertDialogFooterProps>(\n children as ReactElement<AlertDialogFooterProps>,\n { ...((children as ReactElement<AlertDialogFooterProps>).props || {}), ...footerProps }\n )\n : (\n <AlertDialogFooter {...footerProps}>\n {Children.map(children, (child, i) => {\n if(!child || !isValidReactElement(child)) return;\n\n const reactChild = child as ReactElement;\n const clonedChild = cloneElement(reactChild, {...(reactChild.props || {}), key: (reactChild.key || `footer-${footerId}-action-${i}` as unknown as Key)});\n\n if(isValidReactElement(child, AlertDialogAction) || isValidReactElement(child, AlertDialogCancel)) {\n return clonedChild;\n }\n\n return (\n <AlertDialogAction asChild>\n {clonedChild}\n </AlertDialogAction>\n )\n })}\n </AlertDialogFooter>\n )\n }\n\n return (\n <AlertDialogFooter>\n {variant !== 'alert' && (\n <AlertDialogCancel\n onClick={onCancel}\n {...cancelButtonProps}\n >\n {cancelLabel}\n </AlertDialogCancel>\n )}\n <AlertDialogAction\n onClick={onConfirm}\n {...actionButtonProps}\n variant={\n actionButtonProps.variant || variant === 'destructive' ? 'destructive' : 'default'\n }\n >\n {actionLabel}\n </AlertDialogAction>\n </AlertDialogFooter>\n )\n}\n\n/**\n * Component for show Alert Dialog.\n * @public\n * @see [Documentation](#)\n * @example\n * > Import:\n * ```tsx\n * import { AlertDialog } from '@oneplatformdev/ui/AlertDialog';\n * ```\n * > Simple example:\n * ```tsx\n * <AlertDialog\n * trigger={'Trigger text'} // may be any ReactNode | Button | string\n * variant='alert' // 'confirm' (default) | 'alert' | 'destructive'\n * title='Dialog title'\n * description='Description text...'\n * />\n * ```\n * > Base example:\n * ```tsx\n * <AlertDialog\n * trigger={<Button variant=\"outline\">Simple Trigger</Button>}\n * title='Dialog title'\n * description='Description text...'\n * onCancel={(event) => console.log(event, 'Cancel')}\n * onConfirm={(event) => console.log(event, 'Confirm')}\n * />\n * ```\n * > Trigger example: Button with icon children\n * ```tsx\n * <AlertDialog\n * trigger={<Button variant=\"outline\" size=\"icon\"><PencilLine /></Button>}\n * title=\"Dialog title with icon trigger\"\n * description=\"Description text...\"\n * onCancel={(event) => console.log(event, 'Cancel')}\n * onConfirm={(event) => console.log(event, 'Confirm')}\n * />\n * ```\n *\n * > Full content example:\n * ```tsx\n * <AlertDialog trigger={<Button variant=\"outline\">Full Content Trigger</Button>}>\n * Full Content...\n * </AlertDialog>\n * ```\n *\n * > Full control example:\n * ```tsx\n * <AlertDialog\n * open={true}\n * onOpenChange={(nextState) => console.log(nextState)}\n * trigger={<Button variant=\"outline\">Control Trigger</Button>}\n * header={<div>Custom Header</div>}\n * footer={[\n * <Button key='cancel' variant=\"outline\" onClick={() => {}}>On Action</Button>,\n * <Button key='action' variant=\"outline\" onClick={() => {}}>On Action</Button>,\n * ]}\n * />\n * ```\n */\nexport const AlertDialog: FC<PropsWithChildren<AlertDialogProps>> = (props) => {\n const {\n trigger,\n header,\n footer,\n slotProps = {},\n children,\n ...rest\n } = props;\n\n const contentProps = slotProps.content ?? {};\n\n return (\n <AlertDialogRoot {...rest}>\n <RenderAlertDialogTrigger {...props}>{trigger}</RenderAlertDialogTrigger>\n {children\n ? isValidReactElement(children, AlertDialogContent)\n ? cloneElement<AlertDialogContentProps>(\n children as ReactElement<AlertDialogContentProps>,\n {\n ...((children as ReactElement<AlertDialogContentProps>).props || {}),\n ...contentProps\n })\n : <AlertDialogContent {...contentProps}>{children}</AlertDialogContent>\n : (\n <AlertDialogContent {...contentProps}>\n <RenderAlertDialogHeader {...props}>{header}</RenderAlertDialogHeader>\n <RenderAlertDialogFooter {...props}>{footer}</RenderAlertDialogFooter>\n </AlertDialogContent>\n )\n }\n </AlertDialogRoot>\n )\n}\n\nexport default AlertDialog;\n"],"names":["RenderAlertDialogTrigger","props","slotProps","children","triggerProps","isValidReactElement","AlertDialogTrigger","cloneElement","jsx","RenderAlertDialogHeader","title","description","headerProps","titleProps","descriptionProps","AlertDialogHeader","AlertDialogTitle","AlertDialogDescription","RenderAlertDialogFooter","onCancel","onConfirm","cancelLabel","actionLabel","variant","footerId","useId","footerProps","cancelButtonProps","actionButtonProps","AlertDialogFooter","child","i","reactChild","clonedChild","AlertDialogAction","AlertDialogCancel","AlertDialog","trigger","header","footer","rest","contentProps","jsxs","AlertDialogRoot","AlertDialogContent"],"mappings":";;;;AAgCA,MAAMA,IAAoE,CACxEC,MACG;AACH,QAAM,EAAE,WAAAC,IAAY,IAAI,UAAAC,MAAaF,GAE/BG,IAAeF,EAAU,WAAW,CAAA;AAE1C,SAAIG,EAAoBF,GAAUG,CAAkB,IAC3CC;AAAA,IACLJ;AAAA,IACA;AAAA,MACE,GAAKA,EAAmD,SAAS,CAAA;AAAA,MACjE,GAAGC;AAAA,IAAA;AAAA,EACL,IAIG,gBAAAI,EAACF,GAAA,EAAmB,SAAO,IAAE,UAAAH,EAAA,CAAS;AAC/C,GAEMM,IAAmE,CAACR,MAAU;AAClF,QAAM;AAAA,IACJ,OAAAS,IAAQ;AAAA,IACR,aAAAC,IAAc;AAAA,IACd,WAAAT,IAAY,CAAA;AAAA,IACZ,UAAAC;AAAA,EAAA,IACEF,GAEEW,IAAcV,EAAU,UAAU,CAAA,GAClCW,IAAaX,EAAU,SAAS,CAAA,GAChCY,IAAmBZ,EAAU,eAAe,CAAA;AAElD,SAAGC,IACME,EAAoBF,GAAUY,CAAiB,IAClDR;AAAA,IACAJ;AAAA,IACA,EAAE,GAAKA,EAAkD,SAAS,CAAA,GAAK,GAAGS,EAAA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,EAAoB,GAAGH,GACtB,UAAA;AAAA,MAAA,gBAAAjC,EAACC,GAAA,EAAyB,GAAGR,GAAQ,UAAAqC,EAAA,CAAO;AAAA,MAC5C,gBAAA9B,EAACU,GAAA,EAAyB,GAAGjB,GAAQ,UAAAsC,EAAA,CAAO;AAAA,IAAA,EAAA,CAC9C;AAAA,EAAA,GAGN;AAEJ;"}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 0.1.10-80 (2025-11-09)
|
|
2
|
+
|
|
3
|
+
### 🧱 Updated Dependencies
|
|
4
|
+
|
|
5
|
+
- Updated @oneplatformdev/utils to 0.1.1-129
|
|
6
|
+
- Updated @oneplatformdev/hooks to 0.1.0-115
|
|
7
|
+
- Updated @oneplatformdev/tokens to 0.0.1-102
|
|
8
|
+
|
|
1
9
|
## 0.1.10-79 (2025-11-06)
|
|
2
10
|
|
|
3
11
|
### 🧱 Updated Dependencies
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oneplatformdev/ui",
|
|
3
|
-
"version": "0.1.10-
|
|
3
|
+
"version": "0.1.10-80",
|
|
4
4
|
"description": "UI component library for OnePlatform",
|
|
5
5
|
"author": "One Platform Development Team",
|
|
6
6
|
"keywords": [
|
|
@@ -105,8 +105,8 @@
|
|
|
105
105
|
"recharts": "^3.2.0",
|
|
106
106
|
"sonner": "^2.0.7",
|
|
107
107
|
"vaul": "^1.1.2",
|
|
108
|
-
"@oneplatformdev/tokens": "^0.0.1-
|
|
109
|
-
"@oneplatformdev/hooks": "^0.1.0-
|
|
110
|
-
"@oneplatformdev/utils": "^0.1.1-
|
|
108
|
+
"@oneplatformdev/tokens": "^0.0.1-102",
|
|
109
|
+
"@oneplatformdev/hooks": "^0.1.0-115",
|
|
110
|
+
"@oneplatformdev/utils": "^0.1.1-129"
|
|
111
111
|
}
|
|
112
112
|
}
|