shadcn-settings 0.1.45 → 0.1.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +13 -9
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("react");c=s(c,1);let l=require("clsx"),u=require("tailwind-merge"),d=require("class-variance-authority"),f=require("react/jsx-runtime"),p=require("lucide-react"),m=require("@radix-ui/react-select");m=s(m,1);let h=require("@radix-ui/react-switch");h=s(h,1);function g(...e){return(0,u.twMerge)((0,l.clsx)(e))}var _=(0,d.cva)(`scroll-mt-4 transition-colors`,{variants:{variant:{card:`rounded-xl border border-border bg-card/80 p-4 lg:p-6`,inline:`rounded-lg border border-border bg-card/50 px-4 py-3`,ghost:`py-2`}},defaultVariants:{variant:`card`}});function v({links:e}){return e?.length?(0,f.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-2`,children:e.map(e=>(0,f.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-[11px] text-blue-500 underline hover:text-blue-600 dark:text-blue-400 dark:hover:text-blue-300 lg:text-xs`,children:e.name},e.url))}):null}function y({title:e,description:t,links:n,titleAddon:r,classNames:i}){return(0,f.jsxs)(`div`,{className:g(i?.header),children:[(0,f.jsxs)(`h4`,{className:g(`flex items-center gap-1.5 text-sm text-foreground`,i?.title),children:[e,r]}),t?(0,f.jsx)(`p`,{className:g(`text-[11px] text-muted-foreground lg:text-xs`,i?.description),children:t}):null,(0,f.jsx)(v,{links:n})]})}function b({anchorId:e,title:t,description:n,links:r,titleAddon:i,classNames:a,variant:o,layout:s=`stacked`,children:c}){let l=(0,f.jsx)(y,{title:t,description:n,links:r,titleAddon:i,classNames:a});return(0,f.jsx)(`section`,{id:e,className:g(_({variant:o}),a?.root),children:s===`row`?(0,f.jsxs)(`div`,{className:`flex w-full flex-row items-center justify-between gap-3 lg:gap-5`,children:[l,(0,f.jsx)(`div`,{className:g(`flex-shrink-0`,a?.control),children:c})]}):(0,f.jsxs)(`div`,{className:`space-y-3 lg:space-y-5`,children:[l,(0,f.jsx)(`div`,{className:g(`relative`,a?.control),children:c})]})})}function x(e){let[t,n]=c.useState(!1),r=c.useRef(!0);return c.useEffect(()=>(r.current=!0,()=>{r.current=!1}),[]),{committing:t,commit:c.useCallback(async t=>{if(e){n(!0);try{await e(t)}finally{window.setTimeout(()=>{r.current&&n(!1)},150)}}},[e])}}var S=`w-full rounded-lg border border-input bg-background px-3 py-2 pr-10 !text-xs text-foreground placeholder:text-muted-foreground transition-colors focus-visible:outline-none focus-visible:border-ring disabled:cursor-not-allowed disabled:opacity-60 lg:px-4 lg:py-3 lg:!text-[13px]`;function C({field:e,value:t,onChange:n,onCommit:r,variant:i,anchorId:a,titleAddon:o,classNames:s,disabled:l,multiline:u=!1,secret:d=!1}){let{committing:m,commit:h}=x(r),[_,v]=c.useState(!1),y=typeof e.default==`string`?e.default:``,C=t??y,w=l||m,
|
|
1
|
+
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("react");c=s(c,1);let l=require("clsx"),u=require("tailwind-merge"),d=require("class-variance-authority"),f=require("react/jsx-runtime"),p=require("lucide-react"),m=require("@radix-ui/react-select");m=s(m,1);let h=require("@radix-ui/react-switch");h=s(h,1);function g(...e){return(0,u.twMerge)((0,l.clsx)(e))}var _=(0,d.cva)(`scroll-mt-4 transition-colors`,{variants:{variant:{card:`rounded-xl border border-border bg-card/80 p-4 lg:p-6`,inline:`rounded-lg border border-border bg-card/50 px-4 py-3`,ghost:`py-2`}},defaultVariants:{variant:`card`}});function v({links:e}){return e?.length?(0,f.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-2`,children:e.map(e=>(0,f.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-[11px] text-blue-500 underline hover:text-blue-600 dark:text-blue-400 dark:hover:text-blue-300 lg:text-xs`,children:e.name},e.url))}):null}function y({title:e,description:t,links:n,titleAddon:r,classNames:i}){return(0,f.jsxs)(`div`,{className:g(i?.header),children:[(0,f.jsxs)(`h4`,{className:g(`flex items-center gap-1.5 text-sm text-foreground`,i?.title),children:[e,r]}),t?(0,f.jsx)(`p`,{className:g(`text-[11px] text-muted-foreground lg:text-xs`,i?.description),children:t}):null,(0,f.jsx)(v,{links:n})]})}function b({anchorId:e,title:t,description:n,links:r,titleAddon:i,classNames:a,variant:o,layout:s=`stacked`,children:c}){let l=(0,f.jsx)(y,{title:t,description:n,links:r,titleAddon:i,classNames:a});return(0,f.jsx)(`section`,{id:e,className:g(_({variant:o}),a?.root),children:s===`row`?(0,f.jsxs)(`div`,{className:`flex w-full flex-row items-center justify-between gap-3 lg:gap-5`,children:[l,(0,f.jsx)(`div`,{className:g(`flex-shrink-0`,a?.control),children:c})]}):(0,f.jsxs)(`div`,{className:`space-y-3 lg:space-y-5`,children:[l,(0,f.jsx)(`div`,{className:g(`relative`,a?.control),children:c})]})})}function x(e){let[t,n]=c.useState(!1),r=c.useRef(!0);return c.useEffect(()=>(r.current=!0,()=>{r.current=!1}),[]),{committing:t,commit:c.useCallback(async t=>{if(e){n(!0);try{await e(t)}finally{window.setTimeout(()=>{r.current&&n(!1)},150)}}},[e])}}var S=`w-full rounded-lg border border-input bg-background px-3 py-2 pr-10 !text-xs text-foreground placeholder:text-muted-foreground transition-colors focus-visible:outline-none focus-visible:border-ring disabled:cursor-not-allowed disabled:opacity-60 lg:px-4 lg:py-3 lg:!text-[13px]`;function C({field:e,value:t,onChange:n,onCommit:r,variant:i,anchorId:a,titleAddon:o,classNames:s,disabled:l,multiline:u=!1,secret:d=!1}){let{committing:m,commit:h}=x(r),[_,v]=c.useState(!1),y=typeof e.default==`string`?e.default:``,C=t??y,[w,T]=c.useState(C),[E,D]=c.useState(C);C!==E&&(D(C),T(C));let O=w,k=l||m,A=e=>{T(e),n?.(e)},j=e=>h(e);return(0,f.jsxs)(b,{anchorId:a,title:e.name,description:e.description,links:e.links,titleAddon:o,classNames:s,variant:i,children:[u?(0,f.jsx)(`textarea`,{value:O,onChange:e=>A(e.target.value),onBlur:e=>j(e.target.value),placeholder:e.placeholder,rows:typeof e.rows==`number`?e.rows:4,disabled:k,className:S}):(0,f.jsx)(`input`,{value:O,onChange:e=>A(e.target.value),onBlur:e=>j(e.target.value),placeholder:e.placeholder,type:d&&!_?`password`:`text`,disabled:k,className:g(S,d&&`pr-16`)}),d&&!u?(0,f.jsx)(`button`,{type:`button`,onClick:()=>v(e=>!e),title:_?`Hide`:`Show`,className:`absolute right-3 top-1/2 -translate-y-1/2 p-1 text-muted-foreground transition-colors hover:text-foreground`,children:_?(0,f.jsx)(p.EyeOff,{className:`h-4 w-4`}):(0,f.jsx)(p.Eye,{className:`h-4 w-4`})}):null,m?(0,f.jsx)(`span`,{className:g(`pointer-events-none absolute text-muted-foreground`,u?`right-3 translate-y-3`:`top-1/2 -translate-y-1/2`,d&&!u?`right-8`:`right-3`),children:(0,f.jsx)(p.Loader2,{className:`h-4 w-4 animate-spin`})}):null]})}function w(e){return(0,f.jsx)(C,{...e})}function T(e){return(0,f.jsx)(C,{...e,secret:!0})}function E(e){return(0,f.jsx)(C,{...e,multiline:!0})}var D=m.Root,O=m.Group,k=m.Value,A=c.forwardRef(({className:e,children:t,...n},r)=>(0,f.jsxs)(m.Trigger,{ref:r,className:g(`flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-background px-3 py-2 text-sm shadow-sm`,`placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring`,`disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1`,e),...n,children:[t,(0,f.jsx)(m.Icon,{asChild:!0,children:(0,f.jsx)(p.ChevronDown,{className:`h-4 w-4 opacity-50`})})]}));A.displayName=m.Trigger.displayName;var j=c.forwardRef(({className:e,...t},n)=>(0,f.jsx)(m.ScrollUpButton,{ref:n,className:g(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,f.jsx)(p.ChevronUp,{className:`h-4 w-4`})}));j.displayName=m.ScrollUpButton.displayName;var M=c.forwardRef(({className:e,...t},n)=>(0,f.jsx)(m.ScrollDownButton,{ref:n,className:g(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,f.jsx)(p.ChevronDown,{className:`h-4 w-4`})}));M.displayName=m.ScrollDownButton.displayName;var N=c.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,f.jsx)(m.Portal,{children:(0,f.jsxs)(m.Content,{ref:i,className:g(`relative z-50 max-h-72 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,f.jsx)(j,{}),(0,f.jsx)(m.Viewport,{className:g(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`),children:t}),(0,f.jsx)(M,{})]})}));N.displayName=m.Content.displayName;var P=c.forwardRef(({className:e,children:t,...n},r)=>(0,f.jsxs)(m.Item,{ref:r,className:g(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none`,`focus:bg-accent focus:text-accent-foreground`,`data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:[(0,f.jsx)(`span`,{className:`absolute right-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,f.jsx)(m.ItemIndicator,{children:(0,f.jsx)(p.Check,{className:`h-4 w-4`})})}),(0,f.jsx)(m.ItemText,{children:t})]}));P.displayName=m.Item.displayName;function F({field:e,value:t,onChange:n,onCommit:r,variant:i,anchorId:a,titleAddon:o,classNames:s,disabled:c}){let{committing:l,commit:u}=x(r),d=typeof e.default==`string`?e.default:void 0,p=t??d,m=(e.options??[]).filter(e=>e.value!==``);return(0,f.jsx)(b,{anchorId:a,title:e.name,description:e.description,links:e.links,titleAddon:o,classNames:s,variant:i,children:(0,f.jsxs)(D,{value:p,onValueChange:e=>{n?.(e),u(e)},disabled:c||l,children:[(0,f.jsx)(A,{className:`w-full`,children:(0,f.jsx)(k,{placeholder:`Select an option`})}),(0,f.jsx)(N,{children:m.map(e=>(0,f.jsx)(P,{value:e.value,children:e.name},e.value))})]})})}var I=c.forwardRef(({className:e,...t},n)=>(0,f.jsx)(h.Root,{ref:n,className:g(`peer inline-flex h-[1.15rem] w-8 shrink-0 cursor-pointer items-center rounded-full border border-transparent shadow-sm transition-colors outline-none`,`focus-visible:ring-2 focus-visible:ring-ring/50`,`data-[state=checked]:bg-primary data-[state=unchecked]:bg-input`,`disabled:cursor-not-allowed disabled:opacity-50`,e),...t,children:(0,f.jsx)(h.Thumb,{className:g(`pointer-events-none block size-4 rounded-full bg-background shadow-sm ring-0 transition-transform`,`data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0`)})}));I.displayName=`Switch`;function L({field:e,value:t,onChange:n,onCommit:r,variant:i,anchorId:a,titleAddon:o,classNames:s,disabled:c}){let{committing:l,commit:u}=x(r),d=t===!0||t===`true`||t===void 0&&e.default===!0;return(0,f.jsx)(b,{anchorId:a,title:e.name,description:e.description,links:e.links,titleAddon:o,classNames:s,variant:i,layout:`row`,children:(0,f.jsx)(I,{checked:d,onCheckedChange:e=>{n?.(e),u(e)},disabled:c||l,className:`h-6 w-12`})})}var R={string:w,password:T,textarea:E,select:F,switch:L};function z({field:e,variant:t,anchorId:n,classNames:r}){return(0,f.jsx)(b,{anchorId:n,title:e.name,description:e.description,classNames:r,variant:t,children:(0,f.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Unsupported field type: `,String(e.type)]})})}function B({renderers:e,...t}){let n=c.useMemo(()=>({...R,...e}),[e]),r=n[t.field.type]??n.unknown??z;return(0,f.jsx)(r,{...t})}function V({fields:e,getValue:t,onCommit:n,onChange:r,variant:i,renderers:a,anchorId:o,renderTitleAddon:s,classNames:c,className:l}){return(0,f.jsx)(`div`,{className:g(`flex-1 space-y-6 overflow-y-auto px-6 py-6`,l),children:e.map(e=>(0,f.jsx)(B,{field:e,value:t(e),onChange:r?t=>r(e,t):void 0,onCommit:t=>n(e,t),variant:i,renderers:a,anchorId:o?.(e),titleAddon:s?.(e),classNames:c},e.key))})}exports.FieldShell=b,exports.PasswordField=T,exports.Select=D,exports.SelectContent=N,exports.SelectField=F,exports.SelectGroup=O,exports.SelectItem=P,exports.SelectTrigger=A,exports.SelectValue=k,exports.SettingsField=B,exports.SettingsList=V,exports.StringField=w,exports.Switch=I,exports.SwitchField=L,exports.TextareaField=E,exports.builtinRenderers=R,exports.cn=g,exports.useCommit=x;
|
package/dist/index.mjs
CHANGED
|
@@ -101,7 +101,11 @@ function y(t) {
|
|
|
101
101
|
//#region src/components/fields/text-field.tsx
|
|
102
102
|
var b = "w-full rounded-lg border border-input bg-background px-3 py-2 pr-10 !text-xs text-foreground placeholder:text-muted-foreground transition-colors focus-visible:outline-none focus-visible:border-ring disabled:cursor-not-allowed disabled:opacity-60 lg:px-4 lg:py-3 lg:!text-[13px]";
|
|
103
103
|
function x({ field: t, value: n, onChange: r, onCommit: o, variant: s, anchorId: c, titleAddon: f, classNames: p, disabled: h, multiline: g = !1, secret: _ = !1 }) {
|
|
104
|
-
let { committing: x, commit: S } = y(o), [C, w] = e.useState(!1), T = typeof t.default == "string" ? t.default : "", E = n ?? T, D
|
|
104
|
+
let { committing: x, commit: S } = y(o), [C, w] = e.useState(!1), T = typeof t.default == "string" ? t.default : "", E = n ?? T, [D, O] = e.useState(E), [k, A] = e.useState(E);
|
|
105
|
+
E !== k && (A(E), O(E));
|
|
106
|
+
let j = D, M = h || x, N = (e) => {
|
|
107
|
+
O(e), r?.(e);
|
|
108
|
+
}, P = (e) => S(e);
|
|
105
109
|
return /* @__PURE__ */ a(v, {
|
|
106
110
|
anchorId: c,
|
|
107
111
|
title: t.name,
|
|
@@ -112,20 +116,20 @@ function x({ field: t, value: n, onChange: r, onCommit: o, variant: s, anchorId:
|
|
|
112
116
|
variant: s,
|
|
113
117
|
children: [
|
|
114
118
|
g ? /* @__PURE__ */ i("textarea", {
|
|
115
|
-
value:
|
|
116
|
-
onChange: (e) =>
|
|
117
|
-
onBlur: (e) =>
|
|
119
|
+
value: j,
|
|
120
|
+
onChange: (e) => N(e.target.value),
|
|
121
|
+
onBlur: (e) => P(e.target.value),
|
|
118
122
|
placeholder: t.placeholder,
|
|
119
123
|
rows: typeof t.rows == "number" ? t.rows : 4,
|
|
120
|
-
disabled:
|
|
124
|
+
disabled: M,
|
|
121
125
|
className: b
|
|
122
126
|
}) : /* @__PURE__ */ i("input", {
|
|
123
|
-
value:
|
|
124
|
-
onChange: (e) =>
|
|
125
|
-
onBlur: (e) =>
|
|
127
|
+
value: j,
|
|
128
|
+
onChange: (e) => N(e.target.value),
|
|
129
|
+
onBlur: (e) => P(e.target.value),
|
|
126
130
|
placeholder: t.placeholder,
|
|
127
131
|
type: _ && !C ? "password" : "text",
|
|
128
|
-
disabled:
|
|
132
|
+
disabled: M,
|
|
129
133
|
className: m(b, _ && "pr-16")
|
|
130
134
|
}),
|
|
131
135
|
_ && !g ? /* @__PURE__ */ i("button", {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shadcn-settings",
|
|
3
3
|
"description": "Prop-driven, schema-based settings form renderer built on shadcn/ui — string, password, textarea, select and switch field variants with card, inline and ghost layouts",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.47",
|
|
5
5
|
"author": "vtempest",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|