@cerberus-design/react 0.15.0-next-e0ce56e → 0.15.0-next-739c492
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/build/legacy/_tsup-dts-rollup.d.cts +313 -112
- package/build/legacy/components/Checkbox.cjs +27 -35
- package/build/legacy/components/Checkbox.cjs.map +1 -1
- package/build/legacy/components/DatePicker.client.cjs +67 -89
- package/build/legacy/components/DatePicker.client.cjs.map +1 -1
- package/build/legacy/components/Fieldset.cjs +4 -17
- package/build/legacy/components/Fieldset.cjs.map +1 -1
- package/build/legacy/components/FieldsetLabel.cjs.map +1 -1
- package/build/legacy/components/FileStatus.cjs +126 -79
- package/build/legacy/components/FileStatus.cjs.map +1 -1
- package/build/legacy/components/Legend.cjs +10 -22
- package/build/legacy/components/Legend.cjs.map +1 -1
- package/build/legacy/components/Radio.cjs +4 -21
- package/build/legacy/components/Radio.cjs.map +1 -1
- package/build/legacy/components/Select.cjs +19 -54
- package/build/legacy/components/Select.cjs.map +1 -1
- package/build/legacy/components/Toggle.cjs +17 -24
- package/build/legacy/components/Toggle.cjs.map +1 -1
- package/build/legacy/components/button/button.cjs +1 -1
- package/build/legacy/components/button/button.cjs.map +1 -1
- package/build/legacy/components/button/index.cjs +1 -1
- package/build/legacy/components/button/index.cjs.map +1 -1
- package/build/legacy/components/button/parts.cjs +1 -1
- package/build/legacy/components/button/parts.cjs.map +1 -1
- package/build/legacy/components/{FieldMessage.cjs → deprecated/FieldMessage.cjs} +4 -17
- package/build/legacy/components/deprecated/FieldMessage.cjs.map +1 -0
- package/build/legacy/components/{Textarea.cjs → deprecated/Label.cjs} +24 -36
- package/build/legacy/components/deprecated/Label.cjs.map +1 -0
- package/build/legacy/components/field/field.cjs +130 -0
- package/build/legacy/components/field/field.cjs.map +1 -0
- package/build/legacy/components/field/index.cjs +261 -0
- package/build/legacy/components/field/index.cjs.map +1 -0
- package/build/legacy/components/field/parts.cjs +184 -0
- package/build/legacy/components/field/parts.cjs.map +1 -0
- package/build/legacy/components/field/primitives.cjs +186 -0
- package/build/legacy/components/field/primitives.cjs.map +1 -0
- package/build/legacy/components/field/start-indicator.cjs +45 -0
- package/build/legacy/components/field/start-indicator.cjs.map +1 -0
- package/build/legacy/components/field/status-indicator.cjs +78 -0
- package/build/legacy/components/field/status-indicator.cjs.map +1 -0
- package/build/legacy/context/confirm-modal.cjs +1 -1
- package/build/legacy/context/confirm-modal.cjs.map +1 -1
- package/build/legacy/context/cta-modal.cjs +1 -1
- package/build/legacy/context/cta-modal.cjs.map +1 -1
- package/build/legacy/context/field.cjs +23 -4
- package/build/legacy/context/field.cjs.map +1 -1
- package/build/legacy/context/notification-center.cjs.map +1 -1
- package/build/legacy/context/prompt-modal.cjs +168 -166
- package/build/legacy/context/prompt-modal.cjs.map +1 -1
- package/build/legacy/hooks/useDate.cjs.map +1 -1
- package/build/legacy/index.cjs +1156 -1067
- package/build/legacy/index.cjs.map +1 -1
- package/build/legacy/utils/index.cjs +22 -2
- package/build/legacy/utils/index.cjs.map +1 -1
- package/build/modern/_tsup-dts-rollup.d.ts +313 -112
- package/build/modern/{chunk-2JX27W6Y.js → chunk-2BIHLH4V.js} +2 -2
- package/build/modern/chunk-2BIHLH4V.js.map +1 -0
- package/build/modern/{chunk-3ZDFQO25.js → chunk-6EUC3SUI.js} +4 -7
- package/build/modern/chunk-6EUC3SUI.js.map +1 -0
- package/build/modern/{chunk-MER66QUY.js → chunk-6KZVE4HC.js} +1 -1
- package/build/modern/{chunk-MER66QUY.js.map → chunk-6KZVE4HC.js.map} +1 -1
- package/build/modern/{chunk-FTPZHG6J.js → chunk-6WOJAMZV.js} +3 -9
- package/build/modern/chunk-6WOJAMZV.js.map +1 -0
- package/build/modern/chunk-7VA5SXTY.js +31 -0
- package/build/modern/chunk-7VA5SXTY.js.map +1 -0
- package/build/modern/chunk-7YVOZULL.js +23 -0
- package/build/modern/chunk-7YVOZULL.js.map +1 -0
- package/build/modern/{chunk-KU2AWAK3.js → chunk-B2A6QFKT.js} +4 -17
- package/build/modern/chunk-B2A6QFKT.js.map +1 -0
- package/build/modern/chunk-BL7G3577.js +29 -0
- package/build/modern/chunk-BL7G3577.js.map +1 -0
- package/build/modern/chunk-C5NL3X7W.js +96 -0
- package/build/modern/chunk-C5NL3X7W.js.map +1 -0
- package/build/modern/chunk-CNA2VKAH.js +43 -0
- package/build/modern/chunk-CNA2VKAH.js.map +1 -0
- package/build/modern/{chunk-Z7FGXAND.js → chunk-FMRWRVUS.js} +2 -2
- package/build/modern/{chunk-NGOLRISW.js → chunk-FVE4GBB7.js} +9 -8
- package/build/modern/chunk-FVE4GBB7.js.map +1 -0
- package/build/modern/{chunk-7P7OWBGV.js → chunk-G2VFEBY4.js} +8 -8
- package/build/modern/chunk-G2VFEBY4.js.map +1 -0
- package/build/modern/{chunk-XQICKZH4.js → chunk-GENS32QO.js} +10 -8
- package/build/modern/chunk-GENS32QO.js.map +1 -0
- package/build/modern/{chunk-Q4IV5NUT.js → chunk-GNPGG4ND.js} +37 -40
- package/build/modern/chunk-GNPGG4ND.js.map +1 -0
- package/build/modern/{chunk-7S47NSGR.js → chunk-H54FR7IP.js} +2 -2
- package/build/modern/chunk-IGSC4IEA.js +37 -0
- package/build/modern/chunk-IGSC4IEA.js.map +1 -0
- package/build/modern/{chunk-JWIJHSI6.js → chunk-L7N24B6B.js} +3 -6
- package/build/modern/chunk-L7N24B6B.js.map +1 -0
- package/build/modern/{chunk-3RGRHMJQ.js → chunk-LCN7LYTU.js} +5 -5
- package/build/modern/{chunk-3BM6MZ4A.js → chunk-MWRO5QYD.js} +1 -1
- package/build/modern/chunk-MWRO5QYD.js.map +1 -0
- package/build/modern/{chunk-PZAZKQMO.js → chunk-OYT7RGC7.js} +1 -1
- package/build/modern/chunk-OYT7RGC7.js.map +1 -0
- package/build/modern/{chunk-ILQW5VZT.js → chunk-RBNOEAWJ.js} +4 -7
- package/build/modern/chunk-RBNOEAWJ.js.map +1 -0
- package/build/modern/{chunk-5QONP7GT.js → chunk-S2X5OEPK.js} +2 -10
- package/build/modern/chunk-S2X5OEPK.js.map +1 -0
- package/build/modern/chunk-TYPULJMJ.js +1 -0
- package/build/modern/chunk-Z52R6ABJ.js +21 -0
- package/build/modern/chunk-Z52R6ABJ.js.map +1 -0
- package/build/modern/components/Checkbox.js +1 -2
- package/build/modern/components/DatePicker.client.js +3 -4
- package/build/modern/components/Fieldset.js +1 -2
- package/build/modern/components/FieldsetLabel.js +1 -1
- package/build/modern/components/FileStatus.js +9 -3
- package/build/modern/components/Legend.js +1 -2
- package/build/modern/components/Radio.js +1 -3
- package/build/modern/components/Select.js +1 -2
- package/build/modern/components/Toggle.js +1 -2
- package/build/modern/components/button/button.js +1 -1
- package/build/modern/components/button/index.js +2 -2
- package/build/modern/components/button/parts.js +2 -2
- package/build/modern/components/deprecated/FieldMessage.js +8 -0
- package/build/modern/components/deprecated/Label.js +17 -0
- package/build/modern/components/field/field.js +14 -0
- package/build/modern/components/field/index.js +42 -0
- package/build/modern/components/field/index.js.map +1 -0
- package/build/modern/components/field/parts.js +11 -0
- package/build/modern/components/field/parts.js.map +1 -0
- package/build/modern/components/field/primitives.js +24 -0
- package/build/modern/components/field/primitives.js.map +1 -0
- package/build/modern/components/field/start-indicator.js +7 -0
- package/build/modern/components/field/start-indicator.js.map +1 -0
- package/build/modern/components/field/status-indicator.js +9 -0
- package/build/modern/components/field/status-indicator.js.map +1 -0
- package/build/modern/context/confirm-modal.js +2 -2
- package/build/modern/context/cta-modal.js +4 -4
- package/build/modern/context/field.js +34 -4
- package/build/modern/context/field.js.map +1 -1
- package/build/modern/context/notification-center.js +2 -2
- package/build/modern/context/prompt-modal.js +10 -5
- package/build/modern/hooks/useDate.js +1 -1
- package/build/modern/index.js +85 -62
- package/build/modern/index.js.map +1 -1
- package/build/modern/utils/index.js +5 -3
- package/package.json +2 -2
- package/src/components/Checkbox.tsx +13 -9
- package/src/components/DatePicker.client.tsx +2 -14
- package/src/components/Fieldset.tsx +3 -3
- package/src/components/FieldsetLabel.tsx +5 -2
- package/src/components/FileStatus.tsx +4 -5
- package/src/components/Legend.tsx +5 -6
- package/src/components/Radio.tsx +2 -7
- package/src/components/Select.tsx +1 -16
- package/src/components/Toggle.tsx +14 -7
- package/src/components/button/button.tsx +1 -1
- package/src/components/button/parts.ts +6 -0
- package/src/components/{FieldMessage.tsx → deprecated/FieldMessage.tsx} +2 -13
- package/src/components/deprecated/Label.tsx +24 -0
- package/src/components/field/field.tsx +77 -0
- package/src/components/field/index.ts +5 -0
- package/src/components/field/parts.ts +71 -0
- package/src/components/field/primitives.tsx +197 -0
- package/src/components/field/start-indicator.tsx +23 -0
- package/src/components/field/status-indicator.tsx +58 -0
- package/src/context/field.tsx +6 -5
- package/src/context/prompt-modal.tsx +16 -18
- package/src/hooks/useDate.ts +1 -7
- package/src/index.ts +4 -6
- package/src/utils/index.ts +30 -0
- package/build/legacy/components/FieldMessage.cjs.map +0 -1
- package/build/legacy/components/Input.cjs +0 -95
- package/build/legacy/components/Input.cjs.map +0 -1
- package/build/legacy/components/Label.cjs +0 -93
- package/build/legacy/components/Label.cjs.map +0 -1
- package/build/legacy/components/Textarea.cjs.map +0 -1
- package/build/modern/chunk-2JX27W6Y.js.map +0 -1
- package/build/modern/chunk-3BM6MZ4A.js.map +0 -1
- package/build/modern/chunk-3ZDFQO25.js.map +0 -1
- package/build/modern/chunk-5QONP7GT.js.map +0 -1
- package/build/modern/chunk-7P7OWBGV.js.map +0 -1
- package/build/modern/chunk-C5EHJUS5.js +0 -10
- package/build/modern/chunk-C5EHJUS5.js.map +0 -1
- package/build/modern/chunk-FTPZHG6J.js.map +0 -1
- package/build/modern/chunk-ILQW5VZT.js.map +0 -1
- package/build/modern/chunk-JIJM6JFJ.js +0 -36
- package/build/modern/chunk-JIJM6JFJ.js.map +0 -1
- package/build/modern/chunk-JWIJHSI6.js.map +0 -1
- package/build/modern/chunk-KU2AWAK3.js.map +0 -1
- package/build/modern/chunk-NGOLRISW.js.map +0 -1
- package/build/modern/chunk-NMF2HYWO.js +0 -50
- package/build/modern/chunk-NMF2HYWO.js.map +0 -1
- package/build/modern/chunk-PZAZKQMO.js.map +0 -1
- package/build/modern/chunk-Q4IV5NUT.js.map +0 -1
- package/build/modern/chunk-UZDVOIW5.js +0 -33
- package/build/modern/chunk-UZDVOIW5.js.map +0 -1
- package/build/modern/chunk-VYCU7I4J.js +0 -43
- package/build/modern/chunk-VYCU7I4J.js.map +0 -1
- package/build/modern/chunk-XQICKZH4.js.map +0 -1
- package/build/modern/components/FieldMessage.js +0 -9
- package/build/modern/components/Input.js +0 -11
- package/build/modern/components/Label.js +0 -10
- package/build/modern/components/Textarea.js +0 -9
- package/src/components/Input.tsx +0 -69
- package/src/components/Label.tsx +0 -69
- package/src/components/Textarea.tsx +0 -52
- /package/build/modern/{chunk-Z7FGXAND.js.map → chunk-FMRWRVUS.js.map} +0 -0
- /package/build/modern/{chunk-7S47NSGR.js.map → chunk-H54FR7IP.js.map} +0 -0
- /package/build/modern/{chunk-3RGRHMJQ.js.map → chunk-LCN7LYTU.js.map} +0 -0
- /package/build/modern/{components/FieldMessage.js.map → chunk-TYPULJMJ.js.map} +0 -0
- /package/build/modern/components/{Input.js.map → deprecated/FieldMessage.js.map} +0 -0
- /package/build/modern/components/{Label.js.map → deprecated/Label.js.map} +0 -0
- /package/build/modern/components/{Textarea.js.map → field/field.js.map} +0 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/components/field/parts.ts
|
|
21
|
+
var parts_exports = {};
|
|
22
|
+
__export(parts_exports, {
|
|
23
|
+
FieldParts: () => FieldParts
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(parts_exports);
|
|
26
|
+
|
|
27
|
+
// src/components/field/primitives.tsx
|
|
28
|
+
var import_field = require("@ark-ui/react/field");
|
|
29
|
+
var import_css3 = require("@cerberus/styled-system/css");
|
|
30
|
+
var import_recipes3 = require("@cerberus/styled-system/recipes");
|
|
31
|
+
|
|
32
|
+
// src/components/field/status-indicator.tsx
|
|
33
|
+
var import_react2 = require("@ark-ui/react");
|
|
34
|
+
var import_css = require("@cerberus/styled-system/css");
|
|
35
|
+
var import_recipes = require("@cerberus/styled-system/recipes");
|
|
36
|
+
|
|
37
|
+
// src/context/cerberus.tsx
|
|
38
|
+
var import_react = require("react");
|
|
39
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
40
|
+
var CerberusContext = (0, import_react.createContext)(null);
|
|
41
|
+
function useCerberusContext() {
|
|
42
|
+
const context = (0, import_react.useContext)(CerberusContext);
|
|
43
|
+
if (!context) {
|
|
44
|
+
throw new Error("useCerberus must be used within a CerberusProvider");
|
|
45
|
+
}
|
|
46
|
+
return context;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// src/components/field/status-indicator.tsx
|
|
50
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
51
|
+
function FieldStatusIndicator(props) {
|
|
52
|
+
const { fallback, ...nativeProps } = props;
|
|
53
|
+
const styles = (0, import_recipes.field)();
|
|
54
|
+
const fieldContext = (0, import_react2.useFieldContext)();
|
|
55
|
+
const { icons } = useCerberusContext();
|
|
56
|
+
const { invalid: InvalidIcon } = icons;
|
|
57
|
+
if (fieldContext.invalid) {
|
|
58
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
59
|
+
"span",
|
|
60
|
+
{
|
|
61
|
+
...nativeProps,
|
|
62
|
+
"aria-hidden": "true",
|
|
63
|
+
"data-invalid": true,
|
|
64
|
+
className: (0, import_css.cx)(nativeProps.className, styles.statusIndicator),
|
|
65
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(InvalidIcon, {})
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
70
|
+
"span",
|
|
71
|
+
{
|
|
72
|
+
...nativeProps,
|
|
73
|
+
"aria-hidden": "true",
|
|
74
|
+
"data-part": "end-indicator",
|
|
75
|
+
className: (0, import_css.cx)(nativeProps.className, styles.endIndicator),
|
|
76
|
+
children: fallback
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// src/components/field/start-indicator.tsx
|
|
82
|
+
var import_css2 = require("@cerberus/styled-system/css");
|
|
83
|
+
var import_recipes2 = require("@cerberus/styled-system/recipes");
|
|
84
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
85
|
+
function FieldStartIndicator(props) {
|
|
86
|
+
const styles = (0, import_recipes2.field)();
|
|
87
|
+
if (!props.children) return null;
|
|
88
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
89
|
+
"span",
|
|
90
|
+
{
|
|
91
|
+
...props,
|
|
92
|
+
"data-part": "start-indicator",
|
|
93
|
+
className: (0, import_css2.cx)(props.className, styles.startIndicator)
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// src/components/field/primitives.tsx
|
|
99
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
100
|
+
function FieldRoot(props) {
|
|
101
|
+
const { size, ...fieldProps } = props;
|
|
102
|
+
const styles = (0, import_recipes3.field)({ size });
|
|
103
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
104
|
+
import_field.Field.Root,
|
|
105
|
+
{
|
|
106
|
+
...fieldProps,
|
|
107
|
+
className: (0, import_css3.cx)(styles.root, fieldProps.className)
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
function FieldLabel(props) {
|
|
112
|
+
const { children, ...nativeProps } = props;
|
|
113
|
+
const styles = (0, import_recipes3.field)();
|
|
114
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_field.Field.Label, { ...nativeProps, className: (0, import_css3.cx)(styles.label, props.className), children: [
|
|
115
|
+
children,
|
|
116
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_field.Field.RequiredIndicator, { children: "(required)" })
|
|
117
|
+
] });
|
|
118
|
+
}
|
|
119
|
+
function FieldInput(props) {
|
|
120
|
+
const { size, startIcon, endIcon, ...fieldProps } = props;
|
|
121
|
+
const styles = (0, import_recipes3.field)({ size });
|
|
122
|
+
const hasStartIcon = Boolean(startIcon);
|
|
123
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: styles.inputRoot, children: [
|
|
124
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FieldStartIndicator, { children: startIcon }),
|
|
125
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
126
|
+
import_field.Field.Input,
|
|
127
|
+
{
|
|
128
|
+
...fieldProps,
|
|
129
|
+
...hasStartIcon && { "data-has": "start-indicator" },
|
|
130
|
+
className: (0, import_css3.cx)(styles.input, fieldProps.className)
|
|
131
|
+
}
|
|
132
|
+
),
|
|
133
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FieldStatusIndicator, { fallback: endIcon })
|
|
134
|
+
] });
|
|
135
|
+
}
|
|
136
|
+
function FieldHelperText(props) {
|
|
137
|
+
const styles = (0, import_recipes3.field)();
|
|
138
|
+
if (!props.children) return null;
|
|
139
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
140
|
+
import_field.Field.HelperText,
|
|
141
|
+
{
|
|
142
|
+
...props,
|
|
143
|
+
className: (0, import_css3.cx)(styles.helperText, props.className)
|
|
144
|
+
}
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
function FieldErrorText(props) {
|
|
148
|
+
const styles = (0, import_recipes3.field)();
|
|
149
|
+
if (!props.children) return null;
|
|
150
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
151
|
+
import_field.Field.ErrorText,
|
|
152
|
+
{
|
|
153
|
+
...props,
|
|
154
|
+
className: (0, import_css3.cx)(styles.errorText, props.className)
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
function FieldTextarea(props) {
|
|
159
|
+
const styles = (0, import_recipes3.field)();
|
|
160
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
161
|
+
import_field.Field.Textarea,
|
|
162
|
+
{
|
|
163
|
+
...props,
|
|
164
|
+
className: (0, import_css3.cx)(styles.textarea, props.className)
|
|
165
|
+
}
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// src/components/field/parts.ts
|
|
170
|
+
var FieldParts = {
|
|
171
|
+
Root: FieldRoot,
|
|
172
|
+
Label: FieldLabel,
|
|
173
|
+
Input: FieldInput,
|
|
174
|
+
Textarea: FieldTextarea,
|
|
175
|
+
HelperText: FieldHelperText,
|
|
176
|
+
ErrorText: FieldErrorText,
|
|
177
|
+
StartIndicator: FieldStartIndicator,
|
|
178
|
+
StatusIndicator: FieldStatusIndicator
|
|
179
|
+
};
|
|
180
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
181
|
+
0 && (module.exports = {
|
|
182
|
+
FieldParts
|
|
183
|
+
});
|
|
184
|
+
//# sourceMappingURL=parts.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/field/parts.ts","../../../../src/components/field/primitives.tsx","../../../../src/components/field/status-indicator.tsx","../../../../src/context/cerberus.tsx","../../../../src/components/field/start-indicator.tsx"],"sourcesContent":["import type { ElementType } from 'react'\nimport {\n FieldErrorText,\n FieldHelperText,\n FieldInput,\n FieldLabel,\n FieldRoot,\n FieldTextarea,\n} from './primitives'\nimport { FieldStatusIndicator } from './status-indicator'\nimport { FieldStartIndicator } from './start-indicator'\n\n/**\n * This module contains the parts of the Field component.\n * @module 'field/parts'\n */\n\ninterface FieldPartsValue {\n /**\n * The container of the field.\n */\n Root: ElementType\n /**\n * The label of the field.\n */\n Label: ElementType\n /**\n * The input of the field.\n */\n Input: ElementType\n /**\n * The textarea of the field.\n */\n Textarea: ElementType\n /**\n * The text that displays when the field is valid.\n */\n HelperText: ElementType\n /**\n * The text that displays when the field is invalid.\n */\n ErrorText: ElementType\n /**\n * The indicator that appears at the start of the field.\n */\n StartIndicator: ElementType\n /**\n * The status indicator of the field.\n */\n StatusIndicator: ElementType\n}\n\n/**\n * An Object containing the parts of the Field component. For users that\n * prefer Object component syntax.\n *\n * @remarks\n *\n * When using object component syntax, you import the FieldParts object and\n * the entire family of components vs. only what you use.\n */\nexport const FieldParts: FieldPartsValue = {\n Root: FieldRoot,\n Label: FieldLabel,\n Input: FieldInput,\n Textarea: FieldTextarea,\n HelperText: FieldHelperText,\n ErrorText: FieldErrorText,\n StartIndicator: FieldStartIndicator,\n StatusIndicator: FieldStatusIndicator,\n}\n","import {\n Field,\n type FieldHelperTextProps,\n type FieldInputProps as ArkFieldInputProps,\n type FieldLabelProps,\n type FieldRootProps as ArkFieldRootProps,\n type FieldTextareaProps,\n} from '@ark-ui/react/field'\nimport type { ReactNode } from 'react'\nimport { cx } from '@cerberus/styled-system/css'\nimport { field, type FieldVariantProps } from '@cerberus/styled-system/recipes'\nimport { FieldStatusIndicator } from './status-indicator'\nimport { FieldStartIndicator } from './start-indicator'\n\n/**\n * This module contains all the primitives of the Field component.\n * @module 'field'\n */\n\nexport type FieldRootProps = ArkFieldRootProps & FieldVariantProps\n\n/**\n * The context & container for the Field components.\n * @description [Field Docs](https://cerberus.digitalu.design/react/field)\n * @example\n * ```tsx\n * <FieldRoot required ids={{ input: 'exampleId' }}>\n * <FieldLabel>Label</FieldLabel>\n * <FieldInput />\n * </FieldRoot>\n * ```\n */\nexport function FieldRoot(props: FieldRootProps) {\n const { size, ...fieldProps } = props\n const styles = field({ size })\n return (\n <Field.Root\n {...fieldProps}\n className={cx(styles.root, fieldProps.className)}\n />\n )\n}\n\n/**\n * The label for the Field component.\n * @description [Field Docs](https://cerberus.digitalu.design/react/field)\n * @example\n * ```tsx\n * <FieldRoot>\n * <FieldLabel>Label</FieldLabel>\n * </FieldRoot>\n * ```\n */\nexport function FieldLabel(props: FieldLabelProps) {\n const { children, ...nativeProps } = props\n const styles = field()\n return (\n <Field.Label {...nativeProps} className={cx(styles.label, props.className)}>\n {children}\n <Field.RequiredIndicator>(required)</Field.RequiredIndicator>\n </Field.Label>\n )\n}\n\nexport interface FieldInputProps\n extends Omit<ArkFieldInputProps, 'size'>,\n FieldVariantProps {\n /**\n * An optional icon to display at the start of the input.\n */\n startIcon?: ReactNode\n /**\n * An optional icon to display at the end of the input.\n */\n endIcon?: ReactNode\n}\n\n/**\n * The input for the Field component.\n * @description [Field Docs](https://cerberus.digitalu.design/react/field)\n * @example\n * ```tsx\n * <FieldRoot>\n * <FieldInput />\n * </FieldRoot>\n * ```\n */\nexport function FieldInput(props: FieldInputProps) {\n const { size, startIcon, endIcon, ...fieldProps } = props\n const styles = field({ size })\n const hasStartIcon = Boolean(startIcon)\n\n return (\n <div className={styles.inputRoot}>\n <FieldStartIndicator>{startIcon}</FieldStartIndicator>\n <Field.Input\n {...fieldProps}\n {...(hasStartIcon && { 'data-has': 'start-indicator' })}\n className={cx(styles.input, fieldProps.className)}\n />\n <FieldStatusIndicator fallback={endIcon} />\n </div>\n )\n}\n\n/**\n * The helper text for the Field component that is shown when the field is\n * valid.\n * @description [Field Docs](https://cerberus.digitalu.design/react/field)\n * @example\n * ```tsx\n * <FieldRoot>\n * <FieldInput />\n * <FieldHelperText>Helper text</FieldHelperText>\n * </FieldRoot>\n * ```\n */\nexport function FieldHelperText(props: FieldHelperTextProps) {\n const styles = field()\n\n if (!props.children) return null\n\n return (\n <Field.HelperText\n {...props}\n className={cx(styles.helperText, props.className)}\n />\n )\n}\n\n/**\n * The error text for the Field component that is shown when the field is\n * invalid.\n * @description [Field Docs](https://cerberus.digitalu.design/react/field)\n * @example\n * ```tsx\n * <FieldRoot>\n * <FieldInput />\n * <FieldErrorText>Error text</FieldErrorText>\n * </FieldRoot>\n * ```\n */\nexport function FieldErrorText(props: FieldHelperTextProps) {\n const styles = field()\n\n if (!props.children) return null\n\n return (\n <Field.ErrorText\n {...props}\n className={cx(styles.errorText, props.className)}\n />\n )\n}\n\n/**\n * The textarea for the Field component.\n * @description [Field Docs](https://cerberus.digitalu.design/react/field)\n * @example\n * ```tsx\n * <FieldRoot>\n * <FieldTextarea />\n * </FieldRoot>\n * ```\n */\nexport function FieldTextarea(props: FieldTextareaProps) {\n const styles = field()\n return (\n <Field.Textarea\n {...props}\n className={cx(styles.textarea, props.className)}\n />\n )\n}\n\n/**\n * A named export for the FieldInput component.\n * @description [Field Docs](https://cerberus.digitalu.design/react/field)\n * @example\n * ```tsx\n * import { Input } from '@cerberus/react'\n *\n * <Field\n * ids={{\n * control: 'email',\n * }}\n * label=\"Enter your email\"\n * helperText=\"We'll never share your email with anyone else.\"\n * errorText=\"Email is required.\"\n * required\n * >\n * <Input type=\"email\" />\n * </Field>\n * ```\n */\nexport const Input = FieldInput\nexport const Textarea = FieldTextarea\n","'use client'\n\nimport { useFieldContext } from '@ark-ui/react'\nimport { cx } from '@cerberus/styled-system/css'\nimport { field } from '@cerberus/styled-system/recipes'\nimport { useCerberusContext } from '../../context/cerberus'\nimport type { HTMLAttributes, ReactNode } from 'react'\n\nexport interface FieldStatusIndicatorProps\n extends HTMLAttributes<HTMLSpanElement> {\n /**\n * The fallback content to display when the field is valid.\n */\n fallback?: ReactNode\n}\n\n/**\n * The invalid status indicator for the Field component.\n * @description [Field Docs](https://cerberus.digitalu.design/react/field)\n * @example\n * ```tsx\n * <FieldRoot>\n * <FieldStatusIndicator />\n * </FieldRoot>\n * ```\n */\nexport function FieldStatusIndicator(props: FieldStatusIndicatorProps) {\n const { fallback, ...nativeProps } = props\n const styles = field()\n const fieldContext = useFieldContext()\n\n const { icons } = useCerberusContext()\n const { invalid: InvalidIcon } = icons\n\n if (fieldContext.invalid) {\n return (\n <span\n {...nativeProps}\n aria-hidden=\"true\"\n data-invalid\n className={cx(nativeProps.className, styles.statusIndicator)}\n >\n <InvalidIcon />\n </span>\n )\n }\n\n return (\n <span\n {...nativeProps}\n aria-hidden=\"true\"\n data-part=\"end-indicator\"\n className={cx(nativeProps.className, styles.endIndicator)}\n >\n {fallback}\n </span>\n )\n}\n","'use client'\n\nimport { createContext, useContext, type PropsWithChildren } from 'react'\nimport type { SystemConfig } from '../config'\n\n/**\n * This module contains the Cerberus configuration context and helpers.\n * @module context/cerberus\n */\n\ntype CerberusContextValue = SystemConfig\n\nconst CerberusContext = createContext<CerberusContextValue | null>(null)\n\ninterface CerberusProviderProps {\n config: SystemConfig\n}\n\n/**\n * Cerberus configuration provider.\n * @param props.config The Cerberus configuration created with\n * `makeSystemConfig` helper.\n */\nexport function CerberusProvider(\n props: PropsWithChildren<CerberusProviderProps>,\n) {\n return (\n <CerberusContext.Provider value={props.config}>\n {props.children}\n </CerberusContext.Provider>\n )\n}\n\n/**\n * Returns the Cerberus configuration context.\n * @returns The Cerberus configuration context.\n */\nexport function useCerberusContext() {\n const context = useContext(CerberusContext)\n if (!context) {\n throw new Error('useCerberus must be used within a CerberusProvider')\n }\n return context\n}\n","import { cx } from '@cerberus/styled-system/css'\nimport { field } from '@cerberus/styled-system/recipes'\nimport type { HTMLAttributes } from 'react'\n\nexport type FieldIndicatorProps = HTMLAttributes<HTMLSpanElement>\n\n/**\n * The start indicator displays an indicator at the start of the Input.\n * @description [Field Docs](https://cerberus.digitalu.design/react/field)\n */\nexport function FieldStartIndicator(props: FieldIndicatorProps) {\n const styles = field()\n\n if (!props.children) return null\n\n return (\n <span\n {...props}\n data-part=\"start-indicator\"\n className={cx(props.className, styles.startIndicator)}\n />\n )\n}\n"],"mappings":"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","names":["import_css","import_recipes","import_react","import_jsx_runtime","import_css","import_recipes","import_jsx_runtime","import_jsx_runtime"]}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/components/field/primitives.tsx
|
|
21
|
+
var primitives_exports = {};
|
|
22
|
+
__export(primitives_exports, {
|
|
23
|
+
FieldErrorText: () => FieldErrorText,
|
|
24
|
+
FieldHelperText: () => FieldHelperText,
|
|
25
|
+
FieldInput: () => FieldInput,
|
|
26
|
+
FieldLabel: () => FieldLabel,
|
|
27
|
+
FieldRoot: () => FieldRoot,
|
|
28
|
+
FieldTextarea: () => FieldTextarea,
|
|
29
|
+
Input: () => Input,
|
|
30
|
+
Textarea: () => Textarea
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(primitives_exports);
|
|
33
|
+
var import_field = require("@ark-ui/react/field");
|
|
34
|
+
var import_css3 = require("@cerberus/styled-system/css");
|
|
35
|
+
var import_recipes3 = require("@cerberus/styled-system/recipes");
|
|
36
|
+
|
|
37
|
+
// src/components/field/status-indicator.tsx
|
|
38
|
+
var import_react2 = require("@ark-ui/react");
|
|
39
|
+
var import_css = require("@cerberus/styled-system/css");
|
|
40
|
+
var import_recipes = require("@cerberus/styled-system/recipes");
|
|
41
|
+
|
|
42
|
+
// src/context/cerberus.tsx
|
|
43
|
+
var import_react = require("react");
|
|
44
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
45
|
+
var CerberusContext = (0, import_react.createContext)(null);
|
|
46
|
+
function useCerberusContext() {
|
|
47
|
+
const context = (0, import_react.useContext)(CerberusContext);
|
|
48
|
+
if (!context) {
|
|
49
|
+
throw new Error("useCerberus must be used within a CerberusProvider");
|
|
50
|
+
}
|
|
51
|
+
return context;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// src/components/field/status-indicator.tsx
|
|
55
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
56
|
+
function FieldStatusIndicator(props) {
|
|
57
|
+
const { fallback, ...nativeProps } = props;
|
|
58
|
+
const styles = (0, import_recipes.field)();
|
|
59
|
+
const fieldContext = (0, import_react2.useFieldContext)();
|
|
60
|
+
const { icons } = useCerberusContext();
|
|
61
|
+
const { invalid: InvalidIcon } = icons;
|
|
62
|
+
if (fieldContext.invalid) {
|
|
63
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
64
|
+
"span",
|
|
65
|
+
{
|
|
66
|
+
...nativeProps,
|
|
67
|
+
"aria-hidden": "true",
|
|
68
|
+
"data-invalid": true,
|
|
69
|
+
className: (0, import_css.cx)(nativeProps.className, styles.statusIndicator),
|
|
70
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(InvalidIcon, {})
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
75
|
+
"span",
|
|
76
|
+
{
|
|
77
|
+
...nativeProps,
|
|
78
|
+
"aria-hidden": "true",
|
|
79
|
+
"data-part": "end-indicator",
|
|
80
|
+
className: (0, import_css.cx)(nativeProps.className, styles.endIndicator),
|
|
81
|
+
children: fallback
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// src/components/field/start-indicator.tsx
|
|
87
|
+
var import_css2 = require("@cerberus/styled-system/css");
|
|
88
|
+
var import_recipes2 = require("@cerberus/styled-system/recipes");
|
|
89
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
90
|
+
function FieldStartIndicator(props) {
|
|
91
|
+
const styles = (0, import_recipes2.field)();
|
|
92
|
+
if (!props.children) return null;
|
|
93
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
94
|
+
"span",
|
|
95
|
+
{
|
|
96
|
+
...props,
|
|
97
|
+
"data-part": "start-indicator",
|
|
98
|
+
className: (0, import_css2.cx)(props.className, styles.startIndicator)
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// src/components/field/primitives.tsx
|
|
104
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
105
|
+
function FieldRoot(props) {
|
|
106
|
+
const { size, ...fieldProps } = props;
|
|
107
|
+
const styles = (0, import_recipes3.field)({ size });
|
|
108
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
109
|
+
import_field.Field.Root,
|
|
110
|
+
{
|
|
111
|
+
...fieldProps,
|
|
112
|
+
className: (0, import_css3.cx)(styles.root, fieldProps.className)
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
function FieldLabel(props) {
|
|
117
|
+
const { children, ...nativeProps } = props;
|
|
118
|
+
const styles = (0, import_recipes3.field)();
|
|
119
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_field.Field.Label, { ...nativeProps, className: (0, import_css3.cx)(styles.label, props.className), children: [
|
|
120
|
+
children,
|
|
121
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_field.Field.RequiredIndicator, { children: "(required)" })
|
|
122
|
+
] });
|
|
123
|
+
}
|
|
124
|
+
function FieldInput(props) {
|
|
125
|
+
const { size, startIcon, endIcon, ...fieldProps } = props;
|
|
126
|
+
const styles = (0, import_recipes3.field)({ size });
|
|
127
|
+
const hasStartIcon = Boolean(startIcon);
|
|
128
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: styles.inputRoot, children: [
|
|
129
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FieldStartIndicator, { children: startIcon }),
|
|
130
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
131
|
+
import_field.Field.Input,
|
|
132
|
+
{
|
|
133
|
+
...fieldProps,
|
|
134
|
+
...hasStartIcon && { "data-has": "start-indicator" },
|
|
135
|
+
className: (0, import_css3.cx)(styles.input, fieldProps.className)
|
|
136
|
+
}
|
|
137
|
+
),
|
|
138
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FieldStatusIndicator, { fallback: endIcon })
|
|
139
|
+
] });
|
|
140
|
+
}
|
|
141
|
+
function FieldHelperText(props) {
|
|
142
|
+
const styles = (0, import_recipes3.field)();
|
|
143
|
+
if (!props.children) return null;
|
|
144
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
145
|
+
import_field.Field.HelperText,
|
|
146
|
+
{
|
|
147
|
+
...props,
|
|
148
|
+
className: (0, import_css3.cx)(styles.helperText, props.className)
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
function FieldErrorText(props) {
|
|
153
|
+
const styles = (0, import_recipes3.field)();
|
|
154
|
+
if (!props.children) return null;
|
|
155
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
156
|
+
import_field.Field.ErrorText,
|
|
157
|
+
{
|
|
158
|
+
...props,
|
|
159
|
+
className: (0, import_css3.cx)(styles.errorText, props.className)
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
function FieldTextarea(props) {
|
|
164
|
+
const styles = (0, import_recipes3.field)();
|
|
165
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
166
|
+
import_field.Field.Textarea,
|
|
167
|
+
{
|
|
168
|
+
...props,
|
|
169
|
+
className: (0, import_css3.cx)(styles.textarea, props.className)
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
var Input = FieldInput;
|
|
174
|
+
var Textarea = FieldTextarea;
|
|
175
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
176
|
+
0 && (module.exports = {
|
|
177
|
+
FieldErrorText,
|
|
178
|
+
FieldHelperText,
|
|
179
|
+
FieldInput,
|
|
180
|
+
FieldLabel,
|
|
181
|
+
FieldRoot,
|
|
182
|
+
FieldTextarea,
|
|
183
|
+
Input,
|
|
184
|
+
Textarea
|
|
185
|
+
});
|
|
186
|
+
//# sourceMappingURL=primitives.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/field/primitives.tsx","../../../../src/components/field/status-indicator.tsx","../../../../src/context/cerberus.tsx","../../../../src/components/field/start-indicator.tsx"],"sourcesContent":["import {\n Field,\n type FieldHelperTextProps,\n type FieldInputProps as ArkFieldInputProps,\n type FieldLabelProps,\n type FieldRootProps as ArkFieldRootProps,\n type FieldTextareaProps,\n} from '@ark-ui/react/field'\nimport type { ReactNode } from 'react'\nimport { cx } from '@cerberus/styled-system/css'\nimport { field, type FieldVariantProps } from '@cerberus/styled-system/recipes'\nimport { FieldStatusIndicator } from './status-indicator'\nimport { FieldStartIndicator } from './start-indicator'\n\n/**\n * This module contains all the primitives of the Field component.\n * @module 'field'\n */\n\nexport type FieldRootProps = ArkFieldRootProps & FieldVariantProps\n\n/**\n * The context & container for the Field components.\n * @description [Field Docs](https://cerberus.digitalu.design/react/field)\n * @example\n * ```tsx\n * <FieldRoot required ids={{ input: 'exampleId' }}>\n * <FieldLabel>Label</FieldLabel>\n * <FieldInput />\n * </FieldRoot>\n * ```\n */\nexport function FieldRoot(props: FieldRootProps) {\n const { size, ...fieldProps } = props\n const styles = field({ size })\n return (\n <Field.Root\n {...fieldProps}\n className={cx(styles.root, fieldProps.className)}\n />\n )\n}\n\n/**\n * The label for the Field component.\n * @description [Field Docs](https://cerberus.digitalu.design/react/field)\n * @example\n * ```tsx\n * <FieldRoot>\n * <FieldLabel>Label</FieldLabel>\n * </FieldRoot>\n * ```\n */\nexport function FieldLabel(props: FieldLabelProps) {\n const { children, ...nativeProps } = props\n const styles = field()\n return (\n <Field.Label {...nativeProps} className={cx(styles.label, props.className)}>\n {children}\n <Field.RequiredIndicator>(required)</Field.RequiredIndicator>\n </Field.Label>\n )\n}\n\nexport interface FieldInputProps\n extends Omit<ArkFieldInputProps, 'size'>,\n FieldVariantProps {\n /**\n * An optional icon to display at the start of the input.\n */\n startIcon?: ReactNode\n /**\n * An optional icon to display at the end of the input.\n */\n endIcon?: ReactNode\n}\n\n/**\n * The input for the Field component.\n * @description [Field Docs](https://cerberus.digitalu.design/react/field)\n * @example\n * ```tsx\n * <FieldRoot>\n * <FieldInput />\n * </FieldRoot>\n * ```\n */\nexport function FieldInput(props: FieldInputProps) {\n const { size, startIcon, endIcon, ...fieldProps } = props\n const styles = field({ size })\n const hasStartIcon = Boolean(startIcon)\n\n return (\n <div className={styles.inputRoot}>\n <FieldStartIndicator>{startIcon}</FieldStartIndicator>\n <Field.Input\n {...fieldProps}\n {...(hasStartIcon && { 'data-has': 'start-indicator' })}\n className={cx(styles.input, fieldProps.className)}\n />\n <FieldStatusIndicator fallback={endIcon} />\n </div>\n )\n}\n\n/**\n * The helper text for the Field component that is shown when the field is\n * valid.\n * @description [Field Docs](https://cerberus.digitalu.design/react/field)\n * @example\n * ```tsx\n * <FieldRoot>\n * <FieldInput />\n * <FieldHelperText>Helper text</FieldHelperText>\n * </FieldRoot>\n * ```\n */\nexport function FieldHelperText(props: FieldHelperTextProps) {\n const styles = field()\n\n if (!props.children) return null\n\n return (\n <Field.HelperText\n {...props}\n className={cx(styles.helperText, props.className)}\n />\n )\n}\n\n/**\n * The error text for the Field component that is shown when the field is\n * invalid.\n * @description [Field Docs](https://cerberus.digitalu.design/react/field)\n * @example\n * ```tsx\n * <FieldRoot>\n * <FieldInput />\n * <FieldErrorText>Error text</FieldErrorText>\n * </FieldRoot>\n * ```\n */\nexport function FieldErrorText(props: FieldHelperTextProps) {\n const styles = field()\n\n if (!props.children) return null\n\n return (\n <Field.ErrorText\n {...props}\n className={cx(styles.errorText, props.className)}\n />\n )\n}\n\n/**\n * The textarea for the Field component.\n * @description [Field Docs](https://cerberus.digitalu.design/react/field)\n * @example\n * ```tsx\n * <FieldRoot>\n * <FieldTextarea />\n * </FieldRoot>\n * ```\n */\nexport function FieldTextarea(props: FieldTextareaProps) {\n const styles = field()\n return (\n <Field.Textarea\n {...props}\n className={cx(styles.textarea, props.className)}\n />\n )\n}\n\n/**\n * A named export for the FieldInput component.\n * @description [Field Docs](https://cerberus.digitalu.design/react/field)\n * @example\n * ```tsx\n * import { Input } from '@cerberus/react'\n *\n * <Field\n * ids={{\n * control: 'email',\n * }}\n * label=\"Enter your email\"\n * helperText=\"We'll never share your email with anyone else.\"\n * errorText=\"Email is required.\"\n * required\n * >\n * <Input type=\"email\" />\n * </Field>\n * ```\n */\nexport const Input = FieldInput\nexport const Textarea = FieldTextarea\n","'use client'\n\nimport { useFieldContext } from '@ark-ui/react'\nimport { cx } from '@cerberus/styled-system/css'\nimport { field } from '@cerberus/styled-system/recipes'\nimport { useCerberusContext } from '../../context/cerberus'\nimport type { HTMLAttributes, ReactNode } from 'react'\n\nexport interface FieldStatusIndicatorProps\n extends HTMLAttributes<HTMLSpanElement> {\n /**\n * The fallback content to display when the field is valid.\n */\n fallback?: ReactNode\n}\n\n/**\n * The invalid status indicator for the Field component.\n * @description [Field Docs](https://cerberus.digitalu.design/react/field)\n * @example\n * ```tsx\n * <FieldRoot>\n * <FieldStatusIndicator />\n * </FieldRoot>\n * ```\n */\nexport function FieldStatusIndicator(props: FieldStatusIndicatorProps) {\n const { fallback, ...nativeProps } = props\n const styles = field()\n const fieldContext = useFieldContext()\n\n const { icons } = useCerberusContext()\n const { invalid: InvalidIcon } = icons\n\n if (fieldContext.invalid) {\n return (\n <span\n {...nativeProps}\n aria-hidden=\"true\"\n data-invalid\n className={cx(nativeProps.className, styles.statusIndicator)}\n >\n <InvalidIcon />\n </span>\n )\n }\n\n return (\n <span\n {...nativeProps}\n aria-hidden=\"true\"\n data-part=\"end-indicator\"\n className={cx(nativeProps.className, styles.endIndicator)}\n >\n {fallback}\n </span>\n )\n}\n","'use client'\n\nimport { createContext, useContext, type PropsWithChildren } from 'react'\nimport type { SystemConfig } from '../config'\n\n/**\n * This module contains the Cerberus configuration context and helpers.\n * @module context/cerberus\n */\n\ntype CerberusContextValue = SystemConfig\n\nconst CerberusContext = createContext<CerberusContextValue | null>(null)\n\ninterface CerberusProviderProps {\n config: SystemConfig\n}\n\n/**\n * Cerberus configuration provider.\n * @param props.config The Cerberus configuration created with\n * `makeSystemConfig` helper.\n */\nexport function CerberusProvider(\n props: PropsWithChildren<CerberusProviderProps>,\n) {\n return (\n <CerberusContext.Provider value={props.config}>\n {props.children}\n </CerberusContext.Provider>\n )\n}\n\n/**\n * Returns the Cerberus configuration context.\n * @returns The Cerberus configuration context.\n */\nexport function useCerberusContext() {\n const context = useContext(CerberusContext)\n if (!context) {\n throw new Error('useCerberus must be used within a CerberusProvider')\n }\n return context\n}\n","import { cx } from '@cerberus/styled-system/css'\nimport { field } from '@cerberus/styled-system/recipes'\nimport type { HTMLAttributes } from 'react'\n\nexport type FieldIndicatorProps = HTMLAttributes<HTMLSpanElement>\n\n/**\n * The start indicator displays an indicator at the start of the Input.\n * @description [Field Docs](https://cerberus.digitalu.design/react/field)\n */\nexport function FieldStartIndicator(props: FieldIndicatorProps) {\n const styles = field()\n\n if (!props.children) return null\n\n return (\n <span\n {...props}\n data-part=\"start-indicator\"\n className={cx(props.className, styles.startIndicator)}\n />\n )\n}\n"],"mappings":"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","names":["import_css","import_recipes","import_react","import_jsx_runtime","import_css","import_recipes","import_jsx_runtime","import_jsx_runtime"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/components/field/start-indicator.tsx
|
|
21
|
+
var start_indicator_exports = {};
|
|
22
|
+
__export(start_indicator_exports, {
|
|
23
|
+
FieldStartIndicator: () => FieldStartIndicator
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(start_indicator_exports);
|
|
26
|
+
var import_css = require("@cerberus/styled-system/css");
|
|
27
|
+
var import_recipes = require("@cerberus/styled-system/recipes");
|
|
28
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
29
|
+
function FieldStartIndicator(props) {
|
|
30
|
+
const styles = (0, import_recipes.field)();
|
|
31
|
+
if (!props.children) return null;
|
|
32
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
33
|
+
"span",
|
|
34
|
+
{
|
|
35
|
+
...props,
|
|
36
|
+
"data-part": "start-indicator",
|
|
37
|
+
className: (0, import_css.cx)(props.className, styles.startIndicator)
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
+
0 && (module.exports = {
|
|
43
|
+
FieldStartIndicator
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=start-indicator.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/field/start-indicator.tsx"],"sourcesContent":["import { cx } from '@cerberus/styled-system/css'\nimport { field } from '@cerberus/styled-system/recipes'\nimport type { HTMLAttributes } from 'react'\n\nexport type FieldIndicatorProps = HTMLAttributes<HTMLSpanElement>\n\n/**\n * The start indicator displays an indicator at the start of the Input.\n * @description [Field Docs](https://cerberus.digitalu.design/react/field)\n */\nexport function FieldStartIndicator(props: FieldIndicatorProps) {\n const styles = field()\n\n if (!props.children) return null\n\n return (\n <span\n {...props}\n data-part=\"start-indicator\"\n className={cx(props.className, styles.startIndicator)}\n />\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAmB;AACnB,qBAAsB;AAelB;AANG,SAAS,oBAAoB,OAA4B;AAC9D,QAAM,aAAS,sBAAM;AAErB,MAAI,CAAC,MAAM,SAAU,QAAO;AAE5B,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,aAAU;AAAA,MACV,eAAW,eAAG,MAAM,WAAW,OAAO,cAAc;AAAA;AAAA,EACtD;AAEJ;","names":[]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/components/field/status-indicator.tsx
|
|
22
|
+
var status_indicator_exports = {};
|
|
23
|
+
__export(status_indicator_exports, {
|
|
24
|
+
FieldStatusIndicator: () => FieldStatusIndicator
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(status_indicator_exports);
|
|
27
|
+
var import_react2 = require("@ark-ui/react");
|
|
28
|
+
var import_css = require("@cerberus/styled-system/css");
|
|
29
|
+
var import_recipes = require("@cerberus/styled-system/recipes");
|
|
30
|
+
|
|
31
|
+
// src/context/cerberus.tsx
|
|
32
|
+
var import_react = require("react");
|
|
33
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
+
var CerberusContext = (0, import_react.createContext)(null);
|
|
35
|
+
function useCerberusContext() {
|
|
36
|
+
const context = (0, import_react.useContext)(CerberusContext);
|
|
37
|
+
if (!context) {
|
|
38
|
+
throw new Error("useCerberus must be used within a CerberusProvider");
|
|
39
|
+
}
|
|
40
|
+
return context;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// src/components/field/status-indicator.tsx
|
|
44
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
45
|
+
function FieldStatusIndicator(props) {
|
|
46
|
+
const { fallback, ...nativeProps } = props;
|
|
47
|
+
const styles = (0, import_recipes.field)();
|
|
48
|
+
const fieldContext = (0, import_react2.useFieldContext)();
|
|
49
|
+
const { icons } = useCerberusContext();
|
|
50
|
+
const { invalid: InvalidIcon } = icons;
|
|
51
|
+
if (fieldContext.invalid) {
|
|
52
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
53
|
+
"span",
|
|
54
|
+
{
|
|
55
|
+
...nativeProps,
|
|
56
|
+
"aria-hidden": "true",
|
|
57
|
+
"data-invalid": true,
|
|
58
|
+
className: (0, import_css.cx)(nativeProps.className, styles.statusIndicator),
|
|
59
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(InvalidIcon, {})
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
64
|
+
"span",
|
|
65
|
+
{
|
|
66
|
+
...nativeProps,
|
|
67
|
+
"aria-hidden": "true",
|
|
68
|
+
"data-part": "end-indicator",
|
|
69
|
+
className: (0, import_css.cx)(nativeProps.className, styles.endIndicator),
|
|
70
|
+
children: fallback
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
+
0 && (module.exports = {
|
|
76
|
+
FieldStatusIndicator
|
|
77
|
+
});
|
|
78
|
+
//# sourceMappingURL=status-indicator.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/field/status-indicator.tsx","../../../../src/context/cerberus.tsx"],"sourcesContent":["'use client'\n\nimport { useFieldContext } from '@ark-ui/react'\nimport { cx } from '@cerberus/styled-system/css'\nimport { field } from '@cerberus/styled-system/recipes'\nimport { useCerberusContext } from '../../context/cerberus'\nimport type { HTMLAttributes, ReactNode } from 'react'\n\nexport interface FieldStatusIndicatorProps\n extends HTMLAttributes<HTMLSpanElement> {\n /**\n * The fallback content to display when the field is valid.\n */\n fallback?: ReactNode\n}\n\n/**\n * The invalid status indicator for the Field component.\n * @description [Field Docs](https://cerberus.digitalu.design/react/field)\n * @example\n * ```tsx\n * <FieldRoot>\n * <FieldStatusIndicator />\n * </FieldRoot>\n * ```\n */\nexport function FieldStatusIndicator(props: FieldStatusIndicatorProps) {\n const { fallback, ...nativeProps } = props\n const styles = field()\n const fieldContext = useFieldContext()\n\n const { icons } = useCerberusContext()\n const { invalid: InvalidIcon } = icons\n\n if (fieldContext.invalid) {\n return (\n <span\n {...nativeProps}\n aria-hidden=\"true\"\n data-invalid\n className={cx(nativeProps.className, styles.statusIndicator)}\n >\n <InvalidIcon />\n </span>\n )\n }\n\n return (\n <span\n {...nativeProps}\n aria-hidden=\"true\"\n data-part=\"end-indicator\"\n className={cx(nativeProps.className, styles.endIndicator)}\n >\n {fallback}\n </span>\n )\n}\n","'use client'\n\nimport { createContext, useContext, type PropsWithChildren } from 'react'\nimport type { SystemConfig } from '../config'\n\n/**\n * This module contains the Cerberus configuration context and helpers.\n * @module context/cerberus\n */\n\ntype CerberusContextValue = SystemConfig\n\nconst CerberusContext = createContext<CerberusContextValue | null>(null)\n\ninterface CerberusProviderProps {\n config: SystemConfig\n}\n\n/**\n * Cerberus configuration provider.\n * @param props.config The Cerberus configuration created with\n * `makeSystemConfig` helper.\n */\nexport function CerberusProvider(\n props: PropsWithChildren<CerberusProviderProps>,\n) {\n return (\n <CerberusContext.Provider value={props.config}>\n {props.children}\n </CerberusContext.Provider>\n )\n}\n\n/**\n * Returns the Cerberus configuration context.\n * @returns The Cerberus configuration context.\n */\nexport function useCerberusContext() {\n const context = useContext(CerberusContext)\n if (!context) {\n throw new Error('useCerberus must be used within a CerberusProvider')\n }\n return context\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAAA,gBAAgC;AAChC,iBAAmB;AACnB,qBAAsB;;;ACFtB,mBAAkE;AAyB9D;AAfJ,IAAM,sBAAkB,4BAA2C,IAAI;AAyBhE,SAAS,qBAAqB;AACnC,QAAM,cAAU,yBAAW,eAAe;AAC1C,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,oDAAoD;AAAA,EACtE;AACA,SAAO;AACT;;;ADDQ,IAAAC,sBAAA;AAhBD,SAAS,qBAAqB,OAAkC;AACrE,QAAM,EAAE,UAAU,GAAG,YAAY,IAAI;AACrC,QAAM,aAAS,sBAAM;AACrB,QAAM,mBAAe,+BAAgB;AAErC,QAAM,EAAE,MAAM,IAAI,mBAAmB;AACrC,QAAM,EAAE,SAAS,YAAY,IAAI;AAEjC,MAAI,aAAa,SAAS;AACxB,WACE;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACJ,eAAY;AAAA,QACZ,gBAAY;AAAA,QACZ,eAAW,eAAG,YAAY,WAAW,OAAO,eAAe;AAAA,QAE3D,uDAAC,eAAY;AAAA;AAAA,IACf;AAAA,EAEJ;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,eAAY;AAAA,MACZ,aAAU;AAAA,MACV,eAAW,eAAG,YAAY,WAAW,OAAO,YAAY;AAAA,MAEvD;AAAA;AAAA,EACH;AAEJ;","names":["import_react","import_jsx_runtime"]}
|
|
@@ -31,6 +31,7 @@ var import_react6 = require("react");
|
|
|
31
31
|
var import_react2 = require("react");
|
|
32
32
|
var import_css = require("@cerberus/styled-system/css");
|
|
33
33
|
var import_recipes = require("@cerberus/styled-system/recipes");
|
|
34
|
+
var import_jsx = require("@cerberus/styled-system/jsx");
|
|
34
35
|
|
|
35
36
|
// src/components/Show.tsx
|
|
36
37
|
var import_react = require("react");
|
|
@@ -44,7 +45,6 @@ function Show(props) {
|
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
// src/components/button/button.tsx
|
|
47
|
-
var import_jsx = require("@cerberus/styled-system/jsx");
|
|
48
48
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
49
49
|
var ButtonContext = (0, import_react2.createContext)({
|
|
50
50
|
pending: false
|