@pibit.ai/cure-design-system 0.3.43 → 0.3.48
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/applications/loading-indicator/index.d.ts +2 -0
- package/dist/applications/loading-indicator/index.d.ts.map +1 -0
- package/dist/applications/loading-indicator/loading-indicator.d.ts +1 -2
- package/dist/applications/loading-indicator/loading-indicator.d.ts.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +175 -162
- package/dist/patterns/table/TableWrapper.d.ts.map +1 -1
- package/dist/patterns/table/TableWrapper.js +538 -564
- package/dist/patterns/table/TableZoomControl.d.ts +12 -0
- package/dist/patterns/table/TableZoomControl.d.ts.map +1 -0
- package/dist/patterns/table/TableZoomControl.js +58 -0
- package/dist/patterns/table/index.d.ts +2 -0
- package/dist/patterns/table/index.d.ts.map +1 -1
- package/dist/patterns/table/tableZoomLayout.d.ts +23 -1
- package/dist/patterns/table/tableZoomLayout.d.ts.map +1 -1
- package/dist/patterns/table/tableZoomLayout.js +39 -27
- package/dist/patterns/table/types.d.ts +3 -0
- package/dist/patterns/table/types.d.ts.map +1 -1
- package/dist/patterns/table-component/TableComponent.d.ts +6 -0
- package/dist/patterns/table-component/TableComponent.d.ts.map +1 -0
- package/dist/patterns/table-component/TableComponent.js +814 -0
- package/dist/patterns/table-component/buildTableColumns.d.ts +10 -0
- package/dist/patterns/table-component/buildTableColumns.d.ts.map +1 -0
- package/dist/patterns/table-component/buildTableColumns.js +65 -0
- package/dist/patterns/table-component/buildTableColumns.test.d.ts +2 -0
- package/dist/patterns/table-component/buildTableColumns.test.d.ts.map +1 -0
- package/dist/patterns/table-component/index.d.ts +5 -0
- package/dist/patterns/table-component/index.d.ts.map +1 -0
- package/dist/patterns/table-component/rowMetrics.d.ts +11 -0
- package/dist/patterns/table-component/rowMetrics.d.ts.map +1 -0
- package/dist/patterns/table-component/rowMetrics.js +15 -0
- package/dist/patterns/table-component/tableFeatures.d.ts +12 -0
- package/dist/patterns/table-component/tableFeatures.d.ts.map +1 -0
- package/dist/patterns/table-component/tableFeatures.js +14 -0
- package/dist/patterns/table-component/types.d.ts +207 -0
- package/dist/patterns/table-component/types.d.ts.map +1 -0
- package/dist/patterns/table-component/useCellRangeSelection.d.ts +50 -0
- package/dist/patterns/table-component/useCellRangeSelection.d.ts.map +1 -0
- package/dist/patterns/table-component/useCellRangeSelection.js +218 -0
- package/dist/patterns/table-component/useRowReorderDrag.d.ts +17 -0
- package/dist/patterns/table-component/useRowReorderDrag.d.ts.map +1 -0
- package/dist/patterns/table-component/useRowReorderDrag.js +109 -0
- package/dist/primitives/input/hint-text.d.ts +1 -2
- package/dist/primitives/input/hint-text.d.ts.map +1 -1
- package/dist/primitives/input/index.d.ts +3 -1
- package/dist/primitives/input/index.d.ts.map +1 -1
- package/dist/primitives/input/input.d.ts +1 -1
- package/dist/primitives/input/input.d.ts.map +1 -1
- package/dist/primitives/input/input.js +135 -129
- package/dist/primitives/input/label.d.ts +1 -2
- package/dist/primitives/input/label.d.ts.map +1 -1
- package/dist/primitives/select/index.d.ts +1 -0
- package/dist/primitives/select/index.d.ts.map +1 -1
- package/dist/primitives/select/select-item.d.ts +1 -2
- package/dist/primitives/select/select-item.d.ts.map +1 -1
- package/dist/styles/components.css +1 -1
- package/dist/styles/theme.css +1 -1
- package/package.json +6 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PointerEvent as ReactPointerEvent } from 'react';
|
|
2
|
+
import { RowDragSession } from '../table/rowReorderDrag';
|
|
3
|
+
export type UseRowReorderDragOptions = {
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
onReorderRows?: (fromSourceIndex: number, toSourceIndex: number, item: Record<string, unknown>) => void;
|
|
6
|
+
containerRef: {
|
|
7
|
+
current: HTMLElement | null;
|
|
8
|
+
};
|
|
9
|
+
/** Called when a drag starts, so row-action popovers can close. */
|
|
10
|
+
onDragStart?: () => void;
|
|
11
|
+
};
|
|
12
|
+
export type UseRowReorderDragResult = {
|
|
13
|
+
session: RowDragSession | null;
|
|
14
|
+
startDrag: (event: ReactPointerEvent<HTMLElement>, rowId: string, sourceRowIndex: number, item: Record<string, unknown>) => void;
|
|
15
|
+
};
|
|
16
|
+
export declare function useRowReorderDrag({ enabled, onReorderRows, containerRef, onDragStart, }: UseRowReorderDragOptions): UseRowReorderDragResult;
|
|
17
|
+
//# sourceMappingURL=useRowReorderDrag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRowReorderDrag.d.ts","sourceRoot":"","sources":["../../../src/patterns/table-component/useRowReorderDrag.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAKL,KAAK,YAAY,IAAI,iBAAiB,EACvC,MAAM,OAAO,CAAC;AACf,OAAO,EAQL,KAAK,cAAc,EACpB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,CACd,eAAe,EAAE,MAAM,EACvB,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC1B,IAAI,CAAC;IACV,YAAY,EAAE;QAAE,OAAO,EAAE,WAAW,GAAG,IAAI,CAAA;KAAE,CAAC;IAC9C,mEAAmE;IACnE,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/B,SAAS,EAAE,CACT,KAAK,EAAE,iBAAiB,CAAC,WAAW,CAAC,EACrC,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC1B,IAAI,CAAC;CACX,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,aAAa,EACb,YAAY,EACZ,WAAW,GACZ,EAAE,wBAAwB,GAAG,uBAAuB,CAmJpD"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { useState as C, useRef as P, useCallback as S, useEffect as Y } from "react";
|
|
2
|
+
import { ROW_REORDER_ATTR as T, cloneRowForPreview as X, measureRowPreview as g, getRowDragScrollDelta as D, ROW_DRAG_THRESHOLD_PX as A, computeDropTarget as W, clipDropLineToScrollport as _ } from "../table/rowReorderDrag.js";
|
|
3
|
+
function b({
|
|
4
|
+
enabled: E,
|
|
5
|
+
onReorderRows: w,
|
|
6
|
+
containerRef: p,
|
|
7
|
+
onDragStart: v
|
|
8
|
+
}) {
|
|
9
|
+
const [i, h] = C(null), d = P(null), a = S((t) => {
|
|
10
|
+
d.current = t, h(t);
|
|
11
|
+
}, []), x = S(
|
|
12
|
+
(t, c, u, s) => {
|
|
13
|
+
var o, e;
|
|
14
|
+
if (!E || t.button !== 0) return;
|
|
15
|
+
const n = (o = p.current) == null ? void 0 : o.querySelector(
|
|
16
|
+
`tr[${T}="${CSS.escape(c)}"]`
|
|
17
|
+
);
|
|
18
|
+
if (!n) return;
|
|
19
|
+
t.preventDefault();
|
|
20
|
+
try {
|
|
21
|
+
t.currentTarget.setPointerCapture(t.pointerId);
|
|
22
|
+
} catch {
|
|
23
|
+
}
|
|
24
|
+
const r = ((e = n.closest("table")) == null ? void 0 : e.getBoundingClientRect()) ?? n.getBoundingClientRect();
|
|
25
|
+
a({
|
|
26
|
+
rowId: c,
|
|
27
|
+
fromSourceIndex: u,
|
|
28
|
+
item: s,
|
|
29
|
+
pointerId: t.pointerId,
|
|
30
|
+
startX: t.clientX,
|
|
31
|
+
startY: t.clientY,
|
|
32
|
+
currentX: t.clientX,
|
|
33
|
+
currentY: t.clientY,
|
|
34
|
+
active: !1,
|
|
35
|
+
preview: g(n),
|
|
36
|
+
toSourceIndex: u,
|
|
37
|
+
dropLineY: null,
|
|
38
|
+
dropLineLeft: r.left,
|
|
39
|
+
dropLineWidth: r.width,
|
|
40
|
+
rowClone: X(n)
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
[E, p, a]
|
|
44
|
+
);
|
|
45
|
+
return Y(() => {
|
|
46
|
+
if (!i) return;
|
|
47
|
+
const t = (r, o) => {
|
|
48
|
+
const e = d.current;
|
|
49
|
+
if (!e) return;
|
|
50
|
+
const I = Math.hypot(
|
|
51
|
+
r - e.startX,
|
|
52
|
+
o - e.startY
|
|
53
|
+
), l = e.active || I >= A;
|
|
54
|
+
l && !e.active && (v == null || v());
|
|
55
|
+
let f = {
|
|
56
|
+
...e,
|
|
57
|
+
currentX: r,
|
|
58
|
+
currentY: o,
|
|
59
|
+
active: l
|
|
60
|
+
};
|
|
61
|
+
const m = p.current;
|
|
62
|
+
if (l && m) {
|
|
63
|
+
const L = W(
|
|
64
|
+
m,
|
|
65
|
+
o,
|
|
66
|
+
e.fromSourceIndex,
|
|
67
|
+
e.rowId
|
|
68
|
+
);
|
|
69
|
+
L && (f = {
|
|
70
|
+
...f,
|
|
71
|
+
toSourceIndex: L.toSourceIndex,
|
|
72
|
+
// Clipped so the line never draws over sticky chrome or outside the card.
|
|
73
|
+
dropLineY: _(L.dropLineY, m),
|
|
74
|
+
dropLineLeft: L.dropLineLeft,
|
|
75
|
+
dropLineWidth: L.dropLineWidth
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
a(f);
|
|
79
|
+
}, c = (r) => {
|
|
80
|
+
var o;
|
|
81
|
+
r.pointerId === ((o = d.current) == null ? void 0 : o.pointerId) && (r.preventDefault(), t(r.clientX, r.clientY));
|
|
82
|
+
}, u = (r) => (o) => {
|
|
83
|
+
const e = d.current;
|
|
84
|
+
if (!e || o.pointerId !== e.pointerId) return;
|
|
85
|
+
const { fromSourceIndex: I, toSourceIndex: l, item: f, active: m } = e;
|
|
86
|
+
a(null), r && m && I !== l && (w == null || w(I, l, f));
|
|
87
|
+
}, s = u(!0), n = u(!1);
|
|
88
|
+
return window.addEventListener("pointermove", c), window.addEventListener("pointerup", s), window.addEventListener("pointercancel", n), () => {
|
|
89
|
+
window.removeEventListener("pointermove", c), window.removeEventListener("pointerup", s), window.removeEventListener("pointercancel", n);
|
|
90
|
+
};
|
|
91
|
+
}, [i, p, a, w, v]), Y(() => {
|
|
92
|
+
if (!(i != null && i.active)) return;
|
|
93
|
+
const t = p.current;
|
|
94
|
+
if (!t) return;
|
|
95
|
+
let c = 0;
|
|
96
|
+
const u = () => {
|
|
97
|
+
const s = d.current;
|
|
98
|
+
if (s) {
|
|
99
|
+
const n = D(t, s.currentY);
|
|
100
|
+
n !== 0 && (t.scrollTop += n);
|
|
101
|
+
}
|
|
102
|
+
c = requestAnimationFrame(u);
|
|
103
|
+
};
|
|
104
|
+
return c = requestAnimationFrame(u), () => cancelAnimationFrame(c);
|
|
105
|
+
}, [i == null ? void 0 : i.active, p]), { session: i, startDrag: x };
|
|
106
|
+
}
|
|
107
|
+
export {
|
|
108
|
+
b as useRowReorderDrag
|
|
109
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode, Ref } from 'react';
|
|
2
2
|
import { TextProps as AriaTextProps } from 'react-aria-components';
|
|
3
|
-
interface HintTextProps extends AriaTextProps {
|
|
3
|
+
export interface HintTextProps extends AriaTextProps {
|
|
4
4
|
/** Indicates that the hint text is an error message. */
|
|
5
5
|
isInvalid?: boolean;
|
|
6
6
|
ref?: Ref<HTMLElement>;
|
|
@@ -11,5 +11,4 @@ export declare const HintText: {
|
|
|
11
11
|
({ size, isInvalid, className, ...props }: HintTextProps): import("react/jsx-runtime").JSX.Element;
|
|
12
12
|
displayName: string;
|
|
13
13
|
};
|
|
14
|
-
export {};
|
|
15
14
|
//# sourceMappingURL=hint-text.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hint-text.d.ts","sourceRoot":"","sources":["../../../src/primitives/input/hint-text.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGxE,
|
|
1
|
+
{"version":3,"file":"hint-text.d.ts","sourceRoot":"","sources":["../../../src/primitives/input/hint-text.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGxE,MAAM,WAAW,aAAc,SAAQ,aAAa;IAClD,wDAAwD;IACxD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,GAAG,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;IACvB,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;CAC3B;AAQD,eAAO,MAAM,QAAQ;+CAKlB,aAAa;;CAiBf,CAAC"}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export { Input, type InputProps } from './input';
|
|
1
|
+
export { Input, InputBase, type InputProps, type InputBaseProps } from './input';
|
|
2
|
+
export { Label, type LabelProps } from './label';
|
|
3
|
+
export { HintText, type HintTextProps } from './hint-text';
|
|
2
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/primitives/input/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/primitives/input/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AACjF,OAAO,EAAE,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -84,7 +84,7 @@ export interface InputProps extends InputBaseProps, BaseProps {
|
|
|
84
84
|
* <Input errorMessage="This field is required" />
|
|
85
85
|
*/
|
|
86
86
|
export declare const Input: {
|
|
87
|
-
({ size, placeholder, icon: Icon, iconTrailing: IconTrailing, label, supportingText, hint, shortcut, hideRequiredIndicator, className, ref, groupRef, tooltip, iconClassName, inputClassName, wrapperClassName, tooltipClassName, inputType, customStyles, containerStyles, trailingAction, trailingIconCount, mode, ...props }: InputProps): import("react/jsx-runtime").JSX.Element;
|
|
87
|
+
({ size, placeholder, icon: Icon, iconTrailing: IconTrailing, label, supportingText, hint, shortcut, hideRequiredIndicator, className, ref, groupRef, tooltip, iconClassName, inputClassName, wrapperClassName, tooltipClassName, inputType, customStyles, containerStyles, trailingAction, trailingIconCount, mode, isDisabled, isInvalid, ...props }: InputProps): import("react/jsx-runtime").JSX.Element;
|
|
88
88
|
displayName: string;
|
|
89
89
|
};
|
|
90
90
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../src/primitives/input/input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,cAAc,IAAI,kBAAkB,EACrC,MAAM,uBAAuB,CAAC;AAO/B,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../src/primitives/input/input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,cAAc,IAAI,kBAAkB,EACrC,MAAM,uBAAuB,CAAC;AAO/B,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAqB3E,MAAM,WAAW,cAAe,SAAQ,cAAc;IACpD,+CAA+C;IAC/C,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,wBAAwB;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+BAA+B;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gCAAgC;IAChC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,wCAAwC;IACxC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kCAAkC;IAClC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,8IAA8I;IAC9I,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,GAAG,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAC5B,QAAQ,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IAC/B,+DAA+D;IAC/D,IAAI,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACvD,gEAAgE;IAChE,YAAY,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAC/D,2DAA2D;IAC3D,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B,0CAA0C;IAC1C,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kCAAkC;IAClC,YAAY,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CACpC;AAED,eAAO,MAAM,SAAS;2SAuBnB,IAAI,CAAC,cAAc,EAAE,OAAO,GAAG,MAAM,CAAC;;CAqTxC,CAAC;AAIF,UAAU,SAAS;IACjB,+BAA+B;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4CAA4C;IAC5C,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB;AAED,MAAM,WAAW,cACf,SACE,SAAS,EACT,kBAAkB,EAClB,IAAI,CACF,cAAc,EACZ,MAAM,GACN,kBAAkB,GAClB,gBAAgB,GAChB,eAAe,GACf,kBAAkB,CACrB;IACH,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAID,eAAO,MAAM,SAAS;8BAA6B,cAAc;;CAehE,CAAC;AAIF,MAAM,WAAW,UAAW,SAAQ,cAAc,EAAE,SAAS;IAC3D,+CAA+C;IAC/C,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,oDAAoD;IACpD,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,MAAM,CAAC;IACpD,kCAAkC;IAClC,YAAY,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACnC,sCAAsC;IACtC,eAAe,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACtC,6BAA6B;IAC7B,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B,gDAAgD;IAChD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,KAAK;4VA2Bf,UAAU;;CAmFZ,CAAC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { jsx as r, jsxs as
|
|
2
|
-
import {
|
|
1
|
+
import { jsx as r, jsxs as R, Fragment as Y } from "react/jsx-runtime";
|
|
2
|
+
import { Group as Z, Input as A, TextField as W } from "react-aria-components";
|
|
3
3
|
import { cx as i, sortCx as D } from "../../utils/cn.js";
|
|
4
|
-
import { useState as
|
|
5
|
-
import { HintText as
|
|
6
|
-
import { EyeOff as te, Eye as ie, XClose as
|
|
4
|
+
import { useState as H, useContext as ee, createContext as re, useEffect as ae } from "react";
|
|
5
|
+
import { HintText as G } from "./hint-text.js";
|
|
6
|
+
import { EyeOff as te, Eye as ie, XClose as se, HelpCircle as le, InfoCircle as ne } from "@untitledui/icons";
|
|
7
7
|
import { Label as oe } from "./label.js";
|
|
8
8
|
import { Tooltip as de, TooltipTrigger as pe } from "../tooltip/tooltip.js";
|
|
9
9
|
import { getPlatformShortcutLabel as ue } from "../../utils/keyboard-shortcut.js";
|
|
10
10
|
import { Badge as ge } from "../badge/badge.js";
|
|
11
|
-
const
|
|
11
|
+
const X = {
|
|
12
12
|
sm: "text-xs",
|
|
13
13
|
md: "text-sm",
|
|
14
14
|
lg: "text-md"
|
|
@@ -16,19 +16,19 @@ const G = {
|
|
|
16
16
|
sm: "text-xs",
|
|
17
17
|
md: "text-xs",
|
|
18
18
|
lg: "text-sm"
|
|
19
|
-
},
|
|
20
|
-
ref:
|
|
21
|
-
isReadOnly:
|
|
22
|
-
tooltip:
|
|
19
|
+
}, J = ({
|
|
20
|
+
ref: o,
|
|
21
|
+
isReadOnly: f,
|
|
22
|
+
tooltip: c,
|
|
23
23
|
shortcut: N,
|
|
24
24
|
groupRef: C,
|
|
25
25
|
size: _ = "sm",
|
|
26
|
-
isInvalid:
|
|
27
|
-
isDisabled:
|
|
28
|
-
icon:
|
|
29
|
-
iconTrailing:
|
|
26
|
+
isInvalid: h,
|
|
27
|
+
isDisabled: u,
|
|
28
|
+
icon: v,
|
|
29
|
+
iconTrailing: x,
|
|
30
30
|
placeholder: B,
|
|
31
|
-
wrapperClassName:
|
|
31
|
+
wrapperClassName: E,
|
|
32
32
|
tooltipClassName: j,
|
|
33
33
|
inputClassName: k,
|
|
34
34
|
iconClassName: L,
|
|
@@ -36,11 +36,11 @@ const G = {
|
|
|
36
36
|
trailingIconCount: g,
|
|
37
37
|
mode: m,
|
|
38
38
|
// Omit this prop to avoid invalid HTML attribute warning
|
|
39
|
-
isRequired:
|
|
40
|
-
customStyles:
|
|
41
|
-
...
|
|
39
|
+
isRequired: V,
|
|
40
|
+
customStyles: F,
|
|
41
|
+
...P
|
|
42
42
|
}) => {
|
|
43
|
-
const z =
|
|
43
|
+
const z = c || h || x || T, q = v, [w, y] = H([]), [d, b] = H(""), e = ee(M), s = (e == null ? void 0 : e.size) || _, l = D({
|
|
44
44
|
sm: {
|
|
45
45
|
root: i(
|
|
46
46
|
"p-2 h-8",
|
|
@@ -86,55 +86,55 @@ const G = {
|
|
|
86
86
|
tag: "rounded-md bg-primary border border-secondary p-2.5",
|
|
87
87
|
wrapper: "rounded-lg"
|
|
88
88
|
}
|
|
89
|
-
}),
|
|
89
|
+
}), $ = () => {
|
|
90
90
|
var t;
|
|
91
|
-
const a =
|
|
91
|
+
const a = d.trim();
|
|
92
92
|
a && ((t = e == null ? void 0 : e.onChange) == null || t.call(
|
|
93
93
|
e,
|
|
94
94
|
e != null && e.value ? (e == null ? void 0 : e.value) + "," + a : a
|
|
95
|
-
),
|
|
96
|
-
},
|
|
97
|
-
var t, n,
|
|
95
|
+
), y((n) => [...n, a]), b(""));
|
|
96
|
+
}, I = (a) => {
|
|
97
|
+
var t, n, K;
|
|
98
98
|
if (m === "tag") {
|
|
99
99
|
if (a.key === "Enter" || a.key === ",") {
|
|
100
100
|
a.preventDefault();
|
|
101
|
-
const
|
|
102
|
-
|
|
101
|
+
const p = d.trim();
|
|
102
|
+
p && ((t = e == null ? void 0 : e.onChange) == null || t.call(
|
|
103
103
|
e,
|
|
104
|
-
e != null && e.value ? (e == null ? void 0 : e.value) + "," +
|
|
105
|
-
),
|
|
104
|
+
e != null && e.value ? (e == null ? void 0 : e.value) + "," + p : p
|
|
105
|
+
), y((O) => [...O, p]), b(""));
|
|
106
106
|
}
|
|
107
|
-
if (a.key === "Backspace" && !
|
|
107
|
+
if (a.key === "Backspace" && !d)
|
|
108
108
|
if (e != null && e.value) {
|
|
109
|
-
const
|
|
110
|
-
|
|
109
|
+
const p = e.value.split(",").map((O) => O.trim()).filter(Boolean);
|
|
110
|
+
p.pop(), (n = e.onChange) == null || n.call(e, p.join(", "));
|
|
111
111
|
} else
|
|
112
|
-
(
|
|
112
|
+
(K = e == null ? void 0 : e.onChange) == null || K.call(e, "");
|
|
113
113
|
}
|
|
114
|
-
},
|
|
114
|
+
}, S = (a) => {
|
|
115
115
|
const t = a.target.value;
|
|
116
|
-
m === "tag" &&
|
|
116
|
+
m === "tag" && b(t);
|
|
117
117
|
}, U = (a) => {
|
|
118
118
|
var n;
|
|
119
|
-
const t =
|
|
120
|
-
|
|
119
|
+
const t = w.filter((K, p) => p !== a);
|
|
120
|
+
y(t), (n = e == null ? void 0 : e.onChange) == null || n.call(e, t.join(", "));
|
|
121
121
|
};
|
|
122
122
|
return ae(() => {
|
|
123
123
|
if (m === "tag")
|
|
124
124
|
if (e != null && e.value) {
|
|
125
125
|
const a = e.value.split(",").map((t) => t.trim()).filter(Boolean);
|
|
126
|
-
|
|
126
|
+
y(a);
|
|
127
127
|
} else
|
|
128
|
-
|
|
129
|
-
}, [e == null ? void 0 : e.value]), /* @__PURE__ */
|
|
130
|
-
|
|
128
|
+
y([]);
|
|
129
|
+
}, [e == null ? void 0 : e.value]), /* @__PURE__ */ R(
|
|
130
|
+
Z,
|
|
131
131
|
{
|
|
132
|
-
isDisabled:
|
|
133
|
-
isInvalid:
|
|
132
|
+
isDisabled: u,
|
|
133
|
+
isInvalid: h,
|
|
134
134
|
ref: C,
|
|
135
135
|
className: ({ isFocusWithin: a, isDisabled: t, isInvalid: n }) => i(
|
|
136
136
|
"relative flex w-full flex-row place-content-center place-items-center bg-primary border border-secondary duration-100 ease-linear",
|
|
137
|
-
a && !t && !
|
|
137
|
+
a && !t && !f && "ring-1 ring-brand",
|
|
138
138
|
// Disabled state styles
|
|
139
139
|
t && "cursor-not-allowed bg-disabled_subtle ring-disabled",
|
|
140
140
|
"group-disabled:cursor-not-allowed group-disabled:bg-disabled_subtle group-disabled:ring-disabled",
|
|
@@ -145,36 +145,36 @@ const G = {
|
|
|
145
145
|
n && a && "ring-2 ring-error",
|
|
146
146
|
a && "group-invalid:ring-2 group-invalid:ring-error",
|
|
147
147
|
e == null ? void 0 : e.wrapperClassName,
|
|
148
|
-
|
|
149
|
-
s
|
|
148
|
+
E,
|
|
149
|
+
l[s].wrapper
|
|
150
150
|
),
|
|
151
151
|
children: [
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
v && /* @__PURE__ */ r(
|
|
153
|
+
v,
|
|
154
154
|
{
|
|
155
155
|
className: i(
|
|
156
156
|
"pointer-events-none absolute size-5 text-fg-quaternary",
|
|
157
|
-
|
|
158
|
-
s
|
|
157
|
+
u && "text-fg-disabled",
|
|
158
|
+
l[s].iconLeading,
|
|
159
159
|
e == null ? void 0 : e.iconClassName,
|
|
160
160
|
L
|
|
161
161
|
)
|
|
162
162
|
}
|
|
163
163
|
),
|
|
164
|
-
m === "tag" && /* @__PURE__ */
|
|
164
|
+
m === "tag" && /* @__PURE__ */ R(
|
|
165
165
|
"div",
|
|
166
166
|
{
|
|
167
167
|
className: i(
|
|
168
168
|
"flex flex-wrap w-full items-center justify-start gap-1 pl-1.5",
|
|
169
|
-
|
|
169
|
+
u && "text-fg-disabled"
|
|
170
170
|
),
|
|
171
171
|
children: [
|
|
172
|
-
|
|
172
|
+
w.map((a, t) => (
|
|
173
173
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
|
|
174
|
-
/* @__PURE__ */ r("div", { onClick: (n) => n.stopPropagation(), children: /* @__PURE__ */
|
|
174
|
+
/* @__PURE__ */ r("div", { onClick: (n) => n.stopPropagation(), children: /* @__PURE__ */ R(ge, { className: "rounded-md bg-primary border border-secondary px-2 py-1 pointer-events-auto!", children: [
|
|
175
175
|
a,
|
|
176
176
|
/* @__PURE__ */ r(
|
|
177
|
-
|
|
177
|
+
se,
|
|
178
178
|
{
|
|
179
179
|
className: "size-4 cursor-pointer text-fg-quaternary hover:text-fg-quaternary_hover focus:text-fg-quaternary_hover",
|
|
180
180
|
onClick: () => U(t)
|
|
@@ -186,17 +186,17 @@ const G = {
|
|
|
186
186
|
"input",
|
|
187
187
|
{
|
|
188
188
|
type: "text",
|
|
189
|
-
value:
|
|
190
|
-
onChange:
|
|
191
|
-
onKeyDown:
|
|
192
|
-
placeholder:
|
|
193
|
-
disabled:
|
|
194
|
-
onBlur:
|
|
189
|
+
value: d,
|
|
190
|
+
onChange: S,
|
|
191
|
+
onKeyDown: I,
|
|
192
|
+
placeholder: w.length === 0 ? B : "",
|
|
193
|
+
disabled: u,
|
|
194
|
+
onBlur: $,
|
|
195
195
|
className: i(
|
|
196
196
|
"bg-transparent outline-none flex-1 min-w-[50px] w-full text-primary placeholder:text-placeholder_subtle",
|
|
197
|
-
|
|
198
|
-
s
|
|
199
|
-
|
|
197
|
+
"disabled:cursor-not-allowed disabled:text-disabled group-disabled:pointer-events-none",
|
|
198
|
+
l[s].root,
|
|
199
|
+
X[s],
|
|
200
200
|
k
|
|
201
201
|
)
|
|
202
202
|
}
|
|
@@ -205,51 +205,51 @@ const G = {
|
|
|
205
205
|
}
|
|
206
206
|
),
|
|
207
207
|
m !== "tag" && /* @__PURE__ */ r(
|
|
208
|
-
|
|
208
|
+
A,
|
|
209
209
|
{
|
|
210
|
-
...
|
|
211
|
-
ref:
|
|
210
|
+
...P,
|
|
211
|
+
ref: o,
|
|
212
212
|
placeholder: B,
|
|
213
213
|
className: i(
|
|
214
214
|
"m-0 w-full bg-transparent text-primary ring-0 outline-hidden placeholder:text-placeholder_subtle autofill:rounded-lg autofill:text-primary",
|
|
215
|
-
|
|
216
|
-
s
|
|
217
|
-
|
|
215
|
+
"disabled:cursor-not-allowed disabled:text-disabled group-disabled:pointer-events-none",
|
|
216
|
+
l[s].root,
|
|
217
|
+
X[s],
|
|
218
218
|
e == null ? void 0 : e.inputClassName,
|
|
219
219
|
k
|
|
220
220
|
),
|
|
221
|
-
style: { ...
|
|
221
|
+
style: { ...F }
|
|
222
222
|
}
|
|
223
223
|
),
|
|
224
|
-
T && !
|
|
224
|
+
T && !x && /* @__PURE__ */ r(
|
|
225
225
|
"div",
|
|
226
226
|
{
|
|
227
227
|
className: i(
|
|
228
228
|
"absolute flex items-center justify-center",
|
|
229
|
-
s
|
|
230
|
-
s
|
|
229
|
+
l[s].iconTrailing,
|
|
230
|
+
l[s].trailingIconCount
|
|
231
231
|
),
|
|
232
232
|
children: T
|
|
233
233
|
}
|
|
234
234
|
),
|
|
235
|
-
|
|
235
|
+
c && !h && /* @__PURE__ */ r(de, { title: c, placement: "top", children: /* @__PURE__ */ r(
|
|
236
236
|
pe,
|
|
237
237
|
{
|
|
238
238
|
className: i(
|
|
239
239
|
"absolute cursor-pointer text-fg-quaternary transition duration-200 hover:text-fg-quaternary_hover focus:text-fg-quaternary_hover",
|
|
240
|
-
s
|
|
240
|
+
l[s].iconTrailing,
|
|
241
241
|
e == null ? void 0 : e.tooltipClassName,
|
|
242
242
|
j
|
|
243
243
|
),
|
|
244
|
-
children: /* @__PURE__ */ r(
|
|
244
|
+
children: /* @__PURE__ */ r(le, { className: "size-4" })
|
|
245
245
|
}
|
|
246
246
|
) }),
|
|
247
|
-
|
|
247
|
+
h && /* @__PURE__ */ r(
|
|
248
248
|
ne,
|
|
249
249
|
{
|
|
250
250
|
className: i(
|
|
251
251
|
"pointer-events-none absolute size-4 text-fg-error-secondary",
|
|
252
|
-
s
|
|
252
|
+
l[s].iconTrailing,
|
|
253
253
|
e == null ? void 0 : e.tooltipClassName,
|
|
254
254
|
j
|
|
255
255
|
)
|
|
@@ -260,14 +260,14 @@ const G = {
|
|
|
260
260
|
{
|
|
261
261
|
className: i(
|
|
262
262
|
"pointer-events-none absolute inset-y-0.5 right-0.5 z-10 flex items-center rounded-r-[inherit] bg-linear-to-r from-transparent pl-8",
|
|
263
|
-
s
|
|
263
|
+
l[s].shortcut
|
|
264
264
|
),
|
|
265
265
|
children: /* @__PURE__ */ r(
|
|
266
266
|
"span",
|
|
267
267
|
{
|
|
268
268
|
className: i(
|
|
269
269
|
"pointer-events-none rounded px-1 py-px text-xs font-medium text-quaternary ring-1 ring-secondary select-none ring-inset",
|
|
270
|
-
|
|
270
|
+
u && "bg-transparent text-disabled"
|
|
271
271
|
),
|
|
272
272
|
"aria-hidden": "true",
|
|
273
273
|
children: typeof N == "string" ? N : ue(["meta"], "K")
|
|
@@ -275,13 +275,13 @@ const G = {
|
|
|
275
275
|
)
|
|
276
276
|
}
|
|
277
277
|
),
|
|
278
|
-
|
|
279
|
-
|
|
278
|
+
x && /* @__PURE__ */ r(
|
|
279
|
+
x,
|
|
280
280
|
{
|
|
281
281
|
className: i(
|
|
282
282
|
"pointer-events-none absolute size-5 text-fg-quaternary",
|
|
283
|
-
|
|
284
|
-
s
|
|
283
|
+
u && "text-fg-disabled",
|
|
284
|
+
l[s].iconTrailing,
|
|
285
285
|
e == null ? void 0 : e.iconClassName,
|
|
286
286
|
L
|
|
287
287
|
)
|
|
@@ -291,95 +291,101 @@ const G = {
|
|
|
291
291
|
}
|
|
292
292
|
);
|
|
293
293
|
};
|
|
294
|
-
|
|
295
|
-
const
|
|
296
|
-
|
|
294
|
+
J.displayName = "InputBase";
|
|
295
|
+
const M = re({}), Q = ({ className: o, ...f }) => /* @__PURE__ */ r(M.Provider, { value: f, children: /* @__PURE__ */ r(
|
|
296
|
+
W,
|
|
297
297
|
{
|
|
298
|
-
...
|
|
298
|
+
...f,
|
|
299
299
|
"data-input-wrapper": !0,
|
|
300
|
-
className: (
|
|
300
|
+
className: (c) => i(
|
|
301
301
|
"group flex h-max w-full flex-col items-start justify-start gap-1.5",
|
|
302
|
-
typeof
|
|
302
|
+
typeof o == "function" ? o(c) : o
|
|
303
303
|
)
|
|
304
304
|
}
|
|
305
305
|
) });
|
|
306
|
-
|
|
306
|
+
Q.displayName = "TextField";
|
|
307
307
|
const fe = ({
|
|
308
|
-
size:
|
|
309
|
-
placeholder:
|
|
310
|
-
icon:
|
|
308
|
+
size: o = "sm",
|
|
309
|
+
placeholder: f,
|
|
310
|
+
icon: c,
|
|
311
311
|
iconTrailing: N,
|
|
312
312
|
label: C,
|
|
313
313
|
supportingText: _,
|
|
314
|
-
hint:
|
|
315
|
-
shortcut:
|
|
316
|
-
hideRequiredIndicator:
|
|
317
|
-
className:
|
|
314
|
+
hint: h,
|
|
315
|
+
shortcut: u,
|
|
316
|
+
hideRequiredIndicator: v,
|
|
317
|
+
className: x,
|
|
318
318
|
ref: B,
|
|
319
|
-
groupRef:
|
|
319
|
+
groupRef: E,
|
|
320
320
|
tooltip: j,
|
|
321
321
|
iconClassName: k,
|
|
322
322
|
inputClassName: L,
|
|
323
323
|
wrapperClassName: T,
|
|
324
324
|
tooltipClassName: g,
|
|
325
325
|
inputType: m = "text",
|
|
326
|
-
customStyles:
|
|
327
|
-
containerStyles:
|
|
328
|
-
trailingAction:
|
|
326
|
+
customStyles: V = {},
|
|
327
|
+
containerStyles: F = {},
|
|
328
|
+
trailingAction: P,
|
|
329
329
|
trailingIconCount: z,
|
|
330
330
|
mode: q,
|
|
331
|
-
|
|
331
|
+
isDisabled: w,
|
|
332
|
+
isInvalid: y,
|
|
333
|
+
...d
|
|
332
334
|
}) => {
|
|
333
|
-
const [
|
|
335
|
+
const [b, e] = H(!1), s = m === "password", l = s ? b ? "text" : "password" : m, $ = d == null ? void 0 : d.isReadOnly;
|
|
334
336
|
return /* @__PURE__ */ r(
|
|
335
|
-
|
|
337
|
+
Q,
|
|
336
338
|
{
|
|
337
|
-
style:
|
|
338
|
-
"aria-label": C ? void 0 :
|
|
339
|
-
...
|
|
340
|
-
|
|
341
|
-
|
|
339
|
+
style: F,
|
|
340
|
+
"aria-label": C ? void 0 : f,
|
|
341
|
+
...d,
|
|
342
|
+
isDisabled: w,
|
|
343
|
+
isInvalid: y,
|
|
344
|
+
className: x,
|
|
345
|
+
children: ({ isRequired: I, isInvalid: S }) => /* @__PURE__ */ R(Y, { children: [
|
|
342
346
|
C && /* @__PURE__ */ r(
|
|
343
347
|
oe,
|
|
344
348
|
{
|
|
345
|
-
className: i("color-text-label", me[
|
|
346
|
-
isRequired:
|
|
349
|
+
className: i("color-text-label", me[o]),
|
|
350
|
+
isRequired: v ? !v : I,
|
|
347
351
|
children: C
|
|
348
352
|
}
|
|
349
353
|
),
|
|
350
|
-
_ && /* @__PURE__ */ r(
|
|
354
|
+
_ && /* @__PURE__ */ r(G, { className: "mt-[-5px] text-tertiary!", isInvalid: !1, children: _ }),
|
|
351
355
|
/* @__PURE__ */ r(
|
|
352
|
-
|
|
356
|
+
J,
|
|
353
357
|
{
|
|
354
358
|
ref: B,
|
|
355
|
-
groupRef:
|
|
356
|
-
size:
|
|
357
|
-
placeholder:
|
|
358
|
-
isReadOnly:
|
|
359
|
-
|
|
359
|
+
groupRef: E,
|
|
360
|
+
size: o,
|
|
361
|
+
placeholder: f,
|
|
362
|
+
isReadOnly: $,
|
|
363
|
+
isDisabled: w,
|
|
364
|
+
isInvalid: S,
|
|
365
|
+
icon: c,
|
|
360
366
|
iconTrailing: N,
|
|
361
|
-
shortcut:
|
|
367
|
+
shortcut: u,
|
|
362
368
|
iconClassName: k,
|
|
363
369
|
inputClassName: L,
|
|
364
370
|
wrapperClassName: T,
|
|
365
371
|
tooltipClassName: g,
|
|
366
372
|
tooltip: j,
|
|
367
|
-
type:
|
|
368
|
-
customStyles:
|
|
373
|
+
type: l,
|
|
374
|
+
customStyles: V,
|
|
369
375
|
mode: q,
|
|
370
|
-
trailingAction:
|
|
376
|
+
trailingAction: s ? /* @__PURE__ */ r(
|
|
371
377
|
"button",
|
|
372
378
|
{
|
|
373
379
|
type: "button",
|
|
374
|
-
onClick: () =>
|
|
380
|
+
onClick: () => e(!b),
|
|
375
381
|
className: "text-fg-quaternary hover:text-fg-quaternary_hover focus:outline-none",
|
|
376
|
-
children:
|
|
382
|
+
children: b ? /* @__PURE__ */ r(te, { className: "size-5" }) : /* @__PURE__ */ r(ie, { className: "size-5" })
|
|
377
383
|
}
|
|
378
|
-
) :
|
|
384
|
+
) : P,
|
|
379
385
|
trailingIconCount: z
|
|
380
386
|
}
|
|
381
387
|
),
|
|
382
|
-
|
|
388
|
+
h && /* @__PURE__ */ r(G, { size: o, isInvalid: S, children: h })
|
|
383
389
|
] })
|
|
384
390
|
}
|
|
385
391
|
);
|
|
@@ -387,6 +393,6 @@ const fe = ({
|
|
|
387
393
|
fe.displayName = "Input";
|
|
388
394
|
export {
|
|
389
395
|
fe as Input,
|
|
390
|
-
|
|
391
|
-
|
|
396
|
+
J as InputBase,
|
|
397
|
+
Q as TextField
|
|
392
398
|
};
|