jaguar-form 1.0.1 → 1.0.3

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.
Files changed (40) hide show
  1. package/README.md +24 -0
  2. package/dist/{Control-fWNQOzmu.js → Control-B36bu6zQ.js} +2 -2
  3. package/dist/{Select-BFLDNUiq.js → Select-BG2H-YnK.js} +5 -5
  4. package/dist/{TreeSelect-D8smQmgp.js → TreeSelect-CkPtMg-g.js} +6 -5
  5. package/dist/compound-D4_6P0d_.js +320 -0
  6. package/dist/compound.js +1 -0
  7. package/dist/core.js +3 -1
  8. package/dist/date-time.js +1 -1
  9. package/dist/form-DTI0Sqsy.js +413 -0
  10. package/dist/form.js +4 -3
  11. package/dist/{icons-KmLuj5v3.js → icons-BI3fdIey.js} +2 -1
  12. package/dist/{image-upload-CkX8vlWK.js → image-upload-VtUlQgzJ.js} +4 -4
  13. package/dist/image-upload.js +1 -1
  14. package/dist/index.js +14 -12
  15. package/dist/input.js +1 -1
  16. package/dist/{inputs-DNNFmj2K.js → inputs-BOP8Ryne.js} +5 -4
  17. package/dist/{pickers-BOMKe7vt.js → pickers-C9QTR2XN.js} +6 -4
  18. package/dist/select.js +1 -1
  19. package/dist/selection-CIEa1uce.js +146 -0
  20. package/dist/{slider-BwDcSnnI.js → slider-CNwkLMmo.js} +1 -1
  21. package/dist/slider.js +1 -1
  22. package/dist/{store-DmlIFdPW.js → store-DOn9K-EA.js} +171 -229
  23. package/dist/style.css +1 -1
  24. package/dist/tree-select.js +1 -1
  25. package/dist/types/components/compound/ControlGroup.d.ts +29 -0
  26. package/dist/types/components/compound/context.d.ts +5 -0
  27. package/dist/types/components/compound/index.d.ts +40 -0
  28. package/dist/types/components/compound/model.d.ts +14 -0
  29. package/dist/types/components/compound/types.d.ts +24 -0
  30. package/dist/types/components/date-time/types.d.ts +1 -0
  31. package/dist/types/config/index.d.ts +2 -0
  32. package/dist/types/entries/compound.d.ts +1 -0
  33. package/dist/types/icons/index.d.ts +1 -0
  34. package/dist/types/index.d.ts +1 -0
  35. package/dist/{useControllable-Dl8gno_5.js → useControllable-Zax42z2F.js} +6 -1
  36. package/dist/{useSelection-FYP8nzFQ.js → useSelection-C0OEFZUE.js} +3 -3
  37. package/dist/validation-D6vk5NAv.js +61 -0
  38. package/package.json +5 -1
  39. package/dist/form-zqtJgUQ3.js +0 -407
  40. package/dist/selection-Bfrk6SoB.js +0 -136
package/README.md CHANGED
@@ -111,3 +111,27 @@ The release check includes dependency audits, syntax, core checks, TypeScript, V
111
111
  ## License
112
112
 
113
113
  MIT.
