@zapatran/paper-ember-components 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),m=require("react");var d={btn:{root:(e,a,l=[])=>{const r=`btn btn--${e} btn--${a}`,o=l.map(n=>`btn--${n}`).join(" ");return o?`${r} ${o}`:r},elements:{label:"btn__label",icon:"btn__icon",kbd:"btn__kbd"}},badge:{root:(e,a="soft",l="sm",r=[])=>{const o=`badge badge--${a} badge--${e} badge--${l}`,n=r.map(s=>`badge--${s}`).join(" ");return n?`${o} ${n}`:o},elements:{dot:"badge__dot",icon:"badge__icon",label:"badge__label",close:"badge__close"}},alert:{root:e=>`alert alert--${e}`,elements:{icon:"alert__icon",body:"alert__body",title:"alert__title",text:"alert__text",close:"alert__close",action:"alert__action"}},card:{root:"card",elements:{header:"card__header",title:"card__title",meta:"card__meta",kpi:"card__kpi",trend:e=>`card__trend card__trend--${e}`,chart:"card__chart",avatar:"card__avatar"}},table:{wrap:"table-wrap",root:e=>e?"table table--stripe":"table",elements:{th:e=>e==="right"?"table__th table__th--right":"table__th",td:"table__td",tdFoot:"table__td--foot",tdNum:"table__td--num"}},field:{root:"field",elements:{label:"field__label",helper:"field__helper",error:"field__error",inputWrap:"field__input-wrap",inputIcon:"field__input-icon"}},input:{root:e=>e?"input input--error":"input"},textarea:{root:"textarea"},select:{wrap:"select-wrap",root:"select",elements:{arrow:"select-wrap__arrow"}},checkbox:{root:"checkbox",elements:{box:e=>e?"checkbox__box checkbox__box--checked":"checkbox__box",check:"checkbox__check",label:"checkbox__label"}},radio:{root:"radio",elements:{circle:e=>e?"radio__circle radio__circle--selected":"radio__circle",label:"radio__label"}},switch:{root:e=>e?"switch switch--on":"switch",elements:{thumb:"switch__thumb"}}};function T({variant:e="info",title:a,description:l,icon:r,onClose:o,action:n,className:s}){const{root:i,elements:c}=d.alert,u=[i(e),s].filter(Boolean).join(" ");return t.jsxs("div",{className:u,role:"alert",children:[r&&t.jsx("span",{className:c.icon,"aria-hidden":"true",children:r}),t.jsxs("div",{className:c.body,children:[a&&t.jsx("p",{className:c.title,children:a}),l&&t.jsx("p",{className:c.text,children:l})]}),n&&t.jsx("button",{className:c.action,onClick:n.onClick,type:"button",children:n.label}),o&&t.jsx("button",{className:c.close,onClick:o,type:"button","aria-label":"Dismiss",children:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",stroke:"currentColor",strokeWidth:"2",children:t.jsx("path",{d:"M2 2l8 8M10 2l-8 8"})})})]})}function $({variant:e="neutral",appearance:a="soft",size:l="sm",shape:r,className:o,...n}){const{root:s,elements:i}=d.badge;if("value"in n&&n.value!==void 0){const{value:p,max:v=99}=n,g=p>v?`${v}+`:String(p),N=["count"];r&&N.push(r);const I=[s(e,a,l,N),o].filter(Boolean).join(" ");return t.jsx("span",{className:I,children:g})}const{children:c,dot:u,icon:b,onClose:x}=n,_=[];r&&_.push(r),x&&_.push("removable");const f=[s(e,a,l,_),o].filter(Boolean).join(" ");return t.jsxs("span",{className:f,children:[u&&t.jsx("span",{className:i.dot,"aria-hidden":"true"}),b&&t.jsx("span",{className:i.icon,"aria-hidden":"true",children:b}),t.jsx("span",{className:i.label,children:c}),x&&t.jsx("button",{className:i.close,onClick:x,type:"button","aria-label":"Remove",children:t.jsx("svg",{viewBox:"0 0 8 8",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",children:t.jsx("path",{d:"M1 1l6 6M7 1L1 7"})})})]})}function F({variant:e="primary",size:a="md",children:l,disabled:r,onClick:o,type:n="button",className:s,loading:i,icon:c,kbd:u,iconOnly:b,"aria-label":x}){const{root:_,elements:f}=d.btn,p=[];b&&p.push("icon"),i&&p.push("loading");const v=[_(e,a,p),s].filter(Boolean).join(" ");return t.jsxs("button",{className:v,disabled:r||i,onClick:o,type:n,"aria-label":x,"aria-busy":i||void 0,children:[i?t.jsx("svg",{className:"btn__spinner",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}):c?t.jsx("span",{className:f.icon,"aria-hidden":"true",children:c}):null,!b&&t.jsx("span",{className:f.label,children:l}),!b&&u&&t.jsx("kbd",{className:f.kbd,children:u})]})}function L({header:e,title:a,meta:l,kpi:r,trend:o,chart:n,avatar:s,children:i,className:c}){const{root:u,elements:b}=d.card,x=[u,c].filter(Boolean).join(" ");return t.jsxs("div",{className:x,children:[(e||s)&&t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[e&&t.jsx("p",{className:b.header,children:e}),s!==void 0&&t.jsx("span",{className:b.avatar,children:s})]}),a&&t.jsx("p",{className:b.title,children:a}),l&&t.jsx("p",{className:b.meta,children:l}),r!==void 0&&t.jsx("p",{className:b.kpi,children:r}),o&&t.jsxs("div",{className:b.trend(o.direction),children:[o.direction==="up"?t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M6 9V3M3 6l3-3 3 3"})}):t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M6 3v6M3 6l3 3 3-3"})}),o.label]}),n&&t.jsx("div",{className:b.chart,children:n}),i]})}const h=(...e)=>e.filter(Boolean).join(" "),w={position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0},C=m.createContext(null),j=()=>m.useContext(C);function M({id:e,invalid:a=!1,disabled:l=!1,children:r,className:o}){const n=m.useId(),s=e??n,i={fieldId:s,describedById:`${s}-desc`,invalid:a,disabled:l};return t.jsx(C.Provider,{value:i,children:t.jsx("div",{className:h(d.field.root,o),children:r})})}function S({children:e,htmlFor:a,className:l}){const r=j();return t.jsx("label",{className:h(d.field.elements.label,l),htmlFor:a??(r==null?void 0:r.fieldId),children:e})}function R({children:e,className:a}){const l=j();return t.jsx("p",{className:h(d.field.elements.helper,a),id:l==null?void 0:l.describedById,children:e})}function W({children:e,className:a}){const l=j();return t.jsx("p",{className:h(d.field.elements.error,a),id:l==null?void 0:l.describedById,role:"alert",children:e})}function H({error:e,icon:a,className:l,id:r,disabled:o,...n}){const s=j(),i=e??(s==null?void 0:s.invalid)??!1,c=t.jsx("input",{id:r??(s==null?void 0:s.fieldId),className:h(d.input.root(i),l),disabled:o??(s==null?void 0:s.disabled),"aria-invalid":i||void 0,"aria-describedby":s==null?void 0:s.describedById,...n});return a?t.jsxs("div",{className:d.field.elements.inputWrap,children:[c,t.jsx("span",{className:d.field.elements.inputIcon,"aria-hidden":"true",children:a})]}):c}function P({error:e,className:a,id:l,disabled:r,rows:o=4,...n}){const s=j(),i=e??(s==null?void 0:s.invalid)??!1;return t.jsx("textarea",{id:l??(s==null?void 0:s.fieldId),className:h(d.textarea.root,a),rows:o,disabled:r??(s==null?void 0:s.disabled),"aria-invalid":i||void 0,"aria-describedby":s==null?void 0:s.describedById,...n})}function G({error:e,className:a,id:l,disabled:r,children:o,...n}){const s=j(),i=e??(s==null?void 0:s.invalid)??!1;return t.jsxs("div",{className:d.select.wrap,children:[t.jsx("select",{id:l??(s==null?void 0:s.fieldId),className:h(d.select.root,a),disabled:r??(s==null?void 0:s.disabled),"aria-invalid":i||void 0,"aria-describedby":s==null?void 0:s.describedById,...n,children:o}),t.jsx("svg",{className:d.select.elements.arrow,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M4 6l4 4 4-4"})})]})}function y(e,a,l){const[r,o]=m.useState(a),n=e!==void 0,s=n?e:r,i=m.useCallback(c=>{n||o(c),l==null||l(c)},[n,l]);return[s,i]}function q({checked:e,defaultChecked:a=!1,onChange:l,disabled:r,name:o,value:n,children:s,className:i}){const[c,u]=y(e,a,l);return t.jsxs("label",{className:h(d.checkbox.root,i),style:r?{cursor:"not-allowed",opacity:.6}:void 0,children:[t.jsx("input",{type:"checkbox",style:w,checked:c,onChange:b=>u(b.target.checked),disabled:r,name:o,value:n}),t.jsx("span",{className:d.checkbox.elements.box(c),"aria-hidden":"true",children:c&&t.jsx("svg",{className:d.checkbox.elements.check,viewBox:"0 0 12 12",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M2.5 6.5l2.5 2.5 4.5-5"})})}),s&&t.jsx("span",{className:d.checkbox.elements.label,children:s})]})}const B=m.createContext(null);function A({name:e,value:a,onChange:l,disabled:r,children:o,className:n}){return t.jsx(B.Provider,{value:{name:e,value:a,onChange:l,disabled:r},children:t.jsx("div",{role:"radiogroup",className:n,children:o})})}function D({value:e,children:a,disabled:l,className:r}){const o=m.useContext(B),n=(o==null?void 0:o.value)===e,s=l??(o==null?void 0:o.disabled);return t.jsxs("label",{className:h(d.radio.root,r),style:s?{cursor:"not-allowed",opacity:.6}:void 0,children:[t.jsx("input",{type:"radio",style:w,name:o==null?void 0:o.name,value:e,checked:n,onChange:()=>{var i;return(i=o==null?void 0:o.onChange)==null?void 0:i.call(o,e)},disabled:s}),t.jsx("span",{className:d.radio.elements.circle(n),"aria-hidden":"true"}),a&&t.jsx("span",{className:d.radio.elements.label,children:a})]})}function E({checked:e,defaultChecked:a=!1,onChange:l,disabled:r,id:o,className:n,"aria-label":s}){const[i,c]=y(e,a,l);return t.jsx("button",{type:"button",role:"switch",id:o,"aria-checked":i,"aria-label":s,disabled:r,onClick:()=>c(!i),className:h(d.switch.root(i),n),children:t.jsx("span",{className:d.switch.elements.thumb,"aria-hidden":"true"})})}const k=m.createContext("body");function V({stripe:e,children:a,className:l}){const{wrap:r,root:o}=d.table,n=[r,l].filter(Boolean).join(" ");return t.jsx("div",{className:n,children:t.jsx("table",{className:o(e),children:a})})}function U({children:e}){return t.jsx("thead",{children:e})}function J({children:e}){return t.jsx(k.Provider,{value:"body",children:t.jsx("tbody",{children:e})})}function K({children:e}){return t.jsx(k.Provider,{value:"foot",children:t.jsx("tfoot",{children:e})})}function O({children:e,className:a}){return t.jsx("tr",{className:a,children:e})}function Q({children:e,align:a,colSpan:l,className:r}){const{elements:o}=d.table,n=[o.th(a),r].filter(Boolean).join(" ");return t.jsx("th",{className:n,colSpan:l,scope:"col",children:e})}function X({children:e,num:a,colSpan:l,className:r}){const o=m.useContext(k),{elements:n}=d.table,i=[o==="foot"?n.tdFoot:n.td,a?n.tdNum:void 0,r].filter(Boolean).join(" ");return t.jsx("td",{className:i,colSpan:l,children:e})}exports.Alert=T;exports.Badge=$;exports.Button=F;exports.Card=L;exports.Checkbox=q;exports.Field=M;exports.FieldError=W;exports.FieldHelper=R;exports.Input=H;exports.Label=S;exports.Radio=D;exports.RadioGroup=A;exports.Select=G;exports.Switch=E;exports.Table=V;exports.TableBody=J;exports.TableFoot=K;exports.TableHead=U;exports.TableRow=O;exports.Td=X;exports.Textarea=P;exports.Th=Q;exports.useFieldContext=j;
package/dist/index.mjs ADDED
@@ -0,0 +1,523 @@
1
+ import { jsxs as u, jsx as o } from "react/jsx-runtime";
2
+ import C, { createContext as x, useId as F, useContext as B, useState as T, useCallback as W } from "react";
3
+ var d = {
4
+ btn: {
5
+ root: (e, a, n = []) => {
6
+ const r = `btn btn--${e} btn--${a}`, l = n.map((i) => `btn--${i}`).join(" ");
7
+ return l ? `${r} ${l}` : r;
8
+ },
9
+ elements: {
10
+ label: "btn__label",
11
+ icon: "btn__icon",
12
+ kbd: "btn__kbd"
13
+ }
14
+ },
15
+ badge: {
16
+ root: (e, a = "soft", n = "sm", r = []) => {
17
+ const l = `badge badge--${a} badge--${e} badge--${n}`, i = r.map((t) => `badge--${t}`).join(" ");
18
+ return i ? `${l} ${i}` : l;
19
+ },
20
+ elements: {
21
+ dot: "badge__dot",
22
+ icon: "badge__icon",
23
+ label: "badge__label",
24
+ close: "badge__close"
25
+ }
26
+ },
27
+ alert: {
28
+ root: (e) => `alert alert--${e}`,
29
+ elements: {
30
+ icon: "alert__icon",
31
+ body: "alert__body",
32
+ title: "alert__title",
33
+ text: "alert__text",
34
+ close: "alert__close",
35
+ action: "alert__action"
36
+ }
37
+ },
38
+ card: {
39
+ root: "card",
40
+ elements: {
41
+ header: "card__header",
42
+ title: "card__title",
43
+ meta: "card__meta",
44
+ kpi: "card__kpi",
45
+ trend: (e) => `card__trend card__trend--${e}`,
46
+ chart: "card__chart",
47
+ avatar: "card__avatar"
48
+ }
49
+ },
50
+ table: {
51
+ wrap: "table-wrap",
52
+ root: (e) => e ? "table table--stripe" : "table",
53
+ elements: {
54
+ th: (e) => e === "right" ? "table__th table__th--right" : "table__th",
55
+ td: "table__td",
56
+ tdFoot: "table__td--foot",
57
+ tdNum: "table__td--num"
58
+ }
59
+ },
60
+ field: {
61
+ root: "field",
62
+ elements: {
63
+ label: "field__label",
64
+ helper: "field__helper",
65
+ error: "field__error",
66
+ inputWrap: "field__input-wrap",
67
+ inputIcon: "field__input-icon"
68
+ }
69
+ },
70
+ input: {
71
+ root: (e) => e ? "input input--error" : "input"
72
+ },
73
+ textarea: {
74
+ root: "textarea"
75
+ },
76
+ select: {
77
+ wrap: "select-wrap",
78
+ root: "select",
79
+ elements: {
80
+ arrow: "select-wrap__arrow"
81
+ }
82
+ },
83
+ checkbox: {
84
+ root: "checkbox",
85
+ elements: {
86
+ box: (e) => e ? "checkbox__box checkbox__box--checked" : "checkbox__box",
87
+ check: "checkbox__check",
88
+ label: "checkbox__label"
89
+ }
90
+ },
91
+ radio: {
92
+ root: "radio",
93
+ elements: {
94
+ circle: (e) => e ? "radio__circle radio__circle--selected" : "radio__circle",
95
+ label: "radio__label"
96
+ }
97
+ },
98
+ switch: {
99
+ root: (e) => e ? "switch switch--on" : "switch",
100
+ elements: {
101
+ thumb: "switch__thumb"
102
+ }
103
+ }
104
+ };
105
+ function P({
106
+ variant: e = "info",
107
+ title: a,
108
+ description: n,
109
+ icon: r,
110
+ onClose: l,
111
+ action: i,
112
+ className: t
113
+ }) {
114
+ const { root: s, elements: c } = d.alert, h = [s(e), t].filter(Boolean).join(" ");
115
+ return /* @__PURE__ */ u("div", { className: h, role: "alert", children: [
116
+ r && /* @__PURE__ */ o("span", { className: c.icon, "aria-hidden": "true", children: r }),
117
+ /* @__PURE__ */ u("div", { className: c.body, children: [
118
+ a && /* @__PURE__ */ o("p", { className: c.title, children: a }),
119
+ n && /* @__PURE__ */ o("p", { className: c.text, children: n })
120
+ ] }),
121
+ i && /* @__PURE__ */ o("button", { className: c.action, onClick: i.onClick, type: "button", children: i.label }),
122
+ l && /* @__PURE__ */ o("button", { className: c.close, onClick: l, type: "button", "aria-label": "Dismiss", children: /* @__PURE__ */ o("svg", { width: "12", height: "12", viewBox: "0 0 12 12", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ o("path", { d: "M2 2l8 8M10 2l-8 8" }) }) })
123
+ ] });
124
+ }
125
+ function H({
126
+ variant: e = "neutral",
127
+ appearance: a = "soft",
128
+ size: n = "sm",
129
+ shape: r,
130
+ className: l,
131
+ ...i
132
+ }) {
133
+ const { root: t, elements: s } = d.badge;
134
+ if ("value" in i && i.value !== void 0) {
135
+ const { value: _, max: N = 99 } = i, L = _ > N ? `${N}+` : String(_), y = ["count"];
136
+ r && y.push(r);
137
+ const M = [t(e, a, n, y), l].filter(Boolean).join(" ");
138
+ return /* @__PURE__ */ o("span", { className: M, children: L });
139
+ }
140
+ const { children: c, dot: h, icon: b, onClose: p } = i, v = [];
141
+ r && v.push(r), p && v.push("removable");
142
+ const k = [t(e, a, n, v), l].filter(Boolean).join(" ");
143
+ return /* @__PURE__ */ u("span", { className: k, children: [
144
+ h && /* @__PURE__ */ o("span", { className: s.dot, "aria-hidden": "true" }),
145
+ b && /* @__PURE__ */ o("span", { className: s.icon, "aria-hidden": "true", children: b }),
146
+ /* @__PURE__ */ o("span", { className: s.label, children: c }),
147
+ p && /* @__PURE__ */ o("button", { className: s.close, onClick: p, type: "button", "aria-label": "Remove", children: /* @__PURE__ */ o("svg", { viewBox: "0 0 8 8", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", children: /* @__PURE__ */ o("path", { d: "M1 1l6 6M7 1L1 7" }) }) })
148
+ ] });
149
+ }
150
+ function D({
151
+ variant: e = "primary",
152
+ size: a = "md",
153
+ children: n,
154
+ disabled: r,
155
+ onClick: l,
156
+ type: i = "button",
157
+ className: t,
158
+ loading: s,
159
+ icon: c,
160
+ kbd: h,
161
+ iconOnly: b,
162
+ "aria-label": p
163
+ }) {
164
+ const { root: v, elements: k } = d.btn, _ = [];
165
+ b && _.push("icon"), s && _.push("loading");
166
+ const N = [v(e, a, _), t].filter(Boolean).join(" ");
167
+ return /* @__PURE__ */ u(
168
+ "button",
169
+ {
170
+ className: N,
171
+ disabled: r || s,
172
+ onClick: l,
173
+ type: i,
174
+ "aria-label": p,
175
+ "aria-busy": s || void 0,
176
+ children: [
177
+ s ? /* @__PURE__ */ o(
178
+ "svg",
179
+ {
180
+ className: "btn__spinner",
181
+ xmlns: "http://www.w3.org/2000/svg",
182
+ viewBox: "0 0 24 24",
183
+ fill: "none",
184
+ stroke: "currentColor",
185
+ strokeWidth: "2",
186
+ strokeLinecap: "round",
187
+ strokeLinejoin: "round",
188
+ children: /* @__PURE__ */ o("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" })
189
+ }
190
+ ) : c ? /* @__PURE__ */ o("span", { className: k.icon, "aria-hidden": "true", children: c }) : null,
191
+ !b && /* @__PURE__ */ o("span", { className: k.label, children: n }),
192
+ !b && h && /* @__PURE__ */ o("kbd", { className: k.kbd, children: h })
193
+ ]
194
+ }
195
+ );
196
+ }
197
+ function G({
198
+ header: e,
199
+ title: a,
200
+ meta: n,
201
+ kpi: r,
202
+ trend: l,
203
+ chart: i,
204
+ avatar: t,
205
+ children: s,
206
+ className: c
207
+ }) {
208
+ const { root: h, elements: b } = d.card, p = [h, c].filter(Boolean).join(" ");
209
+ return /* @__PURE__ */ u("div", { className: p, children: [
210
+ (e || t) && /* @__PURE__ */ u("div", { style: { display: "flex", alignItems: "flex-start", justifyContent: "space-between" }, children: [
211
+ e && /* @__PURE__ */ o("p", { className: b.header, children: e }),
212
+ t !== void 0 && /* @__PURE__ */ o("span", { className: b.avatar, children: t })
213
+ ] }),
214
+ a && /* @__PURE__ */ o("p", { className: b.title, children: a }),
215
+ n && /* @__PURE__ */ o("p", { className: b.meta, children: n }),
216
+ r !== void 0 && /* @__PURE__ */ o("p", { className: b.kpi, children: r }),
217
+ l && /* @__PURE__ */ u("div", { className: b.trend(l.direction), children: [
218
+ l.direction === "up" ? /* @__PURE__ */ o(
219
+ "svg",
220
+ {
221
+ width: "12",
222
+ height: "12",
223
+ viewBox: "0 0 12 12",
224
+ fill: "none",
225
+ stroke: "currentColor",
226
+ strokeWidth: 2,
227
+ strokeLinecap: "round",
228
+ strokeLinejoin: "round",
229
+ "aria-hidden": "true",
230
+ children: /* @__PURE__ */ o("path", { d: "M6 9V3M3 6l3-3 3 3" })
231
+ }
232
+ ) : /* @__PURE__ */ o(
233
+ "svg",
234
+ {
235
+ width: "12",
236
+ height: "12",
237
+ viewBox: "0 0 12 12",
238
+ fill: "none",
239
+ stroke: "currentColor",
240
+ strokeWidth: 2,
241
+ strokeLinecap: "round",
242
+ strokeLinejoin: "round",
243
+ "aria-hidden": "true",
244
+ children: /* @__PURE__ */ o("path", { d: "M6 3v6M3 6l3 3 3-3" })
245
+ }
246
+ ),
247
+ l.label
248
+ ] }),
249
+ i && /* @__PURE__ */ o("div", { className: b.chart, children: i }),
250
+ s
251
+ ] });
252
+ }
253
+ const m = (...e) => e.filter(Boolean).join(" "), g = {
254
+ position: "absolute",
255
+ width: 1,
256
+ height: 1,
257
+ padding: 0,
258
+ margin: -1,
259
+ overflow: "hidden",
260
+ clip: "rect(0 0 0 0)",
261
+ whiteSpace: "nowrap",
262
+ border: 0
263
+ }, j = x(null), f = () => B(j);
264
+ function V({ id: e, invalid: a = !1, disabled: n = !1, children: r, className: l }) {
265
+ const i = F(), t = e ?? i, s = {
266
+ fieldId: t,
267
+ describedById: `${t}-desc`,
268
+ invalid: a,
269
+ disabled: n
270
+ };
271
+ return /* @__PURE__ */ o(j.Provider, { value: s, children: /* @__PURE__ */ o("div", { className: m(d.field.root, l), children: r }) });
272
+ }
273
+ function A({ children: e, htmlFor: a, className: n }) {
274
+ const r = f();
275
+ return /* @__PURE__ */ o(
276
+ "label",
277
+ {
278
+ className: m(d.field.elements.label, n),
279
+ htmlFor: a ?? (r == null ? void 0 : r.fieldId),
280
+ children: e
281
+ }
282
+ );
283
+ }
284
+ function E({ children: e, className: a }) {
285
+ const n = f();
286
+ return /* @__PURE__ */ o("p", { className: m(d.field.elements.helper, a), id: n == null ? void 0 : n.describedById, children: e });
287
+ }
288
+ function U({ children: e, className: a }) {
289
+ const n = f();
290
+ return /* @__PURE__ */ o("p", { className: m(d.field.elements.error, a), id: n == null ? void 0 : n.describedById, role: "alert", children: e });
291
+ }
292
+ function q({ error: e, icon: a, className: n, id: r, disabled: l, ...i }) {
293
+ const t = f(), s = e ?? (t == null ? void 0 : t.invalid) ?? !1, c = /* @__PURE__ */ o(
294
+ "input",
295
+ {
296
+ id: r ?? (t == null ? void 0 : t.fieldId),
297
+ className: m(d.input.root(s), n),
298
+ disabled: l ?? (t == null ? void 0 : t.disabled),
299
+ "aria-invalid": s || void 0,
300
+ "aria-describedby": t == null ? void 0 : t.describedById,
301
+ ...i
302
+ }
303
+ );
304
+ return a ? /* @__PURE__ */ u("div", { className: d.field.elements.inputWrap, children: [
305
+ c,
306
+ /* @__PURE__ */ o("span", { className: d.field.elements.inputIcon, "aria-hidden": "true", children: a })
307
+ ] }) : c;
308
+ }
309
+ function J({ error: e, className: a, id: n, disabled: r, rows: l = 4, ...i }) {
310
+ const t = f(), s = e ?? (t == null ? void 0 : t.invalid) ?? !1;
311
+ return /* @__PURE__ */ o(
312
+ "textarea",
313
+ {
314
+ id: n ?? (t == null ? void 0 : t.fieldId),
315
+ className: m(d.textarea.root, a),
316
+ rows: l,
317
+ disabled: r ?? (t == null ? void 0 : t.disabled),
318
+ "aria-invalid": s || void 0,
319
+ "aria-describedby": t == null ? void 0 : t.describedById,
320
+ ...i
321
+ }
322
+ );
323
+ }
324
+ function K({ error: e, className: a, id: n, disabled: r, children: l, ...i }) {
325
+ const t = f(), s = e ?? (t == null ? void 0 : t.invalid) ?? !1;
326
+ return /* @__PURE__ */ u("div", { className: d.select.wrap, children: [
327
+ /* @__PURE__ */ o(
328
+ "select",
329
+ {
330
+ id: n ?? (t == null ? void 0 : t.fieldId),
331
+ className: m(d.select.root, a),
332
+ disabled: r ?? (t == null ? void 0 : t.disabled),
333
+ "aria-invalid": s || void 0,
334
+ "aria-describedby": t == null ? void 0 : t.describedById,
335
+ ...i,
336
+ children: l
337
+ }
338
+ ),
339
+ /* @__PURE__ */ o(
340
+ "svg",
341
+ {
342
+ className: d.select.elements.arrow,
343
+ viewBox: "0 0 16 16",
344
+ fill: "none",
345
+ stroke: "currentColor",
346
+ strokeWidth: 1.75,
347
+ strokeLinecap: "round",
348
+ strokeLinejoin: "round",
349
+ "aria-hidden": "true",
350
+ children: /* @__PURE__ */ o("path", { d: "M4 6l4 4 4-4" })
351
+ }
352
+ )
353
+ ] });
354
+ }
355
+ function I(e, a, n) {
356
+ const [r, l] = T(a), i = e !== void 0, t = i ? e : r, s = W(
357
+ (c) => {
358
+ i || l(c), n == null || n(c);
359
+ },
360
+ [i, n]
361
+ );
362
+ return [t, s];
363
+ }
364
+ function Q({
365
+ checked: e,
366
+ defaultChecked: a = !1,
367
+ onChange: n,
368
+ disabled: r,
369
+ name: l,
370
+ value: i,
371
+ children: t,
372
+ className: s
373
+ }) {
374
+ const [c, h] = I(e, a, n);
375
+ return /* @__PURE__ */ u(
376
+ "label",
377
+ {
378
+ className: m(d.checkbox.root, s),
379
+ style: r ? { cursor: "not-allowed", opacity: 0.6 } : void 0,
380
+ children: [
381
+ /* @__PURE__ */ o(
382
+ "input",
383
+ {
384
+ type: "checkbox",
385
+ style: g,
386
+ checked: c,
387
+ onChange: (b) => h(b.target.checked),
388
+ disabled: r,
389
+ name: l,
390
+ value: i
391
+ }
392
+ ),
393
+ /* @__PURE__ */ o("span", { className: d.checkbox.elements.box(c), "aria-hidden": "true", children: c && /* @__PURE__ */ o(
394
+ "svg",
395
+ {
396
+ className: d.checkbox.elements.check,
397
+ viewBox: "0 0 12 12",
398
+ strokeWidth: 2,
399
+ strokeLinecap: "round",
400
+ strokeLinejoin: "round",
401
+ children: /* @__PURE__ */ o("path", { d: "M2.5 6.5l2.5 2.5 4.5-5" })
402
+ }
403
+ ) }),
404
+ t && /* @__PURE__ */ o("span", { className: d.checkbox.elements.label, children: t })
405
+ ]
406
+ }
407
+ );
408
+ }
409
+ const $ = x(null);
410
+ function X({
411
+ name: e,
412
+ value: a,
413
+ onChange: n,
414
+ disabled: r,
415
+ children: l,
416
+ className: i
417
+ }) {
418
+ return /* @__PURE__ */ o($.Provider, { value: { name: e, value: a, onChange: n, disabled: r }, children: /* @__PURE__ */ o("div", { role: "radiogroup", className: i, children: l }) });
419
+ }
420
+ function Y({ value: e, children: a, disabled: n, className: r }) {
421
+ const l = B($), i = (l == null ? void 0 : l.value) === e, t = n ?? (l == null ? void 0 : l.disabled);
422
+ return /* @__PURE__ */ u(
423
+ "label",
424
+ {
425
+ className: m(d.radio.root, r),
426
+ style: t ? { cursor: "not-allowed", opacity: 0.6 } : void 0,
427
+ children: [
428
+ /* @__PURE__ */ o(
429
+ "input",
430
+ {
431
+ type: "radio",
432
+ style: g,
433
+ name: l == null ? void 0 : l.name,
434
+ value: e,
435
+ checked: i,
436
+ onChange: () => {
437
+ var s;
438
+ return (s = l == null ? void 0 : l.onChange) == null ? void 0 : s.call(l, e);
439
+ },
440
+ disabled: t
441
+ }
442
+ ),
443
+ /* @__PURE__ */ o("span", { className: d.radio.elements.circle(i), "aria-hidden": "true" }),
444
+ a && /* @__PURE__ */ o("span", { className: d.radio.elements.label, children: a })
445
+ ]
446
+ }
447
+ );
448
+ }
449
+ function Z({
450
+ checked: e,
451
+ defaultChecked: a = !1,
452
+ onChange: n,
453
+ disabled: r,
454
+ id: l,
455
+ className: i,
456
+ "aria-label": t
457
+ }) {
458
+ const [s, c] = I(e, a, n);
459
+ return /* @__PURE__ */ o(
460
+ "button",
461
+ {
462
+ type: "button",
463
+ role: "switch",
464
+ id: l,
465
+ "aria-checked": s,
466
+ "aria-label": t,
467
+ disabled: r,
468
+ onClick: () => c(!s),
469
+ className: m(d.switch.root(s), i),
470
+ children: /* @__PURE__ */ o("span", { className: d.switch.elements.thumb, "aria-hidden": "true" })
471
+ }
472
+ );
473
+ }
474
+ const w = C.createContext("body");
475
+ function z({ stripe: e, children: a, className: n }) {
476
+ const { wrap: r, root: l } = d.table, i = [r, n].filter(Boolean).join(" ");
477
+ return /* @__PURE__ */ o("div", { className: i, children: /* @__PURE__ */ o("table", { className: l(e), children: a }) });
478
+ }
479
+ function O({ children: e }) {
480
+ return /* @__PURE__ */ o("thead", { children: e });
481
+ }
482
+ function ee({ children: e }) {
483
+ return /* @__PURE__ */ o(w.Provider, { value: "body", children: /* @__PURE__ */ o("tbody", { children: e }) });
484
+ }
485
+ function te({ children: e }) {
486
+ return /* @__PURE__ */ o(w.Provider, { value: "foot", children: /* @__PURE__ */ o("tfoot", { children: e }) });
487
+ }
488
+ function oe({ children: e, className: a }) {
489
+ return /* @__PURE__ */ o("tr", { className: a, children: e });
490
+ }
491
+ function le({ children: e, align: a, colSpan: n, className: r }) {
492
+ const { elements: l } = d.table, i = [l.th(a), r].filter(Boolean).join(" ");
493
+ return /* @__PURE__ */ o("th", { className: i, colSpan: n, scope: "col", children: e });
494
+ }
495
+ function ne({ children: e, num: a, colSpan: n, className: r }) {
496
+ const l = C.useContext(w), { elements: i } = d.table, s = [l === "foot" ? i.tdFoot : i.td, a ? i.tdNum : void 0, r].filter(Boolean).join(" ");
497
+ return /* @__PURE__ */ o("td", { className: s, colSpan: n, children: e });
498
+ }
499
+ export {
500
+ P as Alert,
501
+ H as Badge,
502
+ D as Button,
503
+ G as Card,
504
+ Q as Checkbox,
505
+ V as Field,
506
+ U as FieldError,
507
+ E as FieldHelper,
508
+ q as Input,
509
+ A as Label,
510
+ Y as Radio,
511
+ X as RadioGroup,
512
+ K as Select,
513
+ Z as Switch,
514
+ z as Table,
515
+ ee as TableBody,
516
+ te as TableFoot,
517
+ O as TableHead,
518
+ oe as TableRow,
519
+ ne as Td,
520
+ J as Textarea,
521
+ le as Th,
522
+ f as useFieldContext
523
+ };
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@zapatran/paper-ember-components",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "main": "./dist/index.cjs",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.cjs"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "dependencies": {
19
+ "@zapatran/paper-ember-theme": "0.1.0"
20
+ },
21
+ "peerDependencies": {
22
+ "react": "^18.0.0",
23
+ "react-dom": "^18.0.0"
24
+ },
25
+ "devDependencies": {
26
+ "@storybook/react": "^8.6.18",
27
+ "@testing-library/jest-dom": "^6.4.2",
28
+ "@testing-library/react": "^15.0.6",
29
+ "@testing-library/user-event": "^14.5.2",
30
+ "@types/react": "^18.3.3",
31
+ "@types/react-dom": "^18.3.0",
32
+ "@vitejs/plugin-react": "^4.3.1",
33
+ "jsdom": "^24.1.0",
34
+ "react": "^18.3.1",
35
+ "react-dom": "^18.3.1",
36
+ "typescript": "^5.4.5",
37
+ "vite": "^5.3.1",
38
+ "vitest": "^1.6.0"
39
+ },
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
43
+ "scripts": {
44
+ "build": "vite build",
45
+ "dev": "vite build --watch",
46
+ "test": "vitest run",
47
+ "test:watch": "vitest",
48
+ "typecheck": "tsc --noEmit"
49
+ }
50
+ }