@namroodinc/liquid-editorial 0.6.7 → 0.6.9
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 +108 -2
- package/UPGRADING.md +88 -0
- package/dist/chunks/CollectionView-BIuOL917.cjs +2 -0
- package/dist/chunks/CollectionView-BIuOL917.cjs.map +1 -0
- package/dist/chunks/CollectionView-Cr12UFWa.js +179 -0
- package/dist/chunks/CollectionView-Cr12UFWa.js.map +1 -0
- package/dist/chunks/{EntryPicker-CR8Phuzl.js → EntryPicker-B88N69zH.js} +2 -2
- package/dist/chunks/{EntryPicker-CR8Phuzl.js.map → EntryPicker-B88N69zH.js.map} +1 -1
- package/dist/chunks/{EntryPicker-D7JIgx23.cjs → EntryPicker-daSkD4aR.cjs} +2 -2
- package/dist/chunks/{EntryPicker-D7JIgx23.cjs.map → EntryPicker-daSkD4aR.cjs.map} +1 -1
- package/dist/chunks/{FormEditor-DNcSAnRF.cjs → FormEditor-B4mtAxaU.cjs} +2 -2
- package/dist/chunks/FormEditor-B4mtAxaU.cjs.map +1 -0
- package/dist/chunks/{FormEditor-BSfxVqLn.js → FormEditor-BkBhcYI5.js} +3 -2
- package/dist/chunks/FormEditor-BkBhcYI5.js.map +1 -0
- package/dist/chunks/LoadState-B7GTDlWv.js +71 -0
- package/dist/chunks/LoadState-B7GTDlWv.js.map +1 -0
- package/dist/chunks/LoadState-C7tQ6fIP.cjs +2 -0
- package/dist/chunks/LoadState-C7tQ6fIP.cjs.map +1 -0
- package/dist/chunks/Wizard-B_CPW1V6.cjs +2 -0
- package/dist/chunks/Wizard-B_CPW1V6.cjs.map +1 -0
- package/dist/chunks/Wizard-C1iR5z44.js +99 -0
- package/dist/chunks/Wizard-C1iR5z44.js.map +1 -0
- package/dist/chunks/frame-C8TwdWBC.cjs +2 -0
- package/dist/chunks/frame-C8TwdWBC.cjs.map +1 -0
- package/dist/chunks/frame-DaC03_n-.js +203 -0
- package/dist/chunks/frame-DaC03_n-.js.map +1 -0
- package/dist/chunks/{group-Ckz4Xya-.js → group-C6EOgTgM.js} +2 -2
- package/dist/chunks/{group-Ckz4Xya-.js.map → group-C6EOgTgM.js.map} +1 -1
- package/dist/chunks/{group-Bj9ZKc0R.cjs → group-QSnlx4jX.cjs} +2 -2
- package/dist/chunks/{group-Bj9ZKc0R.cjs.map → group-QSnlx4jX.cjs.map} +1 -1
- package/dist/components/Choice/index.cjs +1 -1
- package/dist/components/Choice/index.js +1 -1
- package/dist/components/CollectionView/empty.d.cts +15 -0
- package/dist/components/CollectionView/empty.d.cts.map +1 -0
- package/dist/components/CollectionView/empty.d.ts +15 -0
- package/dist/components/CollectionView/empty.d.ts.map +1 -0
- package/dist/components/CollectionView/filters.d.cts +6 -0
- package/dist/components/CollectionView/filters.d.cts.map +1 -0
- package/dist/components/CollectionView/filters.d.ts +6 -0
- package/dist/components/CollectionView/filters.d.ts.map +1 -0
- package/dist/components/CollectionView/index.cjs +1 -0
- package/dist/components/CollectionView/index.d.cts +6 -0
- package/dist/components/CollectionView/index.d.cts.map +1 -0
- package/dist/components/CollectionView/index.d.ts +6 -0
- package/dist/components/CollectionView/index.d.ts.map +1 -0
- package/dist/components/CollectionView/index.js +2 -0
- package/dist/components/CollectionView/style.css +70 -0
- package/dist/components/CollectionView/toolbar.d.cts +5 -0
- package/dist/components/CollectionView/toolbar.d.cts.map +1 -0
- package/dist/components/CollectionView/toolbar.d.ts +5 -0
- package/dist/components/CollectionView/toolbar.d.ts.map +1 -0
- package/dist/components/CollectionView/types.d.cts +40 -0
- package/dist/components/CollectionView/types.d.cts.map +1 -0
- package/dist/components/CollectionView/types.d.ts +40 -0
- package/dist/components/CollectionView/types.d.ts.map +1 -0
- package/dist/components/EditLayout/style.css +1 -1
- package/dist/components/EditSection/index.cjs +2 -0
- package/dist/components/EditSection/index.cjs.map +1 -0
- package/dist/components/EditSection/index.d.cts +9 -0
- package/dist/components/EditSection/index.d.cts.map +1 -0
- package/dist/components/EditSection/index.d.ts +9 -0
- package/dist/components/EditSection/index.d.ts.map +1 -0
- package/dist/components/EditSection/index.js +22 -0
- package/dist/components/EditSection/index.js.map +1 -0
- package/dist/components/EditSection/style.css +31 -0
- package/dist/components/EntryPicker/index.cjs +1 -1
- package/dist/components/EntryPicker/index.js +1 -1
- package/dist/components/Field/frame.d.cts +1 -1
- package/dist/components/Field/frame.d.cts.map +1 -1
- package/dist/components/Field/frame.d.ts +1 -1
- package/dist/components/Field/frame.d.ts.map +1 -1
- package/dist/components/Field/header.d.cts +5 -3
- package/dist/components/Field/header.d.cts.map +1 -1
- package/dist/components/Field/header.d.ts +5 -3
- package/dist/components/Field/header.d.ts.map +1 -1
- package/dist/components/Field/index.cjs +1 -1
- package/dist/components/Field/index.js +1 -1
- package/dist/components/Field/style.css +18 -0
- package/dist/components/Field/types.d.cts +2 -0
- package/dist/components/Field/types.d.cts.map +1 -1
- package/dist/components/Field/types.d.ts +2 -0
- package/dist/components/Field/types.d.ts.map +1 -1
- package/dist/components/FormEditor/README.md +25 -0
- package/dist/components/FormEditor/index.cjs +1 -1
- package/dist/components/FormEditor/index.d.cts.map +1 -1
- package/dist/components/FormEditor/index.d.ts.map +1 -1
- package/dist/components/FormEditor/index.js +1 -1
- package/dist/components/FormEditor/model.d.cts +1 -0
- package/dist/components/FormEditor/model.d.cts.map +1 -1
- package/dist/components/FormEditor/model.d.ts +1 -0
- package/dist/components/FormEditor/model.d.ts.map +1 -1
- package/dist/components/LoadState/error.d.cts +13 -0
- package/dist/components/LoadState/error.d.cts.map +1 -0
- package/dist/components/LoadState/error.d.ts +13 -0
- package/dist/components/LoadState/error.d.ts.map +1 -0
- package/dist/components/LoadState/index.cjs +1 -0
- package/dist/components/LoadState/index.d.cts +15 -0
- package/dist/components/LoadState/index.d.cts.map +1 -0
- package/dist/components/LoadState/index.d.ts +15 -0
- package/dist/components/LoadState/index.d.ts.map +1 -0
- package/dist/components/LoadState/index.js +1 -0
- package/dist/components/LoadState/types.d.cts +3 -0
- package/dist/components/LoadState/types.d.cts.map +1 -0
- package/dist/components/LoadState/types.d.ts +3 -0
- package/dist/components/LoadState/types.d.ts.map +1 -0
- package/dist/components/LoadState/useRetryAttempt.d.cts +15 -0
- package/dist/components/LoadState/useRetryAttempt.d.cts.map +1 -0
- package/dist/components/LoadState/useRetryAttempt.d.ts +15 -0
- package/dist/components/LoadState/useRetryAttempt.d.ts.map +1 -0
- package/dist/components/MetaList/index.cjs +2 -0
- package/dist/components/MetaList/index.cjs.map +1 -0
- package/dist/components/MetaList/index.d.cts +7 -0
- package/dist/components/MetaList/index.d.cts.map +1 -0
- package/dist/components/MetaList/index.d.ts +7 -0
- package/dist/components/MetaList/index.d.ts.map +1 -0
- package/dist/components/MetaList/index.js +13 -0
- package/dist/components/MetaList/index.js.map +1 -0
- package/dist/components/MetaList/style.css +19 -0
- package/dist/components/PageHeader/index.cjs +2 -0
- package/dist/components/PageHeader/index.cjs.map +1 -0
- package/dist/components/PageHeader/index.d.cts +9 -0
- package/dist/components/PageHeader/index.d.cts.map +1 -0
- package/dist/components/PageHeader/index.d.ts +9 -0
- package/dist/components/PageHeader/index.d.ts.map +1 -0
- package/dist/components/PageHeader/index.js +27 -0
- package/dist/components/PageHeader/index.js.map +1 -0
- package/dist/components/PageHeader/style.css +39 -0
- package/dist/components/SelectionCard/index.cjs +1 -1
- package/dist/components/SelectionCard/index.js +1 -1
- package/dist/components/Stepper/index.cjs +1 -1
- package/dist/components/Stepper/index.cjs.map +1 -1
- package/dist/components/Stepper/index.d.cts +8 -0
- package/dist/components/Stepper/index.d.cts.map +1 -1
- package/dist/components/Stepper/index.d.ts +8 -0
- package/dist/components/Stepper/index.d.ts.map +1 -1
- package/dist/components/Stepper/index.js +15 -14
- package/dist/components/Stepper/index.js.map +1 -1
- package/dist/components/Stepper/style.css +53 -0
- package/dist/components/Wizard/actions.d.cts +13 -0
- package/dist/components/Wizard/actions.d.cts.map +1 -0
- package/dist/components/Wizard/actions.d.ts +13 -0
- package/dist/components/Wizard/actions.d.ts.map +1 -0
- package/dist/components/Wizard/index.cjs +1 -0
- package/dist/components/Wizard/index.d.cts +7 -0
- package/dist/components/Wizard/index.d.cts.map +1 -0
- package/dist/components/Wizard/index.d.ts +7 -0
- package/dist/components/Wizard/index.d.ts.map +1 -0
- package/dist/components/Wizard/index.js +2 -0
- package/dist/components/Wizard/review-table.d.cts +13 -0
- package/dist/components/Wizard/review-table.d.cts.map +1 -0
- package/dist/components/Wizard/review-table.d.ts +13 -0
- package/dist/components/Wizard/review-table.d.ts.map +1 -0
- package/dist/components/Wizard/style.css +13 -0
- package/dist/components/Wizard/types.d.cts +35 -0
- package/dist/components/Wizard/types.d.cts.map +1 -0
- package/dist/components/Wizard/types.d.ts +35 -0
- package/dist/components/Wizard/types.d.ts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +13 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -30
- package/dist/styles.css +5 -0
- package/package.json +1 -1
- package/dist/chunks/FormEditor-BSfxVqLn.js.map +0 -1
- package/dist/chunks/FormEditor-DNcSAnRF.cjs.map +0 -1
- package/dist/chunks/frame-BBVQTBcX.cjs +0 -2
- package/dist/chunks/frame-BBVQTBcX.cjs.map +0 -1
- package/dist/chunks/frame-De6IuTQz.js +0 -189
- package/dist/chunks/frame-De6IuTQz.js.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../components/Button/index.cjs"),t=require("../components/Banner/index.cjs"),n=require("../components/Skeleton/index.cjs");let r=require("react"),i=require("react/jsx-runtime");var a={pending:`Trying again…`,failed:`Still couldn't load this.`};function o({error:n,onRetry:r,retryState:o}){return(0,i.jsxs)(t.Banner,{tone:`danger`,role:`note`,icon:`auto`,title:`Couldn't load this`,actions:r&&(0,i.jsx)(e.Button,{size:`sm`,isPending:o===`pending`,isFocusableWhenDisabled:!0,onClick:r,children:`Try again`}),children:[n?.message,` `,(0,i.jsx)(`span`,{role:`status`,children:o&&a[o]})]})}var s=1e3;function c(e,t,n){let[i,a]=(0,r.useState)(null),[o,c]=(0,r.useState)(e);e!==o&&(c(e),i?.phase===`pending`&&e===`error`?a({phase:`failed`}):(i?.phase!==`pending`||e!==`loading`)&&a(null));let l=i?.phase===`pending`&&e!==`loading`;(0,r.useEffect)(()=>{if(!l)return;let e=setTimeout(()=>a(e=>e===i?null:e),s);return()=>clearTimeout(e)},[i,l]);let u=i?.phase===`pending`&&e===`loading`?`pending`:i?.phase===`failed`&&e===`error`?`failed`:void 0;return{state:u,error:u===`pending`?i?.error:t,retry:n&&(()=>{a({phase:`pending`,error:t}),n()})}}function l({status:e,error:t,onRetry:r,children:a}){let s=c(e,t,r);return e===`error`||s.state===`pending`?(0,i.jsx)(o,{error:s.error,onRetry:s.retry,retryState:s.state}):e===`loading`?(0,i.jsx)(n.SkeletonText,{lines:4}):(0,i.jsx)(i.Fragment,{children:a})}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return l}});
|
|
2
|
+
//# sourceMappingURL=LoadState-C7tQ6fIP.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoadState-C7tQ6fIP.cjs","names":["Banner","Button","useState","SkeletonText","_Fragment","require_components_Button_index","require_components_Banner_index","require_components_Skeleton_index","react","react_jsx_runtime","retryNotes","LoadError","onRetry","retryState","error","RETRY_START_WINDOW_MS","useRetryAttempt","attempt","setAttempt","seenStatus","setSeenStatus","status","awaitsLoad","timer","current","state","LoadState","retry"],"sources":["../../src/components/LoadState/error.tsx","../../src/components/LoadState/useRetryAttempt.ts","../../src/components/LoadState/index.tsx"],"sourcesContent":["import { Banner } from \"../Banner\";\nimport { Button } from \"../Button\";\n\nimport type { RetryState } from \"./types\";\n\nconst retryNotes: Record<RetryState, string> = {\n pending: \"Trying again…\",\n failed: \"Still couldn't load this.\",\n};\n\n/**\n * Persistent load feedback; the owning view controls when it is shown. A first\n * failure stays quiet, while a retry's progress and repeated failure are announced.\n */\nexport interface LoadErrorProps {\n error?: Error | null;\n onRetry?: () => void;\n /** Set while the owner keeps this banner mounted through a retry, so Retry keeps focus. */\n retryState?: RetryState;\n}\n\nexport function LoadError({ error, onRetry, retryState }: LoadErrorProps) {\n return (\n <Banner\n tone=\"danger\"\n role=\"note\"\n icon=\"auto\"\n title=\"Couldn't load this\"\n actions={\n onRetry && (\n <Button\n size=\"sm\"\n isPending={retryState === \"pending\"}\n isFocusableWhenDisabled\n onClick={onRetry}\n >\n Try again\n </Button>\n )\n }\n >\n {error?.message} <span role=\"status\">{retryState && retryNotes[retryState]}</span>\n </Banner>\n );\n}\n","import { useEffect, useState } from \"react\";\nimport type { RetryState } from \"./types\";\nimport type { LoadStatus } from \"./types\";\n\n/**\n * How long a retry waits for its load to be reported. Loads usually start in\n * the retry handler or within a few ticks of it, such as a query library's\n * batched notification. A later load is unrelated.\n */\nconst RETRY_START_WINDOW_MS = 1000;\n\ninterface Attempt {\n phase: RetryState;\n /** The failure being retried, kept on screen while the retry loads. */\n error?: Error | null;\n}\n\n/**\n * A retry started from failure feedback. The owner keeps that feedback mounted\n * while the retry loads, so Retry keeps focus, and reports a repeated failure.\n * Success, or any load the retry didn't start, clears it. A retry that reports\n * no load within RETRY_START_WINDOW_MS, for example because the owner keeps\n * `error` while refetching, lapses, so a later unrelated load shows a skeleton.\n */\nexport function useRetryAttempt(\n status: LoadStatus,\n error: Error | null | undefined,\n onRetry?: () => void,\n) {\n const [attempt, setAttempt] = useState<Attempt | null>(null);\n const [seenStatus, setSeenStatus] = useState(status);\n if (status !== seenStatus) {\n setSeenStatus(status);\n if (attempt?.phase === \"pending\" && status === \"error\") {\n setAttempt({ phase: \"failed\" });\n } else if (attempt?.phase !== \"pending\" || status !== \"loading\") {\n setAttempt(null);\n }\n }\n const awaitsLoad = attempt?.phase === \"pending\" && status !== \"loading\";\n useEffect(() => {\n if (!awaitsLoad) {\n return;\n }\n const timer = setTimeout(\n () => setAttempt((current) => (current === attempt ? null : current)),\n RETRY_START_WINDOW_MS,\n );\n return () => clearTimeout(timer);\n }, [attempt, awaitsLoad]);\n const state: RetryState | undefined =\n attempt?.phase === \"pending\" && status === \"loading\"\n ? \"pending\"\n : attempt?.phase === \"failed\" && status === \"error\"\n ? \"failed\"\n : undefined;\n return {\n state,\n error: state === \"pending\" ? attempt?.error : error,\n retry:\n onRetry &&\n (() => {\n setAttempt({\n phase: \"pending\",\n error,\n });\n onRetry();\n }),\n };\n}\n","import { SkeletonText } from \"../Skeleton\";\nimport { LoadError } from \"./error\";\nimport { useRetryAttempt } from \"./useRetryAttempt\";\nimport type { LoadStatus } from \"./types\";\nimport type { ReactNode } from \"react\";\n\nexport interface LoadStateProps {\n status: LoadStatus;\n error?: Error | null;\n onRetry?: () => void;\n /** Rendered once loaded. */\n children?: ReactNode;\n}\n\n/** The loading and failed states every API-backed view shares; children render once ready. */\nexport function LoadState({ status, error, onRetry, children }: LoadStateProps) {\n const retry = useRetryAttempt(status, error, onRetry);\n // One LoadError instance spans a retry, so focus stays on its Retry button.\n if (status === \"error\" || retry.state === \"pending\") {\n return (\n <LoadError\n error={retry.error}\n onRetry={retry.retry}\n retryState={retry.state}\n />\n );\n }\n if (status === \"loading\") {\n return <SkeletonText lines={4} />;\n }\n return <>{children}</>;\n}\n\nexport { LoadError } from \"./error\";\nexport type { LoadErrorProps } from \"./error\";\nexport type { LoadStatus, RetryState } from \"./types\";\n"],"mappings":"A,kMAKA,IAAMU,EAAyC,CAC7C,QAAS,gBACT,OAAQ,2BACV,EAaA,SAAgBC,EAAU,CAAE,QAAO,UAAS,cAA8B,CACxE,OACE,EAAAF,EAAA,KAAA,CAACT,EAAAA,OAAD,CACE,KAAK,SACL,KAAK,OACL,KAAK,OACL,MAAM,qBACN,QACEY,IACE,EAAAH,EAAA,IAAA,CAACR,EAAAA,OAAD,CACE,KAAK,KACL,UAAWY,IAAe,UAC1B,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AYA,EAAM,KACnB,CAAA,EAGDN,IAAW,WACN,EAAAZ,EAAA,IAAA,CAACN,EAAAA,aAAD,CAAc,MAAO,CAAI,CAAA,GAE3B,EAAAM,EAAA,IAAA,CAAAL,EAAAA,SAAA,CAAG,UAAW,CAAA,CACvB,C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../components/Button/index.cjs"),t=require("../components/Modal/index.cjs"),n=require("../components/Table/index.cjs"),r=require("../components/Stepper/index.cjs");let i=require("react"),a=require("react/jsx-runtime");var o=e=>t=>{t.detail<=1&&e()};function s({step:t,isFirst:n,isLast:r,isPending:i,submitLabel:s,onBack:c,onAdvance:l}){return(0,a.jsxs)(a.Fragment,{children:[!t.hideSecondary&&(0,a.jsx)(e.Button,{isDisabled:i,isFocusableWhenDisabled:!0,onClick:o(c),children:n?`Cancel`:`Back`}),(0,a.jsx)(e.Button,{variant:`primary`,isDisabled:i||t.canContinue===!1&&!t.onInvalid,isPending:i,isFocusableWhenDisabled:!0,onClick:o(l),children:t.primaryAction?.label??(r?s:`Next`)})]})}function c({rows:t,onStepChange:r,isDisabled:i=!1}){return(0,a.jsx)(n.TableFrame,{children:(0,a.jsxs)(n.Table,{children:[(0,a.jsx)(n.TableHead,{children:(0,a.jsxs)(n.TableRow,{children:[(0,a.jsx)(n.TableHeaderCell,{children:`Setting`}),(0,a.jsx)(n.TableHeaderCell,{children:`Value`}),(0,a.jsx)(n.TableHeaderCell,{width:`control`,align:`end`,"aria-label":`Actions`})]})}),(0,a.jsx)(n.TableBody,{children:t.map((t,o)=>(0,a.jsxs)(n.TableRow,{children:[(0,a.jsx)(n.TableCell,{emphasis:`primary`,children:t.term}),(0,a.jsx)(n.TableCell,{children:t.value}),(0,a.jsx)(n.TableCell,{width:`control`,align:`end`,children:(0,a.jsx)(e.Button,{isDisabled:i,size:`sm`,variant:`simple`,"aria-label":`Edit ${t.term}`,onClick:()=>r(t.step),children:`Edit`})})]},o))})]})})}function l({isOpen:e,modalComponent:n=t.Modal,title:o,description:c,steps:l,activeStep:u=0,onStepChange:d=()=>{},submitLabel:f,onSubmit:p,isPending:m=!1,isNavigable:h=!0,onClose:g}){let _=Math.min(Math.max(u,0),l.length-1),v=l[_],y=_===0,b=_===l.length-1,x=()=>{m||g()};return(0,a.jsx)(n,{isOpen:e,size:`md`,title:v?.title??o,description:v?.modalDescription??c,onClose:x,footer:v&&(0,a.jsx)(s,{step:v,isFirst:y,isLast:b,isPending:m,submitLabel:f,onBack:y?x:()=>d(_-1),onAdvance:()=>{!m&&v&&(v.canContinue===!1?v.onInvalid?.():v.primaryAction?v.primaryAction.onClick():b?p():d(_+1))}}),children:(0,a.jsxs)(`div`,{className:`ds-wizard__content`,children:[l.length>1&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.Stepper,{size:`md`,orientation:`auto`,activeStep:_,steps:l.map(({id:e,label:t,description:n})=>({id:e,label:t,description:n})),onStepChange:h&&!m?d:void 0}),(0,a.jsx)(`hr`,{className:`ds-wizard__rule`})]}),v&&(0,a.jsx)(i.Fragment,{children:v.content},v.id)]})})}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return l}});
|
|
2
|
+
//# sourceMappingURL=Wizard-B_CPW1V6.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Wizard-B_CPW1V6.cjs","names":["_Fragment","Button","TableFrame","Table","TableHead","TableRow","TableHeaderCell","TableBody","TableCell","Button","Modal","_Fragment","Stepper","Fragment","require_components_Button_index","require_components_Modal_index","require_components_Table_index","require_components_Stepper_index","react","react_jsx_runtime","singleClick","event","action","WizardActions","step","isPending","onBack","isFirst","onAdvance","isLast","submitLabel","ReviewTable","rows","row","onStepChange","index","Wizard","ModalComponent","activeStep","steps","close","onClose","title","description","onSubmit","isNavigable"],"sources":["../../src/components/Wizard/actions.tsx","../../src/components/Wizard/review-table.tsx","../../src/components/Wizard/index.tsx"],"sourcesContent":["import type { MouseEvent } from \"react\";\nimport { Button } from \"../Button\";\nimport type { WizardStep } from \"./types\";\n\n// A footer changes meaning between steps. Ignore the second click of a double-click.\n// Blocked footer buttons stay focusable: the pressed Next/Finish button is the\n// same element on the following step, so native disabling would drop its focus.\nconst singleClick = (action: () => void) => (event: MouseEvent<HTMLButtonElement>) => {\n if (event.detail <= 1) {\n action();\n }\n};\n\ninterface WizardActionsProps {\n step: WizardStep;\n isFirst: boolean;\n isLast: boolean;\n isPending: boolean;\n submitLabel: string;\n onBack: () => void;\n onAdvance: () => void;\n}\n\nexport function WizardActions({\n step,\n isFirst,\n isLast,\n isPending,\n submitLabel,\n onBack,\n onAdvance,\n}: WizardActionsProps) {\n return (\n <>\n {!step.hideSecondary && (\n <Button\n isDisabled={isPending}\n isFocusableWhenDisabled\n onClick={singleClick(onBack)}\n >\n {isFirst ? \"Cancel\" : \"Back\"}\n </Button>\n )}\n <Button\n variant=\"primary\"\n isDisabled={isPending || (step.canContinue === false && !step.onInvalid)}\n isPending={isPending}\n isFocusableWhenDisabled\n onClick={singleClick(onAdvance)}\n >\n {step.primaryAction?.label ?? (isLast ? submitLabel : \"Next\")}\n </Button>\n </>\n );\n}\n","import { Button } from \"../Button\";\nimport {\n Table,\n TableBody,\n TableCell,\n TableFrame,\n TableHead,\n TableHeaderCell,\n TableRow,\n} from \"../Table\";\nimport type { ReactNode } from \"react\";\n\nexport interface ReviewRow {\n term: string;\n value: ReactNode;\n step: number;\n}\n\nexport interface ReviewTableProps {\n rows: ReviewRow[];\n isDisabled?: boolean;\n onStepChange: (index: number) => void;\n}\n\nexport function ReviewTable({ rows, onStepChange, isDisabled = false }: ReviewTableProps) {\n return (\n <TableFrame>\n <Table>\n <TableHead>\n <TableRow>\n <TableHeaderCell>Setting</TableHeaderCell>\n <TableHeaderCell>Value</TableHeaderCell>\n <TableHeaderCell\n width=\"control\"\n align=\"end\"\n aria-label=\"Actions\"\n />\n </TableRow>\n </TableHead>\n <TableBody>\n {/* Terms may repeat, and rows hold no state of their own, so position is the key. */}\n {rows.map((row, index) => (\n <TableRow key={index}>\n <TableCell emphasis=\"primary\">{row.term}</TableCell>\n <TableCell>{row.value}</TableCell>\n <TableCell\n width=\"control\"\n align=\"end\"\n >\n <Button\n isDisabled={isDisabled}\n size=\"sm\"\n variant=\"simple\"\n aria-label={`Edit ${row.term}`}\n onClick={() => onStepChange(row.step)}\n >\n Edit\n </Button>\n </TableCell>\n </TableRow>\n ))}\n </TableBody>\n </Table>\n </TableFrame>\n );\n}\n","import { Fragment } from \"react\";\nimport { Modal } from \"../Modal\";\nimport { Stepper } from \"../Stepper\";\nimport { WizardActions } from \"./actions\";\nimport type { WizardProps, WizardStep } from \"./types\";\nimport \"./style.css\";\n\nexport type { WizardProps, WizardStep } from \"./types\";\nexport { ReviewTable } from \"./review-table\";\nexport type { ReviewTableProps, ReviewRow } from \"./review-table\";\n\n/** Controlled layout and navigation; applications own values, validation and actions. */\nexport function Wizard({\n isOpen,\n modalComponent: ModalComponent = Modal,\n title,\n description,\n steps,\n activeStep = 0,\n onStepChange = () => {},\n submitLabel,\n onSubmit,\n isPending = false,\n isNavigable = true,\n onClose,\n}: WizardProps) {\n // An index past the end, such as after a conditional step is removed, shows\n // the last step. Without steps, such as while they load, only the frame shows.\n const index = Math.min(Math.max(activeStep, 0), steps.length - 1);\n const step: WizardStep | undefined = steps[index];\n const isFirst = index === 0;\n const isLast = index === steps.length - 1;\n const close = () => {\n if (!isPending) {\n onClose();\n }\n };\n const advance = () => {\n if (isPending || !step) {\n return;\n }\n if (step.canContinue === false) {\n step.onInvalid?.();\n return;\n }\n if (step.primaryAction) {\n step.primaryAction.onClick();\n } else if (isLast) {\n onSubmit();\n } else {\n onStepChange(index + 1);\n }\n };\n // The modal stays rendered while closed, so an application modal sees\n // isOpen={false} and can run its own close behavior.\n return (\n <ModalComponent\n isOpen={isOpen}\n size=\"md\"\n title={step?.title ?? title}\n description={step?.modalDescription ?? description}\n onClose={close}\n footer={\n step && (\n <WizardActions\n step={step}\n isFirst={isFirst}\n isLast={isLast}\n isPending={isPending}\n submitLabel={submitLabel}\n onBack={isFirst ? close : () => onStepChange(index - 1)}\n onAdvance={advance}\n />\n )\n }\n >\n <div className=\"ds-wizard__content\">\n {steps.length > 1 && (\n <>\n <Stepper\n size=\"md\"\n orientation=\"auto\"\n activeStep={index}\n steps={steps.map(({ id, label, description }) => ({ id, label, description }))}\n onStepChange={isNavigable && !isPending ? onStepChange : undefined}\n />\n <hr className=\"ds-wizard__rule\" />\n </>\n )}\n {/* Each step mounts fresh, so steps sharing a component type never share its state. */}\n {step && <Fragment key={step.id}>{step.content}</Fragment>}\n </div>\n </ModalComponent>\n );\n}\n"],"mappings":"A,2OAOA,IAAMoB,EAAe,GAAwB,GAAyC,CAChFC,EAAM,QAAU,GAClBC,EAAO,CAEX,EAYA,SAAgBC,EAAc,CAC5B,OACA,UACA,SACA,YACA,cACA,SACA,aACqB,CACrB,OACE,EAAAJ,EAAA,KAAA,CAAAnB,EAAAA,SAAA,CAAA,SAAA,CACG,CAACwB,EAAK,gBACL,EAAAL,EAAA,IAAA,CAAClB,EAAAA,OAAD,CACE,WAAYwB,EACZ,wBAAA,GACA,QAASL,EAAYM,CAAM,EAE1B,SAAAC,EAAU,SAAW,MAChB,CAAA,GAEV,EAAAR,EAAA,IAAA,CAAClB,EAAAA,OAAD,CACE,QAAQ,UACR,WAAYwB,GAAcD,EAAK,cAAgB,IAAS,CAACA,EAAK,UACnD,YACX,wBAAA,GACA,QAASJ,EAAYQ,CAAS,EAE7B,SAAAJ,EAAK,eAAe,QAAUK,EAASC,EAAc,OAChD,CAAA,CACR,CAAA,CAAA,CAEN,CC9BA,SAAgBC,EAAY,CAAE,OAAM,eAAc,aAAa,IAA2B,CACxF,OACE,EAAAZ,EAAA,IAAA,CAACjB,EAAAA,WAAD,CAAA,UACE,EAAAiB,EAAA,KAAA,CAAChB,EAAAA,MAAD,CAAA,SAAA,EACE,EAAAgB,EAAA,IAAA,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AU,EACpBN,EAASM,IAAUI,EAAM,OAAS,EAClCC,MAAc,CACbf,GACHgB,EAAQ,CAEZ,EAmBA,OACE,EAAAtB,EAAA,IAAA,CAACkB,EAAD,CACU,SACR,KAAK,KACL,MAAOb,GAAM,OAASkB,EACtB,YAAalB,GAAM,kBAAoBmB,EACvC,QAASH,EACT,OACEhB,IACE,EAAAL,EAAA,IAAA,CAACI,EAAD,CACQ,OACG,UACD,SACG,YACE,cACb,OAAQI,EAAUa,MAAcN,EAAaC,EAAQ,CAAC,EACtD,cAlCY,CAChB,IAAcX,IAGdA,EAAK,cAAgB,GACvBA,EAAK,YAAY,EAGfA,EAAK,cACPA,EAAK,cAAc,QAAQ,EAClBK,EACTe,EAAS,EAETV,EAAaC,EAAQ,CAAC,EAE1B,CAoBS,CAAA,EAIL,UAAA,EAAAhB,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,qBAAf,SAAA,CACGoB,EAAM,OAAS,IACd,EAAApB,EAAA,KAAA,CAAAR,EAAAA,SAAA,CAAA,SAAA,EACE,EAAAQ,EAAA,IAAA,CAACP,EAAAA,QAAD,CACE,KAAK,KACL,YAAY,OACZ,WAAYuB,EACZ,MAAOI,EAAM,KAAK,CAAE,KAAI,QAAO,kBAAmB,CAAE,KAAI,QAAO,aAAY,EAAE,EAC7E,aAAcM,GAAe,CAACpB,EAAYS,EAAe,IAAA,EAC1D,CAAA,GACD,EAAAf,EAAA,IAAA,CAAC,KAAD,CAAI,UAAU,iBAAmB,CAAA,CACjC,CAAA,CAAA,EAGHK,IAAQ,EAAAL,EAAA,IAAA,CAACN,EAAAA,SAAD,CAAA,SAAyBW,EAAK,OAAkB,EAAjCA,EAAK,EAA4B,CACtD,C,EACS,CAAA,CAEpB,C"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Button as e } from "../components/Button/index.js";
|
|
2
|
+
import { Modal as t } from "../components/Modal/index.js";
|
|
3
|
+
import { Table as n, TableBody as r, TableCell as i, TableFrame as a, TableHead as o, TableHeaderCell as s, TableRow as c } from "../components/Table/index.js";
|
|
4
|
+
import { Stepper as l } from "../components/Stepper/index.js";
|
|
5
|
+
import { Fragment as u } from "react";
|
|
6
|
+
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/Wizard/actions.tsx
|
|
8
|
+
var m = (e) => (t) => {
|
|
9
|
+
t.detail <= 1 && e();
|
|
10
|
+
};
|
|
11
|
+
function h({ step: t, isFirst: n, isLast: r, isPending: i, submitLabel: a, onBack: o, onAdvance: s }) {
|
|
12
|
+
return /* @__PURE__ */ p(d, { children: [!t.hideSecondary && /* @__PURE__ */ f(e, {
|
|
13
|
+
isDisabled: i,
|
|
14
|
+
isFocusableWhenDisabled: !0,
|
|
15
|
+
onClick: m(o),
|
|
16
|
+
children: n ? "Cancel" : "Back"
|
|
17
|
+
}), /* @__PURE__ */ f(e, {
|
|
18
|
+
variant: "primary",
|
|
19
|
+
isDisabled: i || t.canContinue === !1 && !t.onInvalid,
|
|
20
|
+
isPending: i,
|
|
21
|
+
isFocusableWhenDisabled: !0,
|
|
22
|
+
onClick: m(s),
|
|
23
|
+
children: t.primaryAction?.label ?? (r ? a : "Next")
|
|
24
|
+
})] });
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/components/Wizard/review-table.tsx
|
|
28
|
+
function g({ rows: t, onStepChange: l, isDisabled: u = !1 }) {
|
|
29
|
+
return /* @__PURE__ */ f(a, { children: /* @__PURE__ */ p(n, { children: [/* @__PURE__ */ f(o, { children: /* @__PURE__ */ p(c, { children: [
|
|
30
|
+
/* @__PURE__ */ f(s, { children: "Setting" }),
|
|
31
|
+
/* @__PURE__ */ f(s, { children: "Value" }),
|
|
32
|
+
/* @__PURE__ */ f(s, {
|
|
33
|
+
width: "control",
|
|
34
|
+
align: "end",
|
|
35
|
+
"aria-label": "Actions"
|
|
36
|
+
})
|
|
37
|
+
] }) }), /* @__PURE__ */ f(r, { children: t.map((t, n) => /* @__PURE__ */ p(c, { children: [
|
|
38
|
+
/* @__PURE__ */ f(i, {
|
|
39
|
+
emphasis: "primary",
|
|
40
|
+
children: t.term
|
|
41
|
+
}),
|
|
42
|
+
/* @__PURE__ */ f(i, { children: t.value }),
|
|
43
|
+
/* @__PURE__ */ f(i, {
|
|
44
|
+
width: "control",
|
|
45
|
+
align: "end",
|
|
46
|
+
children: /* @__PURE__ */ f(e, {
|
|
47
|
+
isDisabled: u,
|
|
48
|
+
size: "sm",
|
|
49
|
+
variant: "simple",
|
|
50
|
+
"aria-label": `Edit ${t.term}`,
|
|
51
|
+
onClick: () => l(t.step),
|
|
52
|
+
children: "Edit"
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
] }, n)) })] }) });
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/components/Wizard/index.tsx
|
|
59
|
+
function _({ isOpen: e, modalComponent: n = t, title: r, description: i, steps: a, activeStep: o = 0, onStepChange: s = () => {}, submitLabel: c, onSubmit: m, isPending: g = !1, isNavigable: _ = !0, onClose: v }) {
|
|
60
|
+
let y = Math.min(Math.max(o, 0), a.length - 1), b = a[y], x = y === 0, S = y === a.length - 1, C = () => {
|
|
61
|
+
g || v();
|
|
62
|
+
};
|
|
63
|
+
return /* @__PURE__ */ f(n, {
|
|
64
|
+
isOpen: e,
|
|
65
|
+
size: "md",
|
|
66
|
+
title: b?.title ?? r,
|
|
67
|
+
description: b?.modalDescription ?? i,
|
|
68
|
+
onClose: C,
|
|
69
|
+
footer: b && /* @__PURE__ */ f(h, {
|
|
70
|
+
step: b,
|
|
71
|
+
isFirst: x,
|
|
72
|
+
isLast: S,
|
|
73
|
+
isPending: g,
|
|
74
|
+
submitLabel: c,
|
|
75
|
+
onBack: x ? C : () => s(y - 1),
|
|
76
|
+
onAdvance: () => {
|
|
77
|
+
!g && b && (b.canContinue === !1 ? b.onInvalid?.() : b.primaryAction ? b.primaryAction.onClick() : S ? m() : s(y + 1));
|
|
78
|
+
}
|
|
79
|
+
}),
|
|
80
|
+
children: /* @__PURE__ */ p("div", {
|
|
81
|
+
className: "ds-wizard__content",
|
|
82
|
+
children: [a.length > 1 && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f(l, {
|
|
83
|
+
size: "md",
|
|
84
|
+
orientation: "auto",
|
|
85
|
+
activeStep: y,
|
|
86
|
+
steps: a.map(({ id: e, label: t, description: n }) => ({
|
|
87
|
+
id: e,
|
|
88
|
+
label: t,
|
|
89
|
+
description: n
|
|
90
|
+
})),
|
|
91
|
+
onStepChange: _ && !g ? s : void 0
|
|
92
|
+
}), /* @__PURE__ */ f("hr", { className: "ds-wizard__rule" })] }), b && /* @__PURE__ */ f(u, { children: b.content }, b.id)]
|
|
93
|
+
})
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
export { g as n, _ as t };
|
|
98
|
+
|
|
99
|
+
//# sourceMappingURL=Wizard-C1iR5z44.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Wizard-C1iR5z44.js","names":["_Fragment","_Fragment","Fragment$1","singleClick","event","action","WizardActions","step","Button","isPending","onBack","isFirst","onAdvance","isLast","submitLabel","ReviewTable","TableFrame","Table","TableHead","TableRow","TableHeaderCell","TableBody","rows","TableCell","row","onStepChange","index","Wizard","ModalComponent","Modal","activeStep","steps","close","onClose","title","description","onSubmit","Stepper","isNavigable","Fragment"],"sources":["../../src/components/Wizard/actions.tsx","../../src/components/Wizard/review-table.tsx","../../src/components/Wizard/index.tsx"],"sourcesContent":["import type { MouseEvent } from \"react\";\nimport { Button } from \"../Button\";\nimport type { WizardStep } from \"./types\";\n\n// A footer changes meaning between steps. Ignore the second click of a double-click.\n// Blocked footer buttons stay focusable: the pressed Next/Finish button is the\n// same element on the following step, so native disabling would drop its focus.\nconst singleClick = (action: () => void) => (event: MouseEvent<HTMLButtonElement>) => {\n if (event.detail <= 1) {\n action();\n }\n};\n\ninterface WizardActionsProps {\n step: WizardStep;\n isFirst: boolean;\n isLast: boolean;\n isPending: boolean;\n submitLabel: string;\n onBack: () => void;\n onAdvance: () => void;\n}\n\nexport function WizardActions({\n step,\n isFirst,\n isLast,\n isPending,\n submitLabel,\n onBack,\n onAdvance,\n}: WizardActionsProps) {\n return (\n <>\n {!step.hideSecondary && (\n <Button\n isDisabled={isPending}\n isFocusableWhenDisabled\n onClick={singleClick(onBack)}\n >\n {isFirst ? \"Cancel\" : \"Back\"}\n </Button>\n )}\n <Button\n variant=\"primary\"\n isDisabled={isPending || (step.canContinue === false && !step.onInvalid)}\n isPending={isPending}\n isFocusableWhenDisabled\n onClick={singleClick(onAdvance)}\n >\n {step.primaryAction?.label ?? (isLast ? submitLabel : \"Next\")}\n </Button>\n </>\n );\n}\n","import { Button } from \"../Button\";\nimport {\n Table,\n TableBody,\n TableCell,\n TableFrame,\n TableHead,\n TableHeaderCell,\n TableRow,\n} from \"../Table\";\nimport type { ReactNode } from \"react\";\n\nexport interface ReviewRow {\n term: string;\n value: ReactNode;\n step: number;\n}\n\nexport interface ReviewTableProps {\n rows: ReviewRow[];\n isDisabled?: boolean;\n onStepChange: (index: number) => void;\n}\n\nexport function ReviewTable({ rows, onStepChange, isDisabled = false }: ReviewTableProps) {\n return (\n <TableFrame>\n <Table>\n <TableHead>\n <TableRow>\n <TableHeaderCell>Setting</TableHeaderCell>\n <TableHeaderCell>Value</TableHeaderCell>\n <TableHeaderCell\n width=\"control\"\n align=\"end\"\n aria-label=\"Actions\"\n />\n </TableRow>\n </TableHead>\n <TableBody>\n {/* Terms may repeat, and rows hold no state of their own, so position is the key. */}\n {rows.map((row, index) => (\n <TableRow key={index}>\n <TableCell emphasis=\"primary\">{row.term}</TableCell>\n <TableCell>{row.value}</TableCell>\n <TableCell\n width=\"control\"\n align=\"end\"\n >\n <Button\n isDisabled={isDisabled}\n size=\"sm\"\n variant=\"simple\"\n aria-label={`Edit ${row.term}`}\n onClick={() => onStepChange(row.step)}\n >\n Edit\n </Button>\n </TableCell>\n </TableRow>\n ))}\n </TableBody>\n </Table>\n </TableFrame>\n );\n}\n","import { Fragment } from \"react\";\nimport { Modal } from \"../Modal\";\nimport { Stepper } from \"../Stepper\";\nimport { WizardActions } from \"./actions\";\nimport type { WizardProps, WizardStep } from \"./types\";\nimport \"./style.css\";\n\nexport type { WizardProps, WizardStep } from \"./types\";\nexport { ReviewTable } from \"./review-table\";\nexport type { ReviewTableProps, ReviewRow } from \"./review-table\";\n\n/** Controlled layout and navigation; applications own values, validation and actions. */\nexport function Wizard({\n isOpen,\n modalComponent: ModalComponent = Modal,\n title,\n description,\n steps,\n activeStep = 0,\n onStepChange = () => {},\n submitLabel,\n onSubmit,\n isPending = false,\n isNavigable = true,\n onClose,\n}: WizardProps) {\n // An index past the end, such as after a conditional step is removed, shows\n // the last step. Without steps, such as while they load, only the frame shows.\n const index = Math.min(Math.max(activeStep, 0), steps.length - 1);\n const step: WizardStep | undefined = steps[index];\n const isFirst = index === 0;\n const isLast = index === steps.length - 1;\n const close = () => {\n if (!isPending) {\n onClose();\n }\n };\n const advance = () => {\n if (isPending || !step) {\n return;\n }\n if (step.canContinue === false) {\n step.onInvalid?.();\n return;\n }\n if (step.primaryAction) {\n step.primaryAction.onClick();\n } else if (isLast) {\n onSubmit();\n } else {\n onStepChange(index + 1);\n }\n };\n // The modal stays rendered while closed, so an application modal sees\n // isOpen={false} and can run its own close behavior.\n return (\n <ModalComponent\n isOpen={isOpen}\n size=\"md\"\n title={step?.title ?? title}\n description={step?.modalDescription ?? description}\n onClose={close}\n footer={\n step && (\n <WizardActions\n step={step}\n isFirst={isFirst}\n isLast={isLast}\n isPending={isPending}\n submitLabel={submitLabel}\n onBack={isFirst ? close : () => onStepChange(index - 1)}\n onAdvance={advance}\n />\n )\n }\n >\n <div className=\"ds-wizard__content\">\n {steps.length > 1 && (\n <>\n <Stepper\n size=\"md\"\n orientation=\"auto\"\n activeStep={index}\n steps={steps.map(({ id, label, description }) => ({ id, label, description }))}\n onStepChange={isNavigable && !isPending ? onStepChange : undefined}\n />\n <hr className=\"ds-wizard__rule\" />\n </>\n )}\n {/* Each step mounts fresh, so steps sharing a component type never share its state. */}\n {step && <Fragment key={step.id}>{step.content}</Fragment>}\n </div>\n </ModalComponent>\n );\n}\n"],"mappings":";;;;;;;AAOA,IAAMG,KAAe,OAAwB,MAAyC;CACpF,AAAIC,EAAM,UAAU,KAClBC,EAAO;AAEX;AAYA,SAAgBC,EAAc,EAC5B,SACA,YACA,WACA,cACA,gBACA,WACA,gBACqB;CACrB,OACE,kBAAAN,GAAA,EAAA,UAAA,CACG,CAACO,EAAK,iBACL,kBAACC,GAAD;EACE,YAAYC;EACZ,yBAAA;EACA,SAASN,EAAYO,CAAM;EAE1B,UAAAC,IAAU,WAAW;CAChB,CAAA,GAEV,kBAACH,GAAD;EACE,SAAQ;EACR,YAAYC,KAAcF,EAAK,gBAAgB,MAAS,CAACA,EAAK;EACnD;EACX,yBAAA;EACA,SAASJ,EAAYS,CAAS;EAE7B,UAAAL,EAAK,eAAe,UAAUM,IAASC,IAAc;CAChD,CAAA,CACR,EAAA,CAAA;AAEN;;;AC9BA,SAAgBC,EAAY,EAAE,SAAM,iBAAc,gBAAa,MAA2B;CACxF,OACE,kBAACC,GAAD,EAAA,UACE,kBAACC,GAAD,EAAA,UAAA,CACE,kBAACC,GAAD,EAAA,UACE,kBAACC,GAAD,EAAA,UAAA;EACE,kBAACC,GAAD,EAAA,UAAiB,UAAwB,CAAA;EACzC,kBAACA,GAAD,EAAA,UAAiB,QAAsB,CAAA;EACvC,kBAACA,GAAD;GACE,OAAM;GACN,OAAM;GACN,cAAW;EACZ,CAAA;CACO,EAAA,CAAA,EACD,CAAA,GACX,kBAACC,GAAD,EAAA,UAEGC,EAAK,KAAK,GAAK,MACd,kBAACH,GAAD,EAAA,UAAA;EACE,kBAACI,GAAD;GAAW,UAAS;GAAW,UAAAC,EAAI;EAAgB,CAAA;EACnD,kBAACD,GAAD,EAAA,UAAYC,E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AO,sBAAmB;KAAE;KAAI;KAAO;IAAY,EAAE;IAC7E,cAAcO,KAAe,CAAC7B,IAAYgB,IAAe,KAAA;GAC1D,CAAA,GACD,kBAAC,MAAD,EAAI,WAAU,kBAAmB,CAAA,CACjC,EAAA,CAAA,GAGHlB,KAAQ,kBAACgC,GAAD,EAAA,UAAyBhC,EAAK,QAAkB,GAAjCA,EAAK,EAA4B,CACtD;;CACS,CAAA;AAEpB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./context-BONPXF-V.cjs"),t=require("../components/Badge/index.cjs"),n=require("./limit-BX6-o1a2.cjs");;/* empty css */let r=require("react"),i=require("react/jsx-runtime");function a({label:e,count:n,isRequired:r,isGroup:a,id:o,labelId:s,hasHeader:c,labelHint:l,hasLabelHint:u,labelHintId:d,children:f}){let p=a?`legend`:`label`,m=u?(0,i.jsxs)(`span`,{className:`ds-field__support`,children:[(0,i.jsx)(`span`,{id:d,className:`ds-field__label-hint`,children:l}),f]}):f,h=(0,i.jsxs)(i.Fragment,{children:[e,n!==void 0&&(0,i.jsx)(t.Badge,{className:`ds-field__count`,shape:`count`,isCountExact:!0,"aria-hidden":`true`,children:n}),r&&(0,i.jsx)(`span`,{className:`ds-field__required`,"aria-hidden":`true`,children:`*`})]}),g=(0,i.jsx)(p,{id:s,className:`ds-field__label`,htmlFor:a?void 0:o,children:h});return c?a?(0,i.jsxs)(`legend`,{className:`ds-field__header`,children:[(0,i.jsx)(`span`,{id:s,className:`ds-field__label`,children:h}),m]}):(0,i.jsxs)(`div`,{className:`ds-field__header`,children:[g,m]}):g}function o({count:e,max:t,id:r,limitDisplay:a=`used`,showLimitRing:o=!0}){let s=Math.min(1,e/t),c={"--limit-mix":`${(s<=.6?s/.6:(s-.6)/.4)*100}%`,"--limit-from":s<=.6?`var(--color-success)`:`var(--color-warning)`,"--limit-to":s<=.6?`var(--color-warning)`:`var(--color-danger)`};return(0,i.jsxs)(`span`,{className:`ds-field__limit`,"data-tone":n.n({count:e,max:t}),style:c,children:[(0,i.jsx)(`span`,{"aria-hidden":`true`,children:a===`remaining`?`${t-e} left`:`${e}/${t}`}),(0,i.jsx)(`span`,{id:r,className:`ds-field__limit-description`,children:n.t({count:e,max:t},a)}),o&&(0,i.jsxs)(`svg`,{className:`ds-field__limit-ring`,width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,i.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`}),(0,i.jsx)(`circle`,{className:`ds-field__limit-progress`,cx:`8`,cy:`8`,r:`6`,pathLength:`1`,strokeDasharray:s>=1?`none`:`${s} 1`})]})]})}var s={warning:1,danger:2};function c({limitDisplay:e,...t}){let a=n.n(t),o=a?s[a]:0,[c,l]=(0,r.useState)({level:o,text:``});return c.level!==o&&l({level:o,text:o>c.level?n.t(t,e):``}),(0,i.jsx)(`span`,{className:`ds-field__limit-announcement`,"aria-live":`polite`,"aria-atomic":`true`,children:c.text})}function l({label:t,labelHint:s,hint:l,error:p,isRequired:m,count:h,limit:g,limitDisplay:_,limitVisibility:v,showLimitRing:y,isGroup:b=!1,children:x,className:S,groupBinding:C}){let w=(0,r.useId)(),T=d(l,p,w),E=`${w}-label`,D=`${w}-label-hint`,O=r.Children.toArray(s).some(e=>e!==``),k=`${w}-limit`,A=b?`fieldset`:`div`,[j,M]=(0,r.useState)(),[N,P]=(0,r.useState)(()=>new Map),F=g!==void 0,I=(0,r.useMemo)(()=>({labelId:E,isGroup:b,reportCount:M,reportLimit:F?void 0:(e,t)=>P(n=>u(n,e,t))}),[E,b,F]),L=h??j,[R]=N.values(),z=g??R,B=n.i(z,v),V=[T?.id,O?D:void 0,B?k:void 0].filter(Boolean).join(` `)||void 0,H=B&&(0,i.jsx)(o,{...B,id:k,limitDisplay:_,showLimitRing:y}),U=n.r(z)?z:void 0,W=U!==void 0||O;return(0,i.jsxs)(A,{...b?f(C,V,!!p,W?E:void 0):void 0,className:[`ds-field`,S].filter(Boolean).join(` `),children:[(0,i.jsx)(a,{label:t,count:L,isRequired:m,isGroup:b,id:w,labelId:E,hasHeader:W,labelHint:s,hasLabelHint:O,labelHintId:D,children:H}),U&&(0,i.jsx)(c,{...U,limitDisplay:_}),(0,i.jsx)(e.t.Provider,{value:I,children:x({id:w,"aria-describedby":V,"aria-labelledby":E,"aria-invalid":p?!0:void 0,required:m})}),T&&(0,i.jsx)(`span`,{...T})]})}function u(e,t,n){let r=e.get(t);if(n?r?.count===n.count&&r.max===n.max:!r)return e;let i=new Map(e);return n?i.set(t,n):i.delete(t),i}function d(e,t,n){if(t)return{id:`${n}-error`,className:`ds-field__error`,children:t};if(e)return{id:`${n}-hint`,className:`ds-field__hint`,children:e}}function f(e,t,n,r){return{...e,"aria-labelledby":e?.[`aria-labelledby`]||(e?.[`aria-label`]?void 0:r),"aria-describedby":[e?.[`aria-describedby`],t].filter(Boolean).join(` `)||void 0,"aria-invalid":n||e?.[`aria-invalid`]}}Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return l}});
|
|
2
|
+
//# sourceMappingURL=frame-C8TwdWBC.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame-C8TwdWBC.cjs","names":["_Fragment","Badge","limitTone","limitDescription","useState","useId","Children","useState","useMemo","visibleLimit","usableLimit","FieldFrameContext","require_context","require_components_Badge_index","require_limit","react","react_jsx_runtime","FieldHeader","Label","isGroup","support","hasLabelHint","labelHintId","labelHint","children","contents","label","count","isRequired","labelElement","labelId","id","hasHeader","LimitReading","ratio","max","style","limitDisplay","showLimitRing","levels","LimitAnnouncer","limit","tone","level","announcement","setAnnouncement","FieldFrame","message","fieldMessage","hint","error","child","limitId","Wrapper","reportedCount","reportCount","reports","setReports","hasExplicitLimit","frame","withReport","current","key","next","shownCount","reportedLimit","currentLimit","shownLimit","limitVisibility","describedBy","reading","activeLimit","groupAttributes","groupBinding","className","binding","limitLabelId","description","invalid"],"sources":["../../src/components/Field/header.tsx","../../src/components/Field/limit-reading.tsx","../../src/components/Field/frame.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { Badge } from \"../Badge\";\nimport type { FieldProps } from \"./types\";\n\ninterface FieldHeaderProps extends Pick<\n FieldProps,\n \"label\" | \"labelHint\" | \"count\" | \"isRequired\" | \"isGroup\"\n> {\n id: string;\n labelId: string;\n hasHeader: boolean;\n hasLabelHint: boolean;\n labelHintId: string;\n children: ReactNode;\n}\n\n/** Keep the usage reading outside the label's name and the legend directly in its fieldset. */\nexport function FieldHeader({\n label,\n count,\n isRequired,\n isGroup,\n id,\n labelId,\n hasHeader,\n labelHint,\n hasLabelHint,\n labelHintId,\n children,\n}: FieldHeaderProps) {\n const Label = isGroup ? \"legend\" : \"label\";\n const support = hasLabelHint ? (\n <span className=\"ds-field__support\">\n <span\n id={labelHintId}\n className=\"ds-field__label-hint\"\n >\n {labelHint}\n </span>\n {children}\n </span>\n ) : (\n children\n );\n const contents = (\n <>\n {label}\n {count !== undefined && (\n <Badge\n className=\"ds-field__count\"\n shape=\"count\"\n isCountExact\n aria-hidden=\"true\"\n >\n {count}\n </Badge>\n )}\n {isRequired && (\n <span\n className=\"ds-field__required\"\n aria-hidden=\"true\"\n >\n *\n </span>\n )}\n </>\n );\n const labelElement = (\n <Label\n id={labelId}\n className=\"ds-field__label\"\n htmlFor={isGroup ? undefined : id}\n >\n {contents}\n </Label>\n );\n if (!hasHeader) {\n return labelElement;\n }\n if (isGroup) {\n return (\n <legend className=\"ds-field__header\">\n <span\n id={labelId}\n className=\"ds-field__label\"\n >\n {contents}\n </span>\n {support}\n </legend>\n );\n }\n return (\n <div className=\"ds-field__header\">\n {labelElement}\n {support}\n </div>\n );\n}\n","import { useState, type CSSProperties } from \"react\";\nimport { limitDescription, limitTone } from \"./limit\";\nimport type { FieldLimit, FieldLimitOptions } from \"./types\";\n\nexport function LimitReading({\n count,\n max,\n id,\n limitDisplay = \"used\",\n showLimitRing = true,\n}: FieldLimit & FieldLimitOptions & { id: string }) {\n const ratio = Math.min(1, count / max);\n const progress = ratio <= 0.6 ? ratio / 0.6 : (ratio - 0.6) / 0.4;\n const style = {\n \"--limit-mix\": `${progress * 100}%`,\n \"--limit-from\": ratio <= 0.6 ? \"var(--color-success)\" : \"var(--color-warning)\",\n \"--limit-to\": ratio <= 0.6 ? \"var(--color-warning)\" : \"var(--color-danger)\",\n } as CSSProperties;\n return (\n <span\n className=\"ds-field__limit\"\n data-tone={limitTone({ count, max })}\n style={style}\n >\n <span aria-hidden=\"true\">\n {limitDisplay === \"remaining\" ? `${max - count} left` : `${count}/${max}`}\n </span>\n <span\n id={id}\n className=\"ds-field__limit-description\"\n >\n {limitDescription({ count, max }, limitDisplay)}\n </span>\n {showLimitRing && (\n <svg\n className=\"ds-field__limit-ring\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n aria-hidden=\"true\"\n >\n <circle\n cx=\"8\"\n cy=\"8\"\n r=\"6\"\n />\n <circle\n className=\"ds-field__limit-progress\"\n cx=\"8\"\n cy=\"8\"\n r=\"6\"\n pathLength=\"1\"\n // A continuous stroke avoids a dash seam at the circle's closing point.\n strokeDasharray={ratio >= 1 ? \"none\" : `${ratio} 1`}\n />\n </svg>\n )}\n </span>\n );\n}\n\nconst levels = { warning: 1, danger: 2 } as const;\n\n/**\n * A polite region that exists for as long as the limit does, so it is already\n * registered when usage first crosses into warning or danger. It speaks only on\n * those crossings, not on every keystroke, and falls silent below them so a\n * later crossing is announced again. Loaded values are described, not announced.\n */\nexport function LimitAnnouncer({\n limitDisplay,\n ...limit\n}: FieldLimit & Pick<FieldLimitOptions, \"limitDisplay\">) {\n const tone = limitTone(limit);\n const level = tone ? levels[tone] : 0;\n const [announcement, setAnnouncement] = useState({ level, text: \"\" });\n if (announcement.level !== level) {\n setAnnouncement({\n level,\n text: level > announcement.level ? limitDescription(limit, limitDisplay) : \"\",\n });\n }\n return (\n <span\n className=\"ds-field__limit-announcement\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n >\n {announcement.text}\n </span>\n );\n}\n","import { Children, useId, useMemo, useState } from \"react\";\nimport { FieldFrameContext, type FieldFrameContextValue } from \"./context\";\nimport { FieldHeader } from \"./header\";\nimport { LimitAnnouncer, LimitReading } from \"./limit-reading\";\nimport { usableLimit, visibleLimit } from \"./limit\";\nimport type { FieldBinding, FieldLimit, FieldProps } from \"./types\";\nimport \"./style.css\";\n\ninterface FieldFrameProps extends FieldProps {\n className?: string;\n groupBinding?: FieldBinding;\n}\n\ntype LimitReports = ReadonlyMap<string, FieldLimit>;\n\n/**\n * Shared label/legend, count, required marker and messages, including standalone\n * groups. A group's fieldset carries the description; bound controls don't repeat it.\n */\nexport function FieldFrame({\n label,\n labelHint,\n hint,\n error,\n isRequired,\n count,\n limit,\n limitDisplay,\n limitVisibility,\n showLimitRing,\n isGroup = false,\n children,\n className,\n groupBinding,\n}: FieldFrameProps) {\n const id = useId();\n const message = fieldMessage(hint, error, id);\n const labelId = `${id}-label`;\n const labelHintId = `${id}-label-hint`;\n const hasLabelHint = Children.toArray(labelHint).some((child) => child !== \"\");\n const limitId = `${id}-limit`;\n const Wrapper = isGroup ? \"fieldset\" : \"div\";\n const [reportedCount, reportCount] = useState<number>();\n const [reports, setReports] = useState<LimitReports>(() => new Map());\n const hasExplicitLimit = limit !== undefined;\n const frame = useMemo<FieldFrameContextValue>(\n () => ({\n labelId,\n isGroup,\n reportCount,\n reportLimit: hasExplicitLimit\n ? undefined\n : (key, next) => setReports((current) => withReport(current, key, next)),\n }),\n [labelId, isGroup, hasExplicitLimit],\n );\n const shownCount = count ?? reportedCount;\n // The first bound control to report keeps the reading while others come and go.\n const [reportedLimit] = reports.values();\n const currentLimit = limit ?? reportedLimit;\n const shownLimit = visibleLimit(currentLimit, limitVisibility);\n const describedBy =\n [message?.id, hasLabelHint ? labelHintId : undefined, shownLimit ? limitId : undefined]\n .filter(Boolean)\n .join(\" \") || undefined;\n const reading = shownLimit && (\n <LimitReading\n {...shownLimit}\n id={limitId}\n limitDisplay={limitDisplay}\n showLimitRing={showLimitRing}\n />\n );\n const activeLimit = usableLimit(currentLimit) ? currentLimit : undefined;\n const hasHeader = activeLimit !== undefined || hasLabelHint;\n return (\n <Wrapper\n {...(isGroup\n ? groupAttributes(\n groupBinding,\n describedBy,\n Boolean(error),\n hasHeader ? labelId : undefined,\n )\n : undefined)}\n className={[\"ds-field\", className].filter(Boolean).join(\" \")}\n >\n <FieldHeader\n label={label}\n count={shownCount}\n isRequired={isRequired}\n isGroup={isGroup}\n id={id}\n labelId={labelId}\n hasHeader={hasHeader}\n labelHint={labelHint}\n hasLabelHint={hasLabelHint}\n labelHintId={labelHintId}\n >\n {reading}\n </FieldHeader>\n {activeLimit && (\n <LimitAnnouncer\n {...activeLimit}\n limitDisplay={limitDisplay}\n />\n )}\n <FieldFrameContext.Provider value={frame}>\n {children({\n id,\n \"aria-describedby\": describedBy,\n \"aria-labelledby\": labelId,\n \"aria-invalid\": error ? true : undefined,\n required: isRequired,\n })}\n </FieldFrameContext.Provider>\n {message && <span {...message} />}\n </Wrapper>\n );\n}\n\n/** Updates keep a report's position, so one control never displaces another. */\nfunction withReport(reports: LimitReports, key: string, limit: FieldLimit | undefined) {\n const current = reports.get(key);\n if (limit ? current?.count === limit.count && current.max === limit.max : !current) {\n return reports;\n }\n const next = new Map(reports);\n if (limit) {\n next.set(key, limit);\n } else {\n next.delete(key);\n }\n return next;\n}\n\nfunction fieldMessage(hint: FieldProps[\"hint\"], error: FieldProps[\"error\"], id: string) {\n if (error) {\n return { id: `${id}-error`, className: \"ds-field__error\", children: error };\n }\n if (hint) {\n return { id: `${id}-hint`, className: \"ds-field__hint\", children: hint };\n }\n}\n\n/**\n * A limited legend also holds the counter, so `limitLabelId` names the group by\n * its label text alone. A consumer's own name for the group always wins.\n */\nfunction groupAttributes(\n binding: FieldBinding | undefined,\n description: string | undefined,\n invalid: boolean,\n limitLabelId: string | undefined,\n) {\n return {\n ...binding,\n \"aria-labelledby\":\n binding?.[\"aria-labelledby\"] || (binding?.[\"aria-label\"] ? undefined : limitLabelId),\n \"aria-describedby\":\n [binding?.[\"aria-describedby\"], description].filter(Boolean).join(\" \") || undefined,\n \"aria-invalid\": invalid || binding?.[\"aria-invalid\"],\n };\n}\n"],"mappings":"A,6MAiBA,SAAgBiB,EAAY,CAC1B,QACA,QACA,aACA,UACA,KACA,UACA,YACA,YACA,eACA,cACA,YACmB,CACnB,IAAMC,EAAQC,EAAU,SAAW,QAC7BC,EAAUC,GACd,EAAAL,EAAA,KAAA,CAAC,OAAD,CAAM,UAAU,oBAAhB,SAAA,EACE,EAAAA,EAAA,IAAA,CAAC,OAAD,CACE,GAAIM,EACJ,UAAU,uBAET,SAAAC,CACG,CAAA,EACLC,CACG,CAEN,CAAA,EAAAA,EAEIC,GACJ,EAAAT,EAAA,KAAA,CAAAhB,EAAAA,SAAA,CAAA,SAAA,CACG0B,EACAC,IAAU,IAAA,KACT,EAAAX,EAAA,IAAA,CAACf,EAAAA,MAAD,CACE,UAAU,kBACV,MAAM,QACN,aAAA,GACA,cAAY,OAEX,SAAA0B,CACI,CAAA,EAERC,IACC,EAAAZ,EAAA,IAAA,CAAC,OAAD,CACE,UAAU,qBACV,cAAY,OACb,SAAA,GAEK,CAAA,CAER,CAAA,CAAA,EAEEa,GACJ,EAAAb,EAAA,IAAA,CAACE,EAAD,CACE,GAAIY,EACJ,UAAU,kBACV,QAASX,EAAU,IAAA,GAAYY,EAE9B,SAAAN,CACI,CAAA,EAkBT,OAhBKO,EAGDb,GAEA,EAAAH,EAAA,KAAA,CAAC,SAAD,CAAQ,UAAU,mBAAlB,SAAA,EACE,EAAAA,EAAA,IAAA,CAAC,OAAD,CACE,GAAIc,EACJ,UAAU,kBAET,SAAAL,CACG,CAAA,EACLL,CACK,C,IAIV,EAAAJ,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,mBAAf,SAAA,CACGa,EACAT,CACE,C,GAnBES,CAqBX,CC9FA,SAAgBI,EAAa,CAC3B,QACA,MACA,KACA,eAAe,OACf,gB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CAEA,SAASf,EAAa,EAA0B,EAA4B,EAAY,CACtF,GAAIE,EACF,MAAO,CAAE,GAAI,GAAGnB,EAAG,QAAS,UAAW,kBAAmB,SAAUmB,CAAM,EAE5E,GAAID,EACF,MAAO,CAAE,GAAI,GAAGlB,EAAG,OAAQ,UAAW,iBAAkB,SAAUkB,CAAK,CAE3E,CAMA,SAASuB,EACP,EACA,EACA,EACA,EACA,CACA,MAAO,CACL,GAAGG,EACH,kBACEA,IAAU,qBAAuBA,IAAU,cAAgB,IAAA,GAAYC,GACzE,mBACE,CAACD,IAAU,oBAAqBE,CAAW,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,GAAK,IAAA,GAC5E,eAAgBC,GAAWH,IAAU,eACvC,CACF,C"}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { t as e } from "./context-CXvOl4Kt.js";
|
|
2
|
+
import { Badge as t } from "../components/Badge/index.js";
|
|
3
|
+
import { i as n, n as r, r as i, t as a } from "./limit-ChteDN4T.js";
|
|
4
|
+
/* empty css */
|
|
5
|
+
import { Children as o, useId as s, useMemo as c, useState as l } from "react";
|
|
6
|
+
import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/Field/header.tsx
|
|
8
|
+
function p({ label: e, count: n, isRequired: r, isGroup: i, id: a, labelId: o, hasHeader: s, labelHint: c, hasLabelHint: l, labelHintId: p, children: m }) {
|
|
9
|
+
let h = i ? "legend" : "label", g = l ? /* @__PURE__ */ f("span", {
|
|
10
|
+
className: "ds-field__support",
|
|
11
|
+
children: [/* @__PURE__ */ d("span", {
|
|
12
|
+
id: p,
|
|
13
|
+
className: "ds-field__label-hint",
|
|
14
|
+
children: c
|
|
15
|
+
}), m]
|
|
16
|
+
}) : m, _ = /* @__PURE__ */ f(u, { children: [
|
|
17
|
+
e,
|
|
18
|
+
n !== void 0 && /* @__PURE__ */ d(t, {
|
|
19
|
+
className: "ds-field__count",
|
|
20
|
+
shape: "count",
|
|
21
|
+
isCountExact: !0,
|
|
22
|
+
"aria-hidden": "true",
|
|
23
|
+
children: n
|
|
24
|
+
}),
|
|
25
|
+
r && /* @__PURE__ */ d("span", {
|
|
26
|
+
className: "ds-field__required",
|
|
27
|
+
"aria-hidden": "true",
|
|
28
|
+
children: "*"
|
|
29
|
+
})
|
|
30
|
+
] }), v = /* @__PURE__ */ d(h, {
|
|
31
|
+
id: o,
|
|
32
|
+
className: "ds-field__label",
|
|
33
|
+
htmlFor: i ? void 0 : a,
|
|
34
|
+
children: _
|
|
35
|
+
});
|
|
36
|
+
return s ? i ? /* @__PURE__ */ f("legend", {
|
|
37
|
+
className: "ds-field__header",
|
|
38
|
+
children: [/* @__PURE__ */ d("span", {
|
|
39
|
+
id: o,
|
|
40
|
+
className: "ds-field__label",
|
|
41
|
+
children: _
|
|
42
|
+
}), g]
|
|
43
|
+
}) : /* @__PURE__ */ f("div", {
|
|
44
|
+
className: "ds-field__header",
|
|
45
|
+
children: [v, g]
|
|
46
|
+
}) : v;
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/components/Field/limit-reading.tsx
|
|
50
|
+
function m({ count: e, max: t, id: n, limitDisplay: i = "used", showLimitRing: o = !0 }) {
|
|
51
|
+
let s = Math.min(1, e / t), c = {
|
|
52
|
+
"--limit-mix": `${(s <= .6 ? s / .6 : (s - .6) / .4) * 100}%`,
|
|
53
|
+
"--limit-from": s <= .6 ? "var(--color-success)" : "var(--color-warning)",
|
|
54
|
+
"--limit-to": s <= .6 ? "var(--color-warning)" : "var(--color-danger)"
|
|
55
|
+
};
|
|
56
|
+
return /* @__PURE__ */ f("span", {
|
|
57
|
+
className: "ds-field__limit",
|
|
58
|
+
"data-tone": r({
|
|
59
|
+
count: e,
|
|
60
|
+
max: t
|
|
61
|
+
}),
|
|
62
|
+
style: c,
|
|
63
|
+
children: [
|
|
64
|
+
/* @__PURE__ */ d("span", {
|
|
65
|
+
"aria-hidden": "true",
|
|
66
|
+
children: i === "remaining" ? `${t - e} left` : `${e}/${t}`
|
|
67
|
+
}),
|
|
68
|
+
/* @__PURE__ */ d("span", {
|
|
69
|
+
id: n,
|
|
70
|
+
className: "ds-field__limit-description",
|
|
71
|
+
children: a({
|
|
72
|
+
count: e,
|
|
73
|
+
max: t
|
|
74
|
+
}, i)
|
|
75
|
+
}),
|
|
76
|
+
o && /* @__PURE__ */ f("svg", {
|
|
77
|
+
className: "ds-field__limit-ring",
|
|
78
|
+
width: "16",
|
|
79
|
+
height: "16",
|
|
80
|
+
viewBox: "0 0 16 16",
|
|
81
|
+
"aria-hidden": "true",
|
|
82
|
+
children: [/* @__PURE__ */ d("circle", {
|
|
83
|
+
cx: "8",
|
|
84
|
+
cy: "8",
|
|
85
|
+
r: "6"
|
|
86
|
+
}), /* @__PURE__ */ d("circle", {
|
|
87
|
+
className: "ds-field__limit-progress",
|
|
88
|
+
cx: "8",
|
|
89
|
+
cy: "8",
|
|
90
|
+
r: "6",
|
|
91
|
+
pathLength: "1",
|
|
92
|
+
strokeDasharray: s >= 1 ? "none" : `${s} 1`
|
|
93
|
+
})]
|
|
94
|
+
})
|
|
95
|
+
]
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
var h = {
|
|
99
|
+
warning: 1,
|
|
100
|
+
danger: 2
|
|
101
|
+
};
|
|
102
|
+
function g({ limitDisplay: e, ...t }) {
|
|
103
|
+
let n = r(t), i = n ? h[n] : 0, [o, s] = l({
|
|
104
|
+
level: i,
|
|
105
|
+
text: ""
|
|
106
|
+
});
|
|
107
|
+
return o.level !== i && s({
|
|
108
|
+
level: i,
|
|
109
|
+
text: i > o.level ? a(t, e) : ""
|
|
110
|
+
}), /* @__PURE__ */ d("span", {
|
|
111
|
+
className: "ds-field__limit-announcement",
|
|
112
|
+
"aria-live": "polite",
|
|
113
|
+
"aria-atomic": "true",
|
|
114
|
+
children: o.text
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/components/Field/frame.tsx
|
|
119
|
+
function _({ label: t, labelHint: r, hint: a, error: u, isRequired: h, count: _, limit: x, limitDisplay: S, limitVisibility: C, showLimitRing: w, isGroup: T = !1, children: E, className: D, groupBinding: O }) {
|
|
120
|
+
let k = s(), A = y(a, u, k), j = `${k}-label`, M = `${k}-label-hint`, N = o.toArray(r).some((e) => e !== ""), P = `${k}-limit`, F = T ? "fieldset" : "div", [I, L] = l(), [R, z] = l(() => /* @__PURE__ */ new Map()), B = x !== void 0, V = c(() => ({
|
|
121
|
+
labelId: j,
|
|
122
|
+
isGroup: T,
|
|
123
|
+
reportCount: L,
|
|
124
|
+
reportLimit: B ? void 0 : (e, t) => z((n) => v(n, e, t))
|
|
125
|
+
}), [
|
|
126
|
+
j,
|
|
127
|
+
T,
|
|
128
|
+
B
|
|
129
|
+
]), H = _ ?? I, [U] = R.values(), W = x ?? U, G = n(W, C), K = [
|
|
130
|
+
A?.id,
|
|
131
|
+
N ? M : void 0,
|
|
132
|
+
G ? P : void 0
|
|
133
|
+
].filter(Boolean).join(" ") || void 0, q = G && /* @__PURE__ */ d(m, {
|
|
134
|
+
...G,
|
|
135
|
+
id: P,
|
|
136
|
+
limitDisplay: S,
|
|
137
|
+
showLimitRing: w
|
|
138
|
+
}), J = i(W) ? W : void 0, Y = J !== void 0 || N;
|
|
139
|
+
return /* @__PURE__ */ f(F, {
|
|
140
|
+
...T ? b(O, K, !!u, Y ? j : void 0) : void 0,
|
|
141
|
+
className: ["ds-field", D].filter(Boolean).join(" "),
|
|
142
|
+
children: [
|
|
143
|
+
/* @__PURE__ */ d(p, {
|
|
144
|
+
label: t,
|
|
145
|
+
count: H,
|
|
146
|
+
isRequired: h,
|
|
147
|
+
isGroup: T,
|
|
148
|
+
id: k,
|
|
149
|
+
labelId: j,
|
|
150
|
+
hasHeader: Y,
|
|
151
|
+
labelHint: r,
|
|
152
|
+
hasLabelHint: N,
|
|
153
|
+
labelHintId: M,
|
|
154
|
+
children: q
|
|
155
|
+
}),
|
|
156
|
+
J && /* @__PURE__ */ d(g, {
|
|
157
|
+
...J,
|
|
158
|
+
limitDisplay: S
|
|
159
|
+
}),
|
|
160
|
+
/* @__PURE__ */ d(e.Provider, {
|
|
161
|
+
value: V,
|
|
162
|
+
children: E({
|
|
163
|
+
id: k,
|
|
164
|
+
"aria-describedby": K,
|
|
165
|
+
"aria-labelledby": j,
|
|
166
|
+
"aria-invalid": u ? !0 : void 0,
|
|
167
|
+
required: h
|
|
168
|
+
})
|
|
169
|
+
}),
|
|
170
|
+
A && /* @__PURE__ */ d("span", { ...A })
|
|
171
|
+
]
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
function v(e, t, n) {
|
|
175
|
+
let r = e.get(t);
|
|
176
|
+
if (n ? r?.count === n.count && r.max === n.max : !r) return e;
|
|
177
|
+
let i = new Map(e);
|
|
178
|
+
return n ? i.set(t, n) : i.delete(t), i;
|
|
179
|
+
}
|
|
180
|
+
function y(e, t, n) {
|
|
181
|
+
if (t) return {
|
|
182
|
+
id: `${n}-error`,
|
|
183
|
+
className: "ds-field__error",
|
|
184
|
+
children: t
|
|
185
|
+
};
|
|
186
|
+
if (e) return {
|
|
187
|
+
id: `${n}-hint`,
|
|
188
|
+
className: "ds-field__hint",
|
|
189
|
+
children: e
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function b(e, t, n, r) {
|
|
193
|
+
return {
|
|
194
|
+
...e,
|
|
195
|
+
"aria-labelledby": e?.["aria-labelledby"] || (e?.["aria-label"] ? void 0 : r),
|
|
196
|
+
"aria-describedby": [e?.["aria-describedby"], t].filter(Boolean).join(" ") || void 0,
|
|
197
|
+
"aria-invalid": n || e?.["aria-invalid"]
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
//#endregion
|
|
201
|
+
export { _ as t };
|
|
202
|
+
|
|
203
|
+
//# sourceMappingURL=frame-DaC03_n-.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame-DaC03_n-.js","names":["_Fragment","FieldFrameContext","visibleLimit","limitTone","usableLimit","limitDescription","Fragment$1","FieldHeader","Label","isGroup","support","hasLabelHint","labelHintId","labelHint","children","contents","label","count","Badge","isRequired","labelElement","labelId","id","hasHeader","LimitReading","ratio","max","style","limitDisplay","showLimitRing","levels","LimitAnnouncer","limit","tone","level","announcement","setAnnouncement","useState","FieldFrame","useId","message","fieldMessage","hint","error","Children","child","limitId","Wrapper","reportedCount","reportCount","reports","setReports","hasExplicitLimit","frame","useMemo","withReport","current","key","next","shownCount","reportedLimit","currentLimit","shownLimit","limitVisibility","describedBy","reading","activeLimit","groupAttributes","groupBinding","className","binding","limitLabelId","description","invalid"],"sources":["../../src/components/Field/header.tsx","../../src/components/Field/limit-reading.tsx","../../src/components/Field/frame.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { Badge } from \"../Badge\";\nimport type { FieldProps } from \"./types\";\n\ninterface FieldHeaderProps extends Pick<\n FieldProps,\n \"label\" | \"labelHint\" | \"count\" | \"isRequired\" | \"isGroup\"\n> {\n id: string;\n labelId: string;\n hasHeader: boolean;\n hasLabelHint: boolean;\n labelHintId: string;\n children: ReactNode;\n}\n\n/** Keep the usage reading outside the label's name and the legend directly in its fieldset. */\nexport function FieldHeader({\n label,\n count,\n isRequired,\n isGroup,\n id,\n labelId,\n hasHeader,\n labelHint,\n hasLabelHint,\n labelHintId,\n children,\n}: FieldHeaderProps) {\n const Label = isGroup ? \"legend\" : \"label\";\n const support = hasLabelHint ? (\n <span className=\"ds-field__support\">\n <span\n id={labelHintId}\n className=\"ds-field__label-hint\"\n >\n {labelHint}\n </span>\n {children}\n </span>\n ) : (\n children\n );\n const contents = (\n <>\n {label}\n {count !== undefined && (\n <Badge\n className=\"ds-field__count\"\n shape=\"count\"\n isCountExact\n aria-hidden=\"true\"\n >\n {count}\n </Badge>\n )}\n {isRequired && (\n <span\n className=\"ds-field__required\"\n aria-hidden=\"true\"\n >\n *\n </span>\n )}\n </>\n );\n const labelElement = (\n <Label\n id={labelId}\n className=\"ds-field__label\"\n htmlFor={isGroup ? undefined : id}\n >\n {contents}\n </Label>\n );\n if (!hasHeader) {\n return labelElement;\n }\n if (isGroup) {\n return (\n <legend className=\"ds-field__header\">\n <span\n id={labelId}\n className=\"ds-field__label\"\n >\n {contents}\n </span>\n {support}\n </legend>\n );\n }\n return (\n <div className=\"ds-field__header\">\n {labelElement}\n {support}\n </div>\n );\n}\n","import { useState, type CSSProperties } from \"react\";\nimport { limitDescription, limitTone } from \"./limit\";\nimport type { FieldLimit, FieldLimitOptions } from \"./types\";\n\nexport function LimitReading({\n count,\n max,\n id,\n limitDisplay = \"used\",\n showLimitRing = true,\n}: FieldLimit & FieldLimitOptions & { id: string }) {\n const ratio = Math.min(1, count / max);\n const progress = ratio <= 0.6 ? ratio / 0.6 : (ratio - 0.6) / 0.4;\n const style = {\n \"--limit-mix\": `${progress * 100}%`,\n \"--limit-from\": ratio <= 0.6 ? \"var(--color-success)\" : \"var(--color-warning)\",\n \"--limit-to\": ratio <= 0.6 ? \"var(--color-warning)\" : \"var(--color-danger)\",\n } as CSSProperties;\n return (\n <span\n className=\"ds-field__limit\"\n data-tone={limitTone({ count, max })}\n style={style}\n >\n <span aria-hidden=\"true\">\n {limitDisplay === \"remaining\" ? `${max - count} left` : `${count}/${max}`}\n </span>\n <span\n id={id}\n className=\"ds-field__limit-description\"\n >\n {limitDescription({ count, max }, limitDisplay)}\n </span>\n {showLimitRing && (\n <svg\n className=\"ds-field__limit-ring\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n aria-hidden=\"true\"\n >\n <circle\n cx=\"8\"\n cy=\"8\"\n r=\"6\"\n />\n <circle\n className=\"ds-field__limit-progress\"\n cx=\"8\"\n cy=\"8\"\n r=\"6\"\n pathLength=\"1\"\n // A continuous stroke avoids a dash seam at the circle's closing point.\n strokeDasharray={ratio >= 1 ? \"none\" : `${ratio} 1`}\n />\n </svg>\n )}\n </span>\n );\n}\n\nconst levels = { warning: 1, danger: 2 } as const;\n\n/**\n * A polite region that exists for as long as the limit does, so it is already\n * registered when usage first crosses into warning or danger. It speaks only on\n * those crossings, not on every keystroke, and falls silent below them so a\n * later crossing is announced again. Loaded values are described, not announced.\n */\nexport function LimitAnnouncer({\n limitDisplay,\n ...limit\n}: FieldLimit & Pick<FieldLimitOptions, \"limitDisplay\">) {\n const tone = limitTone(limit);\n const level = tone ? levels[tone] : 0;\n const [announcement, setAnnouncement] = useState({ level, text: \"\" });\n if (announcement.level !== level) {\n setAnnouncement({\n level,\n text: level > announcement.level ? limitDescription(limit, limitDisplay) : \"\",\n });\n }\n return (\n <span\n className=\"ds-field__limit-announcement\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n >\n {announcement.text}\n </span>\n );\n}\n","import { Children, useId, useMemo, useState } from \"react\";\nimport { FieldFrameContext, type FieldFrameContextValue } from \"./context\";\nimport { FieldHeader } from \"./header\";\nimport { LimitAnnouncer, LimitReading } from \"./limit-reading\";\nimport { usableLimit, visibleLimit } from \"./limit\";\nimport type { FieldBinding, FieldLimit, FieldProps } from \"./types\";\nimport \"./style.css\";\n\ninterface FieldFrameProps extends FieldProps {\n className?: string;\n groupBinding?: FieldBinding;\n}\n\ntype LimitReports = ReadonlyMap<string, FieldLimit>;\n\n/**\n * Shared label/legend, count, required marker and messages, including standalone\n * groups. A group's fieldset carries the description; bound controls don't repeat it.\n */\nexport function FieldFrame({\n label,\n labelHint,\n hint,\n error,\n isRequired,\n count,\n limit,\n limitDisplay,\n limitVisibility,\n showLimitRing,\n isGroup = false,\n children,\n className,\n groupBinding,\n}: FieldFrameProps) {\n const id = useId();\n const message = fieldMessage(hint, error, id);\n const labelId = `${id}-label`;\n const labelHintId = `${id}-label-hint`;\n const hasLabelHint = Children.toArray(labelHint).some((child) => child !== \"\");\n const limitId = `${id}-limit`;\n const Wrapper = isGroup ? \"fieldset\" : \"div\";\n const [reportedCount, reportCount] = useState<number>();\n const [reports, setReports] = useState<LimitReports>(() => new Map());\n const hasExplicitLimit = limit !== undefined;\n const frame = useMemo<FieldFrameContextValue>(\n () => ({\n labelId,\n isGroup,\n reportCount,\n reportLimit: hasExplicitLimit\n ? undefined\n : (key, next) => setReports((current) => withReport(current, key, next)),\n }),\n [labelId, isGroup, hasExplicitLimit],\n );\n const shownCount = count ?? reportedCount;\n // The first bound control to report keeps the reading while others come and go.\n const [reportedLimit] = reports.values();\n const currentLimit = limit ?? reportedLimit;\n const shownLimit = visibleLimit(currentLimit, limitVisibility);\n const describedBy =\n [message?.id, hasLabelHint ? labelHintId : undefined, shownLimit ? limitId : undefined]\n .filter(Boolean)\n .join(\" \") || undefined;\n const reading = shownLimit && (\n <LimitReading\n {...shownLimit}\n id={limitId}\n limitDisplay={limitDisplay}\n showLimitRing={showLimitRing}\n />\n );\n const activeLimit = usableLimit(currentLimit) ? currentLimit : undefined;\n const hasHeader = activeLimit !== undefined || hasLabelHint;\n return (\n <Wrapper\n {...(isGroup\n ? groupAttributes(\n groupBinding,\n describedBy,\n Boolean(error),\n hasHeader ? labelId : undefined,\n )\n : undefined)}\n className={[\"ds-field\", className].filter(Boolean).join(\" \")}\n >\n <FieldHeader\n label={label}\n count={shownCount}\n isRequired={isRequired}\n isGroup={isGroup}\n id={id}\n labelId={labelId}\n hasHeader={hasHeader}\n labelHint={labelHint}\n hasLabelHint={hasLabelHint}\n labelHintId={labelHintId}\n >\n {reading}\n </FieldHeader>\n {activeLimit && (\n <LimitAnnouncer\n {...activeLimit}\n limitDisplay={limitDisplay}\n />\n )}\n <FieldFrameContext.Provider value={frame}>\n {children({\n id,\n \"aria-describedby\": describedBy,\n \"aria-labelledby\": labelId,\n \"aria-invalid\": error ? true : undefined,\n required: isRequired,\n })}\n </FieldFrameContext.Provider>\n {message && <span {...message} />}\n </Wrapper>\n );\n}\n\n/** Updates keep a report's position, so one control never displaces another. */\nfunction withReport(reports: LimitReports, key: string, limit: FieldLimit | undefined) {\n const current = reports.get(key);\n if (limit ? current?.count === limit.count && current.max === limit.max : !current) {\n return reports;\n }\n const next = new Map(reports);\n if (limit) {\n next.set(key, limit);\n } else {\n next.delete(key);\n }\n return next;\n}\n\nfunction fieldMessage(hint: FieldProps[\"hint\"], error: FieldProps[\"error\"], id: string) {\n if (error) {\n return { id: `${id}-error`, className: \"ds-field__error\", children: error };\n }\n if (hint) {\n return { id: `${id}-hint`, className: \"ds-field__hint\", children: hint };\n }\n}\n\n/**\n * A limited legend also holds the counter, so `limitLabelId` names the group by\n * its label text alone. A consumer's own name for the group always wins.\n */\nfunction groupAttributes(\n binding: FieldBinding | undefined,\n description: string | undefined,\n invalid: boolean,\n limitLabelId: string | undefined,\n) {\n return {\n ...binding,\n \"aria-labelledby\":\n binding?.[\"aria-labelledby\"] || (binding?.[\"aria-label\"] ? undefined : limitLabelId),\n \"aria-describedby\":\n [binding?.[\"aria-describedby\"], description].filter(Boolean).join(\" \") || undefined,\n \"aria-invalid\": invalid || binding?.[\"aria-invalid\"],\n };\n}\n"],"mappings":";;;;;;;AAiBA,SAAgBO,EAAY,EAC1B,UACA,UACA,eACA,YACA,OACA,YACA,cACA,cACA,iBACA,gBACA,eACmB;CACnB,IAAMC,IAAQC,IAAU,WAAW,SAC7BC,IAAUC,IACd,kBAAC,QAAD;EAAM,WAAU;EAAhB,UAAA,CACE,kBAAC,QAAD;GACE,IAAIC;GACJ,WAAU;GAET,UAAAC;EACG,CAAA,GACLC,CACG;CAEN,CAAA,IAAAA,GAEIC,IACJ,kBAAAf,GAAA,EAAA,UAAA;EACGgB;EACAC,MAAU,KAAA,KACT,kBAACC,GAAD;GACE,WAAU;GACV,OAAM;GACN,cAAA;GACA,eAAY;GAEX,UAAAD;EACI,CAAA;EAERE,KACC,kBAAC,QAAD;GACE,WAAU;GACV,eAAY;GACb,UAAA;EAEK,CAAA;CAER,EAAA,CAAA,GAEEC,IACJ,kBAACZ,GAAD;EACE,IAAIa;EACJ,WAAU;EACV,SAASZ,IAAU,KAAA,IAAYa;EAE9B,UAA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,WAAW;EAAmB,UAAUqB;CAAM;CAE5E,IAAID,GACF,OAAO;EAAE,IAAI,GAAGpB,EAAG;EAAQ,WAAW;EAAkB,UAAUoB;CAAK;AAE3E;AAMA,SAASyB,EACP,GACA,GACA,GACA,GACA;CACA,OAAO;EACL,GAAGG;EACH,mBACEA,IAAU,uBAAuBA,IAAU,gBAAgB,KAAA,IAAYC;EACzE,oBACE,CAACD,IAAU,qBAAqBE,CAAW,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,KAAK,KAAA;EAC5E,gBAAgBC,KAAWH,IAAU;CACvC;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "./frame-
|
|
1
|
+
import { t as e } from "./frame-DaC03_n-.js";
|
|
2
2
|
import { t } from "./useLimit-BOmHKdJE.js";
|
|
3
3
|
import { r as n, t as r } from "./binding-Bshy43sG.js";
|
|
4
4
|
import { useEffect as i } from "react";
|
|
@@ -31,4 +31,4 @@ function o({ label: o, hint: s, error: c, isRequired: l, count: u, limit: d, lim
|
|
|
31
31
|
//#endregion
|
|
32
32
|
export { o as t };
|
|
33
33
|
|
|
34
|
-
//# sourceMappingURL=group-
|
|
34
|
+
//# sourceMappingURL=group-C6EOgTgM.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group-
|
|
1
|
+
{"version":3,"file":"group-C6EOgTgM.js","names":["FieldFrame","useGroupBinding","fieldAttributes","FieldGroup","binding","useReportedLimit","limit","useEffect","frame","count","attributes","children"],"sources":["../../src/components/Field/group.tsx"],"sourcesContent":["import { useEffect, type ReactNode } from \"react\";\nimport { FieldFrame } from \"./frame\";\nimport { fieldAttributes, useGroupBinding } from \"./binding\";\nimport type { FieldBinding, FieldProps } from \"./types\";\nimport { useReportedLimit } from \"./useLimit\";\n\nexport interface FieldGroupProps extends FieldBinding, Omit<FieldProps, \"children\" | \"isGroup\"> {\n children: ReactNode;\n className?: string;\n}\n\n/**\n * Standalone groups render their own Field frame. Bound to an enclosing Field,\n * they render only their controls and report their count to its label.\n */\nexport function FieldGroup({\n label,\n hint,\n error,\n isRequired,\n count,\n limit,\n limitDisplay,\n limitVisibility,\n showLimitRing,\n children,\n className,\n ...binding\n}: FieldGroupProps) {\n const { frame, attributes } = useGroupBinding(binding);\n useReportedLimit(binding, limit);\n useEffect(() => {\n if (!frame || count === undefined) {\n return;\n }\n frame.reportCount(count);\n return () => frame.reportCount(undefined);\n }, [frame, count]);\n if (frame) {\n return (\n <div\n {...attributes}\n className={className}\n >\n {children}\n </div>\n );\n }\n return (\n <FieldFrame\n label={label}\n hint={hint}\n error={error}\n isRequired={isRequired}\n count={count}\n limit={limit}\n limitDisplay={limitDisplay}\n limitVisibility={limitVisibility}\n showLimitRing={showLimitRing}\n isGroup\n className={className}\n groupBinding={fieldAttributes(binding)}\n >\n {() => children}\n </FieldFrame>\n );\n}\n"],"mappings":";;;;;;AAeA,SAAgBG,EAAW,EACzB,UACA,SACA,UACA,eACA,UACA,UACA,iBACA,oBACA,kBACA,aACA,cACA,GAAGC,KACe;CAClB,IAAM,EAAE,UAAO,kBAAeH,EAAgBG,CAAO;CAmBrD,OAlBAC,EAAiBD,GAASE,CAAK,GAC/BC,QAAgB;EACd,IAAKC,KAASC,MAAU,KAAA,GAIxB,OADAD,EAAM,YAAYC,CAAK,SACVD,EAAM,YAAY,KAAA,CAAS;CAC1C,GAAG,CAACA,GAAOC,CAAK,CAAC,GACbD,IAEA,kBAAC,OAAD;EACE,GAAIE;EACO;EAEV;CACE,CAAA,IAIP,kBAACV,GAAD;EACS;EACD;EACC;EACK;EACL;EACA;EACO;EACG;EACF;EACf,SAAA;EACW;EACX,cAAcE,EAAgBE,CAAO;EAE9B,gBAAAO;CACG,CAAA;AAEhB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./frame-
|
|
2
|
-
//# sourceMappingURL=group-
|
|
1
|
+
const e=require("./frame-C8TwdWBC.cjs"),t=require("./useLimit-DXe_VmYl.cjs"),n=require("./binding-tMjrUzkU.cjs");let r=require("react"),i=require("react/jsx-runtime");function a({label:a,hint:o,error:s,isRequired:c,count:l,limit:u,limitDisplay:d,limitVisibility:f,showLimitRing:p,children:m,className:h,...g}){let{frame:_,attributes:v}=n.r(g);return t.t(g,u),(0,r.useEffect)(()=>{if(_&&l!==void 0)return _.reportCount(l),()=>_.reportCount(void 0)},[_,l]),_?(0,i.jsx)(`div`,{...v,className:h,children:m}):(0,i.jsx)(e.t,{label:a,hint:o,error:s,isRequired:c,count:l,limit:u,limitDisplay:d,limitVisibility:f,showLimitRing:p,isGroup:!0,className:h,groupBinding:n.t(g),children:()=>m})}Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return a}});
|
|
2
|
+
//# sourceMappingURL=group-QSnlx4jX.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group-
|
|
1
|
+
{"version":3,"file":"group-QSnlx4jX.cjs","names":["useGroupBinding","FieldFrame","fieldAttributes","require_frame","require_useLimit","require_binding","react","react_jsx_runtime","FieldGroup","binding","limit","frame","count","attributes","children"],"sources":["../../src/components/Field/group.tsx"],"sourcesContent":["import { useEffect, type ReactNode } from \"react\";\nimport { FieldFrame } from \"./frame\";\nimport { fieldAttributes, useGroupBinding } from \"./binding\";\nimport type { FieldBinding, FieldProps } from \"./types\";\nimport { useReportedLimit } from \"./useLimit\";\n\nexport interface FieldGroupProps extends FieldBinding, Omit<FieldProps, \"children\" | \"isGroup\"> {\n children: ReactNode;\n className?: string;\n}\n\n/**\n * Standalone groups render their own Field frame. Bound to an enclosing Field,\n * they render only their controls and report their count to its label.\n */\nexport function FieldGroup({\n label,\n hint,\n error,\n isRequired,\n count,\n limit,\n limitDisplay,\n limitVisibility,\n showLimitRing,\n children,\n className,\n ...binding\n}: FieldGroupProps) {\n const { frame, attributes } = useGroupBinding(binding);\n useReportedLimit(binding, limit);\n useEffect(() => {\n if (!frame || count === undefined) {\n return;\n }\n frame.reportCount(count);\n return () => frame.reportCount(undefined);\n }, [frame, count]);\n if (frame) {\n return (\n <div\n {...attributes}\n className={className}\n >\n {children}\n </div>\n );\n }\n return (\n <FieldFrame\n label={label}\n hint={hint}\n error={error}\n isRequired={isRequired}\n count={count}\n limit={limit}\n limitDisplay={limitDisplay}\n limitVisibility={limitVisibility}\n showLimitRing={showLimitRing}\n isGroup\n className={className}\n groupBinding={fieldAttributes(binding)}\n >\n {() => children}\n </FieldFrame>\n );\n}\n"],"mappings":"A,uKAeA,SAAgBQ,EAAW,CACzB,QACA,OACA,QACA,aACA,QACA,QACA,eACA,kBACA,gBACA,WACA,YACA,GAAGC,GACe,CAClB,GAAM,CAAE,QAAO,cAAeT,EAAAA,EAAgBS,CAAO,EAmBrD,OAlBAL,EAAA,EAAiBK,EAASC,CAAK,GAC/B,EAAAJ,EAAA,UAAA,KAAgB,CACd,GAAKK,GAASC,IAAU,IAAA,GAIxB,OADAD,EAAM,YAAYC,CAAK,MACVD,EAAM,YAAY,IAAA,EAAS,CAC1C,EAAG,CAACA,EAAOC,CAAK,CAAC,EACbD,GAEA,EAAAJ,EAAA,IAAA,CAAC,MAAD,CACE,GAAIM,EACO,YAEV,UACE,CAAA,GAIP,EAAAN,EAAA,IAAA,CAACN,EAAAA,EAAD,CACS,QACD,OACC,QACK,aACL,QACA,QACO,eACG,kBACF,gBACf,QAAA,GACW,YACX,aAAcC,EAAAA,EAAgBO,CAAO,EAE9B,aAAAK,CACG,CAAA,CAEhB,C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/group-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/group-QSnlx4jX.cjs"),t=require("../Grid/index.cjs");let n=require("react"),r=require("react/jsx-runtime");var i=(0,n.forwardRef)(function({isIndeterminate:e=!1,className:t,children:i,...a},o){let s=(0,n.useRef)(null);return(0,n.useEffect)(()=>{s.current&&(s.current.indeterminate=e)},[e]),(0,r.jsxs)(`label`,{className:[`ds-choice`,t].filter(Boolean).join(` `),children:[(0,r.jsx)(`input`,{type:`checkbox`,className:`ds-choice__control`,"data-kind":`checkbox`,ref:e=>{s.current=e,typeof o==`function`?o(e):o&&(o.current=e)},...a}),i&&(0,r.jsx)(`span`,{className:`ds-choice__label`,children:i})]})}),a=(0,n.forwardRef)(function({className:e,children:t,...n},i){return(0,r.jsxs)(`label`,{className:[`ds-choice`,e].filter(Boolean).join(` `),children:[(0,r.jsx)(`input`,{ref:i,type:`radio`,className:`ds-choice__control`,"data-kind":`radio`,...n}),t&&(0,r.jsx)(`span`,{className:`ds-choice__label`,children:t})]})});function o({label:n,columns:i=1,children:a,className:o,...s}){return(0,r.jsx)(e.t,{...s,label:n,className:[`ds-choice-group`,o].filter(Boolean).join(` `),children:i===1?(0,r.jsx)(t.Stack,{gap:`sm`,children:a}):(0,r.jsx)(t.Grid,{columns:i,gap:`sm`,className:`ds-choice-group__grid ds-field-group-grid`,style:{"--field-group-columns":i},children:a})})}exports.Checkbox=i,exports.ChoiceGroup=o,exports.Radio=a;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "../../chunks/group-
|
|
1
|
+
import { t as e } from "../../chunks/group-C6EOgTgM.js";
|
|
2
2
|
import { Grid as t, Stack as n } from "../Grid/index.js";
|
|
3
3
|
import { forwardRef as r, useEffect as i, useRef as a } from "react";
|
|
4
4
|
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type TableEmptyProps } from "../Table/index.cjs";
|
|
2
|
+
import type { CollectionEmptyKind } from "./types.cjs";
|
|
3
|
+
export interface CollectionEmptyProps extends Pick<TableEmptyProps, "icon" | "description" | "action"> {
|
|
4
|
+
kind: CollectionEmptyKind;
|
|
5
|
+
/** Plural noun for the no-match title, e.g. "entries". */
|
|
6
|
+
noun: string;
|
|
7
|
+
/** Shown when the collection itself has no items. */
|
|
8
|
+
title: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* What a searchable collection's frame shows instead of its table: how to
|
|
12
|
+
* start an empty collection, or a pointer back to the search field.
|
|
13
|
+
*/
|
|
14
|
+
export declare function CollectionEmpty({ kind, noun, icon, title, description, action, }: CollectionEmptyProps): import("react").JSX.Element;
|
|
15
|
+
//# sourceMappingURL=empty.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"empty.d.cts","sourceRoot":"","sources":["../../../src/components/CollectionView/empty.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAChD,eAAe,EACf,MAAM,GAAG,aAAa,GAAG,QAAQ,CAClC;IACC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,WAAW,EACX,MAAM,GACP,EAAE,oBAAoB,+BAkBtB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type TableEmptyProps } from "../Table/index.js";
|
|
2
|
+
import type { CollectionEmptyKind } from "./types.js";
|
|
3
|
+
export interface CollectionEmptyProps extends Pick<TableEmptyProps, "icon" | "description" | "action"> {
|
|
4
|
+
kind: CollectionEmptyKind;
|
|
5
|
+
/** Plural noun for the no-match title, e.g. "entries". */
|
|
6
|
+
noun: string;
|
|
7
|
+
/** Shown when the collection itself has no items. */
|
|
8
|
+
title: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* What a searchable collection's frame shows instead of its table: how to
|
|
12
|
+
* start an empty collection, or a pointer back to the search field.
|
|
13
|
+
*/
|
|
14
|
+
export declare function CollectionEmpty({ kind, noun, icon, title, description, action, }: CollectionEmptyProps): import("react").JSX.Element;
|
|
15
|
+
//# sourceMappingURL=empty.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"empty.d.ts","sourceRoot":"","sources":["../../../src/components/CollectionView/empty.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAChD,eAAe,EACf,MAAM,GAAG,aAAa,GAAG,QAAQ,CAClC;IACC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,WAAW,EACX,MAAM,GACP,EAAE,oBAAoB,+BAkBtB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CollectionViewProps } from "./types.cjs";
|
|
2
|
+
type FiltersProps = Pick<CollectionViewProps, "title" | "query" | "onQueryChange" | "filter" | "mine" | "view" | "actions">;
|
|
3
|
+
/** Search and view controls for a collection without an active selection. */
|
|
4
|
+
export declare function CollectionFilters({ title, query, onQueryChange, filter, mine, view, actions, }: FiltersProps): import("react").JSX.Element;
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=filters.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filters.d.cts","sourceRoot":"","sources":["../../../src/components/CollectionView/filters.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,KAAK,YAAY,GAAG,IAAI,CACtB,mBAAmB,EACnB,OAAO,GAAG,OAAO,GAAG,eAAe,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAC7E,CAAC;AAEF,6EAA6E;AAC7E,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EACL,KAAK,EACL,aAAa,EACb,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,OAAO,GACR,EAAE,YAAY,+BA8Dd"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CollectionViewProps } from "./types.js";
|
|
2
|
+
type FiltersProps = Pick<CollectionViewProps, "title" | "query" | "onQueryChange" | "filter" | "mine" | "view" | "actions">;
|
|
3
|
+
/** Search and view controls for a collection without an active selection. */
|
|
4
|
+
export declare function CollectionFilters({ title, query, onQueryChange, filter, mine, view, actions, }: FiltersProps): import("react").JSX.Element;
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=filters.d.ts.map
|