114
+
115
+ ## Compound controls
116
+
117
+ ```tsx
118
+ import { ControlGroup, NumberInput, Select, NumberUnit } from 'jaguar-form';
119
+ import 'jaguar-form/style.css';
120
+
121
+ <ControlGroup radius={10} focusMode="group">
122
+ <NumberInput defaultValue={5.5} />
123
+ <ControlGroup.Item width={90}>
124
+ <Select defaultValue="kW" options={[{value:'W',label:'W'},{value:'kW',label:'kW'}]} />
125
+ </ControlGroup.Item>
126
+ </ControlGroup>
127
+
128
+ <NumberUnit units={['W','kW','MW']} defaultValue={{value:5.5,unit:'kW'}} />
129
+ ```
130
+
131
+ `ControlGroup` controls layout only. `CompoundField` stores an object, supports conditional parts and parent-level validation in `Form` / `Form.Field`, and works with schema `transform`. Use `outlined`, `filled`, `underlined` or `borderless` (the existing control variants). Connected and inset default to group focus; separated defaults to individual focus. See [Compound controls](docs/compound.md) for the API and limitations.
132
+
133
+ ## 1.0.3
134
+
135
+ This patch consolidates the control height, connected group border/radius, and selection popup spacing fixes. See [release notes](docs/CHANGELOG-1.0.3.md).
136
+
137
+ Refined default theme: 34/42/48px controls, 10px radius, cool neutral colors, leading required marks and date icons, compact image tiles. Date and time pickers support `iconPosition="end"` for the previous placement. Existing theme tokens and compound layouts remain configurable.
@@ -1,5 +1,5 @@
1
- import { i as e, s as t } from "./useControllable-Dl8gno_5.js";
2
- import { t as n } from "./icons-KmLuj5v3.js";
1
+ import { i as e, s as t } from "./useControllable-Zax42z2F.js";
2
+ import { t as n } from "./icons-BI3fdIey.js";
3
3
  import { jsx as r, jsxs as i } from "react/jsx-runtime";
4
4
  // src/primitives/Control.tsx
5
5
  function a({ children: a, actions: o, prefix: s, suffix: c, prefixIcon: l, suffixIcon: u, size: d, variant: f, status: p, disabled: m, readOnly: h, className: g, style: _, "aria-invalid": v }) {
@@ -1,9 +1,9 @@
1
1
  import { useEffect as e, useId as t, useMemo as n, useState as r } from "react";
2
- import { n as i, t as ee } from "./Control-fWNQOzmu.js";
3
- import { n as a, r as o } from "./selection-Bfrk6SoB.js";
4
- import { c as s, l as c, o as l, s as te, t as u } from "./useSelection-FYP8nzFQ.js";
5
- import { t as d } from "./icons-KmLuj5v3.js";
6
- import { a as f } from "./useControllable-Dl8gno_5.js";
2
+ import { n as i, t as ee } from "./Control-B36bu6zQ.js";
3
+ import { n as a, r as o } from "./selection-CIEa1uce.js";
4
+ import { c as s, l as c, o as l, s as te, t as u } from "./useSelection-C0OEFZUE.js";
5
+ import { t as d } from "./icons-BI3fdIey.js";
6
+ import { a as f } from "./useControllable-Zax42z2F.js";
7
7
  import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
8
8
  // src/components/select/Select.tsx
9
9
  function g(e) {
@@ -1,9 +1,9 @@
1
1
  import { useEffect as e, useId as t, useLayoutEffect as n, useMemo as r, useRef as i, useState as a } from "react";
2
- import { n as o, t as s } from "./Control-fWNQOzmu.js";
3
- import { n as c, r as l } from "./selection-Bfrk6SoB.js";
4
- import { a as u, c as d, i as f, l as ee, n as te, o as p, r as ne, s as re, t as ie } from "./useSelection-FYP8nzFQ.js";
5
- import { t as m } from "./icons-KmLuj5v3.js";
6
- import { a as ae } from "./useControllable-Dl8gno_5.js";
2
+ import { n as o, t as s } from "./Control-B36bu6zQ.js";
3
+ import { n as c, r as l } from "./selection-CIEa1uce.js";
4
+ import { a as u, c as d, i as f, l as ee, n as te, o as p, r as ne, s as re, t as ie } from "./useSelection-C0OEFZUE.js";
5
+ import { t as m } from "./icons-BI3fdIey.js";
6
+ import { a as ae } from "./useControllable-Zax42z2F.js";
7
7
  import { Fragment as oe, jsx as h, jsxs as g } from "react/jsx-runtime";
8
8
  // src/utils/lazy-tree.ts
9
9
  var _ = (e) => e.hasChildren === !0 && e.children === void 0, v = (e) => !!(e.children?.length || _(e));
@@ -218,6 +218,7 @@ function x(n) {
218
218
  label: z,
219
219
  trigger: (e, t) => /* @__PURE__ */ h("div", {
220
220
  ref: t,
221
+ className: "rfe-anchor",
221
222
  onKeyDown: ke,
222
223
  onBlur: (e) => {
223
224
  !T && !e.currentTarget.contains(e.relatedTarget) && n.onBlur?.();
@@ -0,0 +1,320 @@
1
+ import { Children as e, cloneElement as t, isValidElement as n, useCallback as r, useEffect as i, useId as a, useMemo as o, useRef as s, useState as c } from "react";
2
+ import { i as l, o as u, s as d, t as f } from "./useControllable-Zax42z2F.js";
3
+ import { a as p, o as m, s as h, t as g } from "./inputs-BOP8Ryne.js";
4
+ import { n as _, t as v } from "./Select-BG2H-YnK.js";
5
+ import { t as y } from "./TreeSelect-CkPtMg-g.js";
6
+ import { s as b, t as x } from "./pickers-C9QTR2XN.js";
7
+ import { a as S, i as C } from "./selection-CIEa1uce.js";
8
+ import { jsx as w, jsxs as T } from "react/jsx-runtime";
9
+ import { n as E } from "./validation-D6vk5NAv.js";
10
+ // src/components/compound/ControlGroup.tsx
11
+ var D = (e) => typeof e == "number" ? `${e}px` : {
12
+ none: "0",
13
+ small: "4px",
14
+ medium: "var(--rfe-border-radius,6px)",
15
+ large: "12px",
16
+ full: "999px"
17
+ }[e ?? ""] ?? e;
18
+ function O({ children: e, width: t, minWidth: n, maxWidth: r, flex: i, radius: a, background: o, padding: s, divider: c, className: l, style: u }) {
19
+ return /* @__PURE__ */ w("div", {
20
+ className: d("rfe-control-group-item", l),
21
+ "data-divider": c,
22
+ style: {
23
+ width: t,
24
+ minWidth: n,
25
+ maxWidth: r,
26
+ flex: i ?? (t === void 0 ? void 0 : "0 1 auto"),
27
+ borderRadius: D(a),
28
+ "--rfe-group-item-radius": D(a),
29
+ background: o,
30
+ padding: s,
31
+ ...u
32
+ },
33
+ children: e
34
+ });
35
+ }
36
+ function k({ children: a, disabled: u, readOnly: f, error: p, status: m, id: h, className: g, style: _, onFocus: v, onBlur: y, "aria-label": b, "aria-describedby": x, "aria-invalid": T, ...E }) {
37
+ let k = l(), A = S(), { layout: j = "connected", direction: M = "horizontal", focusMode: N = j === "separated" ? "individual" : "group", radius: P, gap: F, padding: I, size: L = k.size, variant: R = k.variant, divider: z = !0, block: B = !0 } = {
38
+ ...k.controlGroup,
39
+ ...E
40
+ }, V = s(null), H = s(/* @__PURE__ */ new Set()), U = s(!1), W = s(null), [G, K] = c(!1), q = s({
41
+ onFocus: v,
42
+ onBlur: y,
43
+ disabled: u
44
+ });
45
+ q.current = {
46
+ onFocus: v,
47
+ onBlur: y,
48
+ disabled: u
49
+ };
50
+ let J = r(() => {
51
+ let e = V.current;
52
+ if (!e) return;
53
+ let t = e.ownerDocument.activeElement, n = !q.current.disabled && !!t && (e.contains(t) || [...H.current].some((e) => e.contains(t)));
54
+ n !== U.current && (U.current = n, K(n), n ? q.current.onFocus?.() : q.current.onBlur?.());
55
+ }, []), Y = r(() => {
56
+ W.current !== null && cancelAnimationFrame(W.current), W.current = requestAnimationFrame(() => {
57
+ W.current = null, J();
58
+ });
59
+ }, [J]);
60
+ i(() => {
61
+ let e = V.current?.ownerDocument;
62
+ if (e) return e.addEventListener("focusin", Y), e.addEventListener("focusout", Y), J(), () => {
63
+ e.removeEventListener("focusin", Y), e.removeEventListener("focusout", Y), W.current !== null && cancelAnimationFrame(W.current), W.current = null;
64
+ };
65
+ }, [J, Y]), i(() => {
66
+ J();
67
+ }, [u, J]);
68
+ let X = r((e) => {
69
+ H.current.add(e);
70
+ let t = A?.registerPopup(e);
71
+ return Y(), () => {
72
+ H.current.delete(e), t?.(), Y();
73
+ };
74
+ }, [A, Y]), Z = o(() => ({ registerPopup: X }), [X]), Q = (e) => {
75
+ if (!n(e)) return e;
76
+ if (typeof e.type == "string") return [
77
+ "input",
78
+ "select",
79
+ "textarea",
80
+ "button"
81
+ ].includes(e.type) ? t(e, {
82
+ ...u ? { disabled: !0 } : {},
83
+ ...f ? e.type === "input" || e.type === "textarea" ? { readOnly: !0 } : { disabled: !0 } : {}
84
+ }) : e;
85
+ let r = e;
86
+ return t(r, {
87
+ size: j === "separated" ? r.props.size ?? L : L,
88
+ ...u ? { disabled: !0 } : {},
89
+ ...f ? { readOnly: !0 } : {}
90
+ });
91
+ }, $ = e.toArray(a).map((r, i) => {
92
+ if (n(r) && r.type === O) {
93
+ let n = r;
94
+ return t(n, { children: e.map(n.props.children, Q) });
95
+ }
96
+ let a = n(r) ? r.props.style?.width : void 0;
97
+ return /* @__PURE__ */ w(O, {
98
+ width: a,
99
+ children: Q(r)
100
+ }, n(r) ? r.key ?? i : i);
101
+ });
102
+ return /* @__PURE__ */ w(C.Provider, {
103
+ value: Z,
104
+ children: /* @__PURE__ */ w("div", {
105
+ ref: V,
106
+ id: h,
107
+ role: "group",
108
+ "aria-label": b,
109
+ "aria-describedby": x,
110
+ "aria-invalid": T || p || m === "error" || void 0,
111
+ "aria-disabled": u || void 0,
112
+ className: d("rfe-control-group", g),
113
+ "data-layout": j,
114
+ "data-direction": M,
115
+ "data-focus-mode": N,
116
+ "data-focused": G,
117
+ "data-status": T || p ? "error" : m ?? "default",
118
+ "data-disabled": u || void 0,
119
+ "data-size": L,
120
+ "data-variant": R,
121
+ "data-divider": z,
122
+ "data-block": B,
123
+ style: {
124
+ "--rfe-group-radius": D(P),
125
+ "--rfe-group-gap": typeof F == "number" ? `${F}px` : F,
126
+ "--rfe-group-padding": typeof I == "number" ? `${I}px` : I,
127
+ ..._
128
+ },
129
+ children: $
130
+ })
131
+ });
132
+ }
133
+ var A = Object.assign(k, { Item: O });
134
+ // src/components/compound/model.ts
135
+ function j(e) {
136
+ let t = /* @__PURE__ */ new Set();
137
+ return Object.fromEntries(e.map((e) => {
138
+ if (!e.name || t.has(e.name) || [
139
+ "__proto__",
140
+ "constructor",
141
+ "prototype"
142
+ ].includes(e.name)) throw Error(`Invalid compound field: ${e.name}`);
143
+ return t.add(e.name), [e.name, e.defaultValue];
144
+ }));
145
+ }
146
+ function M(e, t) {
147
+ return {
148
+ ...j(e),
149
+ ...t && typeof t == "object" && !Array.isArray(t) ? t : {}
150
+ };
151
+ }
152
+ var N = (e, t) => typeof e.visible == "function" ? e.visible(t) : e.visible !== !1, P = (e, t) => typeof e.disabled == "function" ? e.disabled(t) : !!e.disabled;
153
+ function F(e) {
154
+ return { validate: async (t, n, { signal: r }) => {
155
+ let i = M(e, t);
156
+ for (let t of e) {
157
+ if (r.aborted) return;
158
+ if (!N(t, i) || P(t, i)) continue;
159
+ let e = await E(i[t.name], i, [...t.required ? [{ required: !0 }] : [], ...t.rules ?? []], r);
160
+ if (e) return e;
161
+ }
162
+ } };
163
+ }
164
+ // src/components/compound/index.tsx
165
+ var I = {
166
+ input: p,
167
+ number: m,
168
+ password: h,
169
+ select: _,
170
+ multiSelect: v,
171
+ treeSelect: y,
172
+ date: x,
173
+ time: b
174
+ };
175
+ function L({ fields: e, value: t, defaultValue: n, onChange: r, name: i, loading: o, disabled: s, id: c, ...l }) {
176
+ let u = a(), [d, p] = f(t, M(e, n), r), m = M(e, d);
177
+ return /* @__PURE__ */ w(A, {
178
+ ...l,
179
+ disabled: s || o,
180
+ "aria-label": l["aria-label"] ?? i,
181
+ children: e.filter((e) => N(e, m)).map((e, t) => {
182
+ let n = I[e.type], { width: r, minWidth: i, maxWidth: a, flex: d, radius: f, background: h, padding: g, divider: _ } = e, v = {
183
+ ...e.componentProps,
184
+ id: t === 0 ? c ?? u : `${c ?? u}-${t}`,
185
+ name: e.name,
186
+ "aria-label": e.label ?? e.name,
187
+ "aria-describedby": l["aria-describedby"],
188
+ "aria-invalid": l.error || l.status === "error" || l["aria-invalid"],
189
+ value: m[e.name] ?? (["input", "password"].includes(e.type) ? "" : e.type === "multiSelect" || e.type === "treeSelect" && e.componentProps?.multiple ? [] : null),
190
+ onChange: (t) => p({
191
+ ...m,
192
+ [e.name]: t
193
+ }),
194
+ disabled: s || o || P(e, m) || e.componentProps?.disabled === !0,
195
+ readOnly: l.readOnly || (typeof e.readOnly == "function" ? e.readOnly(m) : e.readOnly) || e.componentProps?.readOnly === !0
196
+ };
197
+ return /* @__PURE__ */ w(A.Item, {
198
+ width: r,
199
+ minWidth: i,
200
+ maxWidth: a,
201
+ flex: d,
202
+ radius: f,
203
+ background: h,
204
+ padding: g,
205
+ divider: _,
206
+ children: e.render ? e.render(v, m) : n ? /* @__PURE__ */ w(n, { ...v }) : null
207
+ }, e.name);
208
+ })
209
+ });
210
+ }
211
+ function R({ options: e, selectWidth: t = 100, selectPosition: n = "end", inputProps: r, selectProps: i, numeric: a, ...o }) {
212
+ let s = {
213
+ name: "value",
214
+ type: a ? "number" : "input",
215
+ defaultValue: a ? null : "",
216
+ componentProps: r
217
+ }, c = {
218
+ name: "option",
219
+ type: "select",
220
+ defaultValue: null,
221
+ width: t,
222
+ componentProps: {
223
+ ...i,
224
+ options: e
225
+ }
226
+ };
227
+ return /* @__PURE__ */ w(L, {
228
+ ...o,
229
+ fields: n === "start" ? [c, s] : [s, c]
230
+ });
231
+ }
232
+ function z(e) {
233
+ return /* @__PURE__ */ w(R, { ...e });
234
+ }
235
+ function B(e) {
236
+ return /* @__PURE__ */ w(R, {
237
+ ...e,
238
+ numeric: !0
239
+ });
240
+ }
241
+ function V({ units: e, selectWidth: t = 90, inputProps: n, selectProps: r, selectPosition: i = "end", ...a }) {
242
+ let o = {
243
+ name: "value",
244
+ type: "number",
245
+ defaultValue: null,
246
+ componentProps: n
247
+ }, s = {
248
+ name: "unit",
249
+ type: "select",
250
+ defaultValue: e[0] ?? null,
251
+ width: t,
252
+ componentProps: {
253
+ ...r,
254
+ options: e.map((e) => ({
255
+ value: e,
256
+ label: String(e)
257
+ }))
258
+ }
259
+ };
260
+ return /* @__PURE__ */ w(L, {
261
+ ...a,
262
+ fields: i === "start" ? [s, o] : [o, s]
263
+ });
264
+ }
265
+ function H(e) {
266
+ let { numeric: t, ...n } = e;
267
+ return /* @__PURE__ */ w(L, {
268
+ ...n,
269
+ fields: [{
270
+ name: "start",
271
+ type: t ? "number" : "input"
272
+ }, {
273
+ name: "end",
274
+ type: t ? "number" : "input"
275
+ }]
276
+ });
277
+ }
278
+ function U({ onSearch: e, buttonLabel: t, ...n }) {
279
+ let r = u(), [i, a] = f(n.value, n.defaultValue ?? {
280
+ value: "",
281
+ option: null
282
+ }, n.onChange);
283
+ return /* @__PURE__ */ T(A, {
284
+ ...n,
285
+ children: [
286
+ /* @__PURE__ */ w(p, {
287
+ value: String(i.value ?? ""),
288
+ onChange: (e) => a({
289
+ ...i,
290
+ value: e
291
+ }),
292
+ onEnter: () => {
293
+ n.disabled || n.readOnly || n.loading || e(i);
294
+ },
295
+ disabled: n.loading
296
+ }),
297
+ /* @__PURE__ */ w(A.Item, {
298
+ width: n.selectWidth ?? 100,
299
+ children: /* @__PURE__ */ w(_, {
300
+ options: n.options,
301
+ value: i.option ?? null,
302
+ onChange: (e) => a({
303
+ ...i,
304
+ option: e
305
+ }),
306
+ disabled: n.loading
307
+ })
308
+ }),
309
+ /* @__PURE__ */ w(A.Item, {
310
+ flex: "0 0 auto",
311
+ children: /* @__PURE__ */ w(g, {
312
+ disabled: n.disabled || n.readOnly || n.loading,
313
+ onClick: () => e(i),
314
+ children: t ?? r.search
315
+ })
316
+ })
317
+ ]
318
+ });
319
+ }
320
+ export { V as a, F as c, N as d, A as f, B as i, M as l, H as n, U as o, z as r, j as s, L as t, P as u };
@@ -0,0 +1 @@
1
+ export { t as CompoundField, f as ControlGroup, n as InputRange, r as InputSelect, i as NumberSelect, a as NumberUnit, o as SearchGroup, s as compoundDefaults, c as compoundRule, l as compoundValues, u as partDisabled, d as partVisible } from "./compound-D4_6P0d_.js";
package/dist/core.js CHANGED
@@ -1 +1,3 @@
1
- export { l as changedOutputValues, u as cloneValues, t as createFormStore, o as createPathAdapter, d as defineValueAdapter, m as editArray, n as equalValue, s as expandPaths, h as fieldSegments, c as getPathValue, g as hasPath, f as inputValues, _ as isArrayIndex, r as isEmpty, v as isPlainRecord, y as normalizePaths, b as omitPaths, p as outputValues, x as readPath, i as validateRuleIssue, a as validateRules, S as writePath } from "./store-DmlIFdPW.js";
1
+ import { n as e, r as t, t as n } from "./validation-D6vk5NAv.js";
2
+ import { _ as r, a as i, c as a, d as o, f as s, g as c, h as l, i as u, l as d, m as f, n as p, o as m, p as h, r as g, s as _, t as v, u as y, v as b, y as x } from "./store-DOn9K-EA.js";
3
+ export { m as changedOutputValues, _ as cloneValues, v as createFormStore, g as createPathAdapter, a as defineValueAdapter, o as editArray, p as equalValue, u as expandPaths, s as fieldSegments, i as getPathValue, h as hasPath, d as inputValues, f as isArrayIndex, n as isEmpty, l as isPlainRecord, c as normalizePaths, r as omitPaths, y as outputValues, b as readPath, e as validateRuleIssue, t as validateRules, x as writePath };
package/dist/date-time.js CHANGED
@@ -1 +1 @@
1
- export { t as DatePicker, n as DateRangePicker, r as DateTimePicker, i as DateTimeRangePicker, a as MonthPicker, o as MonthRangePicker, s as TimePicker, c as TimeRangePicker, l as YearPicker, u as YearRangePicker } from "./pickers-BOMKe7vt.js";
1
+ export { t as DatePicker, n as DateRangePicker, r as DateTimePicker, i as DateTimeRangePicker, a as MonthPicker, o as MonthRangePicker, s as TimePicker, c as TimeRangePicker, l as YearPicker, u as YearRangePicker } from "./pickers-C9QTR2XN.js";