@fuf-stack/uniform 0.14.4 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CheckboxGroup/index.cjs +7 -6
- package/dist/CheckboxGroup/index.cjs.map +1 -1
- package/dist/CheckboxGroup/index.js +6 -5
- package/dist/Controller/index.cjs +4 -2
- package/dist/Controller/index.cjs.map +1 -1
- package/dist/Controller/index.d.cts +7 -3
- package/dist/Controller/index.d.ts +7 -3
- package/dist/Controller/index.js +7 -5
- package/dist/Controller-8Nqugui5.d.cts +37 -0
- package/dist/Controller-8Nqugui5.d.ts +37 -0
- package/dist/FieldArray/index.cjs +6 -5
- package/dist/FieldArray/index.cjs.map +1 -1
- package/dist/FieldArray/index.d.cts +5 -3
- package/dist/FieldArray/index.d.ts +5 -3
- package/dist/FieldArray/index.js +5 -4
- package/dist/FieldArray-AqM2XKIh.d.cts +151 -0
- package/dist/FieldArray-AqM2XKIh.d.ts +151 -0
- package/dist/Form/index.cjs +5 -4
- package/dist/Form/index.cjs.map +1 -1
- package/dist/Form/index.js +4 -3
- package/dist/Grid/index.cjs +1 -0
- package/dist/Grid/index.cjs.map +1 -1
- package/dist/Grid/index.js +1 -0
- package/dist/Input/index.cjs +7 -6
- package/dist/Input/index.cjs.map +1 -1
- package/dist/Input/index.js +6 -5
- package/dist/RadioGroup/index.cjs +7 -6
- package/dist/RadioGroup/index.cjs.map +1 -1
- package/dist/RadioGroup/index.js +6 -5
- package/dist/Select/index.cjs +7 -6
- package/dist/Select/index.cjs.map +1 -1
- package/dist/Select/index.js +6 -5
- package/dist/SubmitButton/index.cjs +5 -4
- package/dist/SubmitButton/index.cjs.map +1 -1
- package/dist/SubmitButton/index.js +4 -3
- package/dist/Switch/index.cjs +7 -6
- package/dist/Switch/index.cjs.map +1 -1
- package/dist/Switch/index.js +6 -5
- package/dist/TextArea/index.cjs +7 -6
- package/dist/TextArea/index.cjs.map +1 -1
- package/dist/TextArea/index.js +6 -5
- package/dist/{chunk-DDZMDOSG.js → chunk-2LAPLELO.js} +21 -17
- package/dist/{chunk-DDZMDOSG.js.map → chunk-2LAPLELO.js.map} +1 -1
- package/dist/chunk-2NSCPLAA.cjs +133 -0
- package/dist/chunk-2NSCPLAA.cjs.map +1 -0
- package/dist/{chunk-TR2J3OKH.js → chunk-3Q37222E.js} +20 -13
- package/dist/chunk-3Q37222E.js.map +1 -0
- package/dist/chunk-4AXNPSXG.cjs +82 -0
- package/dist/chunk-4AXNPSXG.cjs.map +1 -0
- package/dist/chunk-4DAZAO6Y.cjs +59 -0
- package/dist/chunk-4DAZAO6Y.cjs.map +1 -0
- package/dist/chunk-4EJS5FXY.js +51 -0
- package/dist/chunk-4EJS5FXY.js.map +1 -0
- package/dist/chunk-4EP3IGSK.cjs +372 -0
- package/dist/chunk-4EP3IGSK.cjs.map +1 -0
- package/dist/{chunk-25LLM544.cjs → chunk-4M6F2O2K.cjs} +11 -9
- package/dist/chunk-4M6F2O2K.cjs.map +1 -0
- package/dist/{chunk-XJGJ5ZNM.js → chunk-7HK64PN5.js} +38 -22
- package/dist/chunk-7HK64PN5.js.map +1 -0
- package/dist/{chunk-OHJYXA6R.cjs → chunk-C4RM2JSD.cjs} +3 -3
- package/dist/{chunk-OHJYXA6R.cjs.map → chunk-C4RM2JSD.cjs.map} +1 -1
- package/dist/chunk-CRTRMMJ7.js +59 -0
- package/dist/chunk-CRTRMMJ7.js.map +1 -0
- package/dist/{chunk-EKE5URXQ.cjs → chunk-F6KTQXWG.cjs} +15 -12
- package/dist/chunk-F6KTQXWG.cjs.map +1 -0
- package/dist/{chunk-RY4F5YDS.cjs → chunk-FLX6VIO7.cjs} +42 -26
- package/dist/chunk-FLX6VIO7.cjs.map +1 -0
- package/dist/chunk-IEF2GJ22.js +82 -0
- package/dist/chunk-IEF2GJ22.js.map +1 -0
- package/dist/chunk-K43U2JVG.cjs +248 -0
- package/dist/chunk-K43U2JVG.cjs.map +1 -0
- package/dist/{chunk-XJZAS7NG.cjs → chunk-MF4JB3YT.cjs} +25 -21
- package/dist/chunk-MF4JB3YT.cjs.map +1 -0
- package/dist/{chunk-BZAPTLMC.js → chunk-MRXNKY72.js} +49 -49
- package/dist/chunk-MRXNKY72.js.map +1 -0
- package/dist/chunk-OBQDQ4RX.js +372 -0
- package/dist/chunk-OBQDQ4RX.js.map +1 -0
- package/dist/{chunk-VP7WDLJM.js → chunk-P4PRVNCH.js} +17 -13
- package/dist/chunk-P4PRVNCH.js.map +1 -0
- package/dist/{chunk-PZ4LZQI4.cjs → chunk-QLQR44AD.cjs} +19 -15
- package/dist/chunk-QLQR44AD.cjs.map +1 -0
- package/dist/{chunk-AQHKELUR.js → chunk-U26GTLKF.js} +10 -8
- package/dist/chunk-U26GTLKF.js.map +1 -0
- package/dist/{chunk-GN5NJ6ZU.js → chunk-UJYXA5AD.js} +3 -3
- package/dist/chunk-V5HTEMWZ.cjs +51 -0
- package/dist/chunk-V5HTEMWZ.cjs.map +1 -0
- package/dist/{chunk-VZ5MMFIF.cjs → chunk-V7LRZ5GK.cjs} +5 -5
- package/dist/{chunk-VZ5MMFIF.cjs.map → chunk-V7LRZ5GK.cjs.map} +1 -1
- package/dist/{chunk-WKM2D7LF.js → chunk-VX76MJAI.js} +2 -2
- package/dist/chunk-W66BVPTB.js +248 -0
- package/dist/{chunk-IUNDGVMC.js.map → chunk-W66BVPTB.js.map} +1 -1
- package/dist/{chunk-BS52M4SZ.js → chunk-WAXJ64P7.js} +14 -11
- package/dist/chunk-WAXJ64P7.js.map +1 -0
- package/dist/{chunk-U6VUNJZG.cjs → chunk-Y4AUJ2YA.cjs} +21 -14
- package/dist/chunk-Y4AUJ2YA.cjs.map +1 -0
- package/dist/helpers/index.cjs +11 -2
- package/dist/helpers/index.cjs.map +1 -1
- package/dist/helpers/index.d.cts +68 -1
- package/dist/helpers/index.d.ts +68 -1
- package/dist/helpers/index.js +12 -3
- package/dist/hooks/index.cjs +6 -3
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +3 -2
- package/dist/hooks/index.d.ts +3 -2
- package/dist/hooks/index.js +7 -4
- package/dist/index.cjs +25 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +33 -22
- package/dist/partials/FieldCopyTestIdButton/index.cjs +1 -0
- package/dist/partials/FieldCopyTestIdButton/index.cjs.map +1 -1
- package/dist/partials/FieldCopyTestIdButton/index.js +1 -0
- package/dist/partials/FieldValidationError/index.cjs +4 -3
- package/dist/partials/FieldValidationError/index.cjs.map +1 -1
- package/dist/partials/FieldValidationError/index.js +3 -2
- package/package.json +18 -18
- package/dist/FieldArray-DD9z-xZ3.d.cts +0 -37
- package/dist/FieldArray-DD9z-xZ3.d.ts +0 -37
- package/dist/chunk-25LLM544.cjs.map +0 -1
- package/dist/chunk-AQHKELUR.js.map +0 -1
- package/dist/chunk-BBB4FEY6.cjs +0 -22
- package/dist/chunk-BBB4FEY6.cjs.map +0 -1
- package/dist/chunk-BS52M4SZ.js.map +0 -1
- package/dist/chunk-BZAPTLMC.js.map +0 -1
- package/dist/chunk-EKE5URXQ.cjs.map +0 -1
- package/dist/chunk-HOETR36J.cjs +0 -299
- package/dist/chunk-HOETR36J.cjs.map +0 -1
- package/dist/chunk-HZP3EXGR.cjs +0 -241
- package/dist/chunk-HZP3EXGR.cjs.map +0 -1
- package/dist/chunk-IUNDGVMC.js +0 -241
- package/dist/chunk-KOKIM2ND.js +0 -9
- package/dist/chunk-KOKIM2ND.js.map +0 -1
- package/dist/chunk-PZ4LZQI4.cjs.map +0 -1
- package/dist/chunk-RY4F5YDS.cjs.map +0 -1
- package/dist/chunk-TR2J3OKH.js.map +0 -1
- package/dist/chunk-U6VUNJZG.cjs.map +0 -1
- package/dist/chunk-V46BHM2U.js +0 -22
- package/dist/chunk-V46BHM2U.js.map +0 -1
- package/dist/chunk-VP7WDLJM.js.map +0 -1
- package/dist/chunk-VQWKXSHW.cjs +0 -9
- package/dist/chunk-VQWKXSHW.cjs.map +0 -1
- package/dist/chunk-XJGJ5ZNM.js.map +0 -1
- package/dist/chunk-XJWEUCV3.cjs +0 -133
- package/dist/chunk-XJWEUCV3.cjs.map +0 -1
- package/dist/chunk-XJZAS7NG.cjs.map +0 -1
- package/dist/chunk-Y53IHK6B.js +0 -299
- package/dist/chunk-Y53IHK6B.js.map +0 -1
- /package/dist/{chunk-GN5NJ6ZU.js.map → chunk-UJYXA5AD.js.map} +0 -0
- /package/dist/{chunk-WKM2D7LF.js.map → chunk-VX76MJAI.js.map} +0 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
+
|
|
3
|
+
var _chunkV5HTEMWZcjs = require('./chunk-V5HTEMWZ.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkJU5RT22Ycjs = require('./chunk-JU5RT22Y.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkC4RM2JSDcjs = require('./chunk-C4RM2JSD.cjs');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var _chunk2NSCPLAAcjs = require('./chunk-2NSCPLAA.cjs');
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
var _chunk4AXNPSXGcjs = require('./chunk-4AXNPSXG.cjs');
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
var _chunk4DAZAO6Ycjs = require('./chunk-4DAZAO6Y.cjs');
|
|
20
|
+
|
|
21
|
+
// src/Select/Select.tsx
|
|
22
|
+
var _react = require('react');
|
|
23
|
+
var _reactselect = require('react-select'); var _reactselect2 = _interopRequireDefault(_reactselect);
|
|
24
|
+
var _select = require('@nextui-org/select');
|
|
25
|
+
var _pixelutils = require('@fuf-stack/pixel-utils');
|
|
26
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
27
|
+
var selectVariants = _pixelutils.tv.call(void 0, {
|
|
28
|
+
slots: {
|
|
29
|
+
base: "group leading-normal",
|
|
30
|
+
clearIndicator: "rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-foreground-800",
|
|
31
|
+
control: "rounded-lg border-2 border-default-200 !duration-150 transition-background hover:border-default-400 group-data-[invalid=true]:border-danger group-data-[invalid=true]:hover:border-danger motion-reduce:transition-none",
|
|
32
|
+
control_focused: "border-focus",
|
|
33
|
+
crossIcon: "",
|
|
34
|
+
downChevron: "",
|
|
35
|
+
dropdownIndicator: "rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-black",
|
|
36
|
+
group: "",
|
|
37
|
+
groupHeading: "mb-1 ml-3 mt-2 text-sm text-foreground-500",
|
|
38
|
+
indicatorsContainer: "gap-1 p-1",
|
|
39
|
+
indicatorSeparator: "bg-default-300",
|
|
40
|
+
input: "py-0.5 pl-1",
|
|
41
|
+
// See NextUI styles for group-data condition, e.g.: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/select.ts
|
|
42
|
+
label: 'pointer-events-auto relative bottom-1.5 ml-1 text-small subpixel-antialiased group-data-[invalid=true]:!text-danger group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-["*"]',
|
|
43
|
+
loadingIndicator: "",
|
|
44
|
+
loadingMessage: "",
|
|
45
|
+
menu: "mt-2 rounded-xl border border-default-200 bg-content1 p-1 shadow-lg",
|
|
46
|
+
menuList: "",
|
|
47
|
+
// ensure menu has same z-index as modal so it is visible when rendered in modal
|
|
48
|
+
// see: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/modal.ts (see z-50)
|
|
49
|
+
menuPortal: "!z-50",
|
|
50
|
+
multiValue: "items-center gap-1.5 rounded bg-default-100 py-0.5 pl-2 pr-1",
|
|
51
|
+
multiValueContainer: "",
|
|
52
|
+
multiValueLabel: "py-0.5 leading-6",
|
|
53
|
+
multiValueRemove: "rounded text-default-500 hover:cursor-pointer hover:border-default-300 hover:text-default-800",
|
|
54
|
+
noOptionsMessage: "rounded-sm p-2 text-foreground-500",
|
|
55
|
+
option_focused: "bg-default-100 active:bg-default-200",
|
|
56
|
+
option_selected: "bg-default-300",
|
|
57
|
+
option: "rounded px-3 py-2 hover:cursor-pointer",
|
|
58
|
+
placeholder: "ml-1 py-0.5 pl-1 text-sm text-foreground-500",
|
|
59
|
+
selectContainer: "",
|
|
60
|
+
singleValue: "!ml-1 !leading-7",
|
|
61
|
+
valueContainer: "gap-1 p-1"
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
var InputComponent = (props) => {
|
|
65
|
+
const testId = `${props.selectProps["data-testid"]}`;
|
|
66
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactselect.components.Input, _chunk4DAZAO6Ycjs.__spreadValues.call(void 0, { "data-testid": testId }, props));
|
|
67
|
+
};
|
|
68
|
+
var ControlComponent = (props) => {
|
|
69
|
+
const testId = `${props.selectProps["data-testid"]}_select`;
|
|
70
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { "data-testid": testId, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactselect.components.Control, _chunk4DAZAO6Ycjs.__spreadValues.call(void 0, {}, props)) });
|
|
71
|
+
};
|
|
72
|
+
var OptionComponent = (props) => {
|
|
73
|
+
var _a, _b, _c;
|
|
74
|
+
const testId = `${props.selectProps["data-testid"]}_select_option_${_chunk4AXNPSXGcjs.slugify.call(void 0, (_c = (_a = props == null ? void 0 : props.data) == null ? void 0 : _a.testId) != null ? _c : (_b = props == null ? void 0 : props.data) == null ? void 0 : _b.value)}`;
|
|
75
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { "data-testid": testId, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactselect.components.Option, _chunk4DAZAO6Ycjs.__spreadValues.call(void 0, {}, props)) });
|
|
76
|
+
};
|
|
77
|
+
var DropdownIndicatorComponent = (props) => {
|
|
78
|
+
const testId = props == null ? void 0 : props.selectProps["data-testid"];
|
|
79
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { "data-testid": `${testId}_select_dropdown`, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactselect.components.DropdownIndicator, _chunk4DAZAO6Ycjs.__spreadValues.call(void 0, {}, props)) });
|
|
80
|
+
};
|
|
81
|
+
var Select = ({
|
|
82
|
+
className = void 0,
|
|
83
|
+
clearable = true,
|
|
84
|
+
disabled = false,
|
|
85
|
+
filterOption = void 0,
|
|
86
|
+
renderOptionLabel = void 0,
|
|
87
|
+
inputValue = void 0,
|
|
88
|
+
label: _label = void 0,
|
|
89
|
+
loading = false,
|
|
90
|
+
multiSelect = false,
|
|
91
|
+
name,
|
|
92
|
+
onInputChange = void 0,
|
|
93
|
+
options,
|
|
94
|
+
placeholder = void 0,
|
|
95
|
+
testId: _testId = void 0
|
|
96
|
+
}) => {
|
|
97
|
+
const { control, debugMode, getFieldState } = _chunk2NSCPLAAcjs.useFormContext.call(void 0, );
|
|
98
|
+
const { error, invalid, required, testId } = getFieldState(name, _testId);
|
|
99
|
+
const [isFocused, setIsFocused] = _react.useState.call(void 0, false);
|
|
100
|
+
const variants = selectVariants();
|
|
101
|
+
const classNames = _pixelutils.variantsToClassNames.call(void 0, variants, className, "base");
|
|
102
|
+
const {
|
|
103
|
+
getBaseProps,
|
|
104
|
+
getErrorMessageProps,
|
|
105
|
+
getHelperWrapperProps,
|
|
106
|
+
getLabelProps,
|
|
107
|
+
getTriggerProps,
|
|
108
|
+
getValueProps,
|
|
109
|
+
label
|
|
110
|
+
} = _select.useSelect.call(void 0, {
|
|
111
|
+
children: [],
|
|
112
|
+
classNames,
|
|
113
|
+
errorMessage: JSON.stringify(error),
|
|
114
|
+
isDisabled: disabled,
|
|
115
|
+
isInvalid: invalid,
|
|
116
|
+
isLoading: loading,
|
|
117
|
+
isRequired: required,
|
|
118
|
+
label: _label,
|
|
119
|
+
labelPlacement: "outside",
|
|
120
|
+
placeholder: " "
|
|
121
|
+
});
|
|
122
|
+
const showTestIdCopyButton = debugMode === "debug-testids";
|
|
123
|
+
const showLabel = label || showTestIdCopyButton;
|
|
124
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
125
|
+
_chunkV5HTEMWZcjs.Controller_default,
|
|
126
|
+
{
|
|
127
|
+
control,
|
|
128
|
+
name,
|
|
129
|
+
render: ({
|
|
130
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
131
|
+
field: { onChange, value, ref, onBlur }
|
|
132
|
+
}) => {
|
|
133
|
+
var _a;
|
|
134
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
135
|
+
"div",
|
|
136
|
+
_chunk4DAZAO6Ycjs.__spreadProps.call(void 0, _chunk4DAZAO6Ycjs.__spreadValues.call(void 0, {}, getBaseProps()), {
|
|
137
|
+
className: _pixelutils.cn.call(void 0, classNames.base),
|
|
138
|
+
"data-testid": `${testId}_wrapper`,
|
|
139
|
+
"data-required": required,
|
|
140
|
+
children: [
|
|
141
|
+
showLabel && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
142
|
+
"label",
|
|
143
|
+
{
|
|
144
|
+
className: classNames.label,
|
|
145
|
+
"data-slot": "label",
|
|
146
|
+
htmlFor: `react-select-${name}-input`,
|
|
147
|
+
id: getLabelProps().id,
|
|
148
|
+
children: [
|
|
149
|
+
label,
|
|
150
|
+
showTestIdCopyButton && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkJU5RT22Ycjs.FieldCopyTestIdButton_default, { testId })
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
),
|
|
154
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
155
|
+
_reactselect2.default,
|
|
156
|
+
{
|
|
157
|
+
"aria-errormessage": "",
|
|
158
|
+
"aria-labelledby": (_a = getTriggerProps()["aria-labelledby"]) == null ? void 0 : _a.split(" ")[1],
|
|
159
|
+
"aria-invalid": invalid,
|
|
160
|
+
classNames: {
|
|
161
|
+
control: () => _pixelutils.cn.call(void 0, classNames.control, {
|
|
162
|
+
[classNames.control_focused]: isFocused && !invalid
|
|
163
|
+
}),
|
|
164
|
+
clearIndicator: () => classNames.clearIndicator,
|
|
165
|
+
dropdownIndicator: () => classNames.dropdownIndicator,
|
|
166
|
+
groupHeading: () => classNames.groupHeading,
|
|
167
|
+
indicatorsContainer: () => classNames.indicatorsContainer,
|
|
168
|
+
indicatorSeparator: () => classNames.indicatorSeparator,
|
|
169
|
+
input: () => classNames.input,
|
|
170
|
+
menu: () => classNames.menu,
|
|
171
|
+
menuList: () => classNames.menuList,
|
|
172
|
+
menuPortal: () => classNames.menuPortal,
|
|
173
|
+
multiValue: () => classNames.multiValue,
|
|
174
|
+
multiValueLabel: () => _pixelutils.cn.call(void 0, classNames.multiValueLabel, `${getValueProps().className}`),
|
|
175
|
+
multiValueRemove: () => classNames.multiValueRemove,
|
|
176
|
+
noOptionsMessage: () => classNames.noOptionsMessage,
|
|
177
|
+
option: ({
|
|
178
|
+
isFocused: optionIsFocused,
|
|
179
|
+
isSelected: optionIsSelected
|
|
180
|
+
}) => _pixelutils.cn.call(void 0, classNames.option, {
|
|
181
|
+
[classNames.option_focused]: optionIsFocused,
|
|
182
|
+
[classNames.option_selected]: optionIsSelected
|
|
183
|
+
}),
|
|
184
|
+
placeholder: () => classNames.placeholder,
|
|
185
|
+
singleValue: () => _pixelutils.cn.call(void 0, classNames.singleValue, `${getValueProps().className}`),
|
|
186
|
+
valueContainer: () => classNames.valueContainer
|
|
187
|
+
},
|
|
188
|
+
components: {
|
|
189
|
+
Input: InputComponent,
|
|
190
|
+
Option: OptionComponent,
|
|
191
|
+
DropdownIndicator: DropdownIndicatorComponent,
|
|
192
|
+
Control: ControlComponent
|
|
193
|
+
},
|
|
194
|
+
"data-testid": testId,
|
|
195
|
+
filterOption,
|
|
196
|
+
formatOptionLabel: renderOptionLabel,
|
|
197
|
+
inputValue,
|
|
198
|
+
instanceId: name,
|
|
199
|
+
isClearable: clearable,
|
|
200
|
+
isDisabled: disabled,
|
|
201
|
+
isLoading: loading,
|
|
202
|
+
isMulti: multiSelect,
|
|
203
|
+
name,
|
|
204
|
+
menuPosition: "fixed",
|
|
205
|
+
menuShouldBlockScroll: true,
|
|
206
|
+
options,
|
|
207
|
+
placeholder,
|
|
208
|
+
onBlur: (_e) => {
|
|
209
|
+
setIsFocused(false);
|
|
210
|
+
return onBlur();
|
|
211
|
+
},
|
|
212
|
+
onChange: (option) => {
|
|
213
|
+
if (multiSelect) {
|
|
214
|
+
onChange(
|
|
215
|
+
option == null ? void 0 : option.map((_option) => _option.value)
|
|
216
|
+
);
|
|
217
|
+
} else {
|
|
218
|
+
onChange(option == null ? void 0 : option.value);
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
onFocus: (_e) => {
|
|
222
|
+
setIsFocused(true);
|
|
223
|
+
},
|
|
224
|
+
onInputChange,
|
|
225
|
+
ref,
|
|
226
|
+
value: options.find((option) => option.value === value),
|
|
227
|
+
unstyled: true
|
|
228
|
+
}
|
|
229
|
+
),
|
|
230
|
+
error && // eslint-disable-next-line react/jsx-props-no-spreading
|
|
231
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", _chunk4DAZAO6Ycjs.__spreadProps.call(void 0, _chunk4DAZAO6Ycjs.__spreadValues.call(void 0, {}, getHelperWrapperProps()), { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", _chunk4DAZAO6Ycjs.__spreadProps.call(void 0, _chunk4DAZAO6Ycjs.__spreadValues.call(void 0, {}, getErrorMessageProps()), { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkC4RM2JSDcjs.FieldValidationError_default, { error }) })) }))
|
|
232
|
+
]
|
|
233
|
+
})
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
);
|
|
238
|
+
};
|
|
239
|
+
var Select_default = Select;
|
|
240
|
+
|
|
241
|
+
// src/Select/index.ts
|
|
242
|
+
var Select_default2 = Select_default;
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
exports.Select_default = Select_default; exports.Select_default2 = Select_default2;
|
|
248
|
+
//# sourceMappingURL=chunk-K43U2JVG.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-K43U2JVG.cjs","../src/Select/Select.tsx","../src/Select/index.ts"],"names":["Select_default"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACjBA,8BAAyB;AACzB,qGAAwC;AAExC,4CAA0B;AAE1B,oDAA6C;AAmGpC,+CAAA;AA3FF,IAAM,eAAA,EAAiB,4BAAA;AAAG,EAC/B,KAAA,EAAO;AAAA,IACL,IAAA,EAAM,sBAAA;AAAA,IACN,cAAA,EACE,wGAAA;AAAA,IACF,OAAA,EACE,yNAAA;AAAA,IACF,eAAA,EAAiB,cAAA;AAAA,IACjB,SAAA,EAAW,EAAA;AAAA,IACX,WAAA,EAAa,EAAA;AAAA,IACb,iBAAA,EACE,+FAAA;AAAA,IACF,KAAA,EAAO,EAAA;AAAA,IACP,YAAA,EAAc,4CAAA;AAAA,IACd,mBAAA,EAAqB,WAAA;AAAA,IACrB,kBAAA,EAAoB,gBAAA;AAAA,IACpB,KAAA,EAAO,aAAA;AAAA;AAAA,IAEP,KAAA,EACE,yPAAA;AAAA,IACF,gBAAA,EAAkB,EAAA;AAAA,IAClB,cAAA,EAAgB,EAAA;AAAA,IAChB,IAAA,EAAM,qEAAA;AAAA,IACN,QAAA,EAAU,EAAA;AAAA;AAAA;AAAA,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EC,8BAAA;AAKA,YAAA;AAAA,UAAA;AAEJ,QAAA;AAAA,MAAA;AAAA,IAAA;AAEJ,EAAA;AAEJ;AAEO;ADtFW;AACA;AE1OXA;AF4OW;AACA;AACA;AACA;AACA","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-K43U2JVG.cjs","sourcesContent":[null,"import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { Props } from 'react-select';\n\nimport { useState } from 'react';\nimport ReactSelect, { components } from 'react-select';\n\nimport { useSelect } from '@nextui-org/select';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { Controller } from '../Controller';\nimport { slugify } from '../helpers';\nimport { useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport const selectVariants = tv({\n slots: {\n base: 'group leading-normal',\n clearIndicator:\n 'rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-foreground-800',\n control:\n 'rounded-lg border-2 border-default-200 !duration-150 transition-background hover:border-default-400 group-data-[invalid=true]:border-danger group-data-[invalid=true]:hover:border-danger motion-reduce:transition-none',\n control_focused: 'border-focus',\n crossIcon: '',\n downChevron: '',\n dropdownIndicator:\n 'rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-black',\n group: '',\n groupHeading: 'mb-1 ml-3 mt-2 text-sm text-foreground-500',\n indicatorsContainer: 'gap-1 p-1',\n indicatorSeparator: 'bg-default-300',\n input: 'py-0.5 pl-1',\n // See NextUI styles for group-data condition, e.g.: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'pointer-events-auto relative bottom-1.5 ml-1 text-small subpixel-antialiased group-data-[invalid=true]:!text-danger group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-[\"*\"]',\n loadingIndicator: '',\n loadingMessage: '',\n menu: 'mt-2 rounded-xl border border-default-200 bg-content1 p-1 shadow-lg',\n menuList: '',\n // ensure menu has same z-index as modal so it is visible when rendered in modal\n // see: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/modal.ts (see z-50)\n menuPortal: '!z-50',\n multiValue: 'items-center gap-1.5 rounded bg-default-100 py-0.5 pl-2 pr-1',\n multiValueContainer: '',\n multiValueLabel: 'py-0.5 leading-6',\n multiValueRemove:\n 'rounded text-default-500 hover:cursor-pointer hover:border-default-300 hover:text-default-800',\n noOptionsMessage: 'rounded-sm p-2 text-foreground-500',\n option_focused: 'bg-default-100 active:bg-default-200',\n option_selected: 'bg-default-300',\n option: 'rounded px-3 py-2 hover:cursor-pointer',\n placeholder: 'ml-1 py-0.5 pl-1 text-sm text-foreground-500',\n selectContainer: '',\n singleValue: '!ml-1 !leading-7',\n valueContainer: 'gap-1 p-1',\n },\n});\n\ntype SelectOption = {\n /** option label */\n label?: React.ReactNode;\n /** option value */\n value: string;\n};\n\ntype VariantProps = TVProps<typeof selectVariants>;\ntype ClassName = TVClassName<typeof selectVariants>;\n\nexport interface SelectProps extends VariantProps {\n /** CSS class name */\n className?: ClassName; // string;\n /** Determine if the */\n clearable?: boolean;\n /** Set the select to disabled state. */\n disabled?: boolean;\n /** Filter Select Options */\n filterOption?:\n | undefined\n | ((option?: SelectOption, inputValue?: string) => boolean);\n /** Format the label of the option */\n renderOptionLabel?: undefined | Props['formatOptionLabel'];\n /** The value of the search input */\n inputValue?: string;\n /** Label that should be associated with the select. */\n label?: React.ReactNode;\n /** Set the select to a loading state. */\n loading?: boolean;\n /** switch between single and multi select mode. */\n multiSelect?: boolean;\n /** The name for the Select component, used by react-hook-form */\n name: string;\n /** Placeholder that is displayed when nothing is selected */\n placeholder?: string;\n /** The options for the Select component */\n options: SelectOption[];\n /** Handle change events on the input */\n onInputChange?: Props['onInputChange'];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\nconst InputComponent: typeof components.Input = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/prop-types, react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}`;\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <components.Input data-testid={testId} {...props} />;\n};\n\nconst ControlComponent: typeof components.Control = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/prop-types, react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}_select`;\n return (\n <div data-testid={testId}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <components.Control {...props} />\n </div>\n );\n};\n\nconst OptionComponent: typeof components.Option = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/prop-types, react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}_select_option_${slugify(props?.data?.testId ?? props?.data?.value)}`;\n return (\n <div data-testid={testId}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <components.Option {...props} />\n </div>\n );\n};\n\nconst DropdownIndicatorComponent: typeof components.DropdownIndicator = (\n props,\n) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/prop-types\n const testId = props?.selectProps['data-testid'] as string;\n return (\n <div data-testid={`${testId}_select_dropdown`}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <components.DropdownIndicator {...props} />\n </div>\n );\n};\n\n/** Select component based on [NextUI Select](https://nextui.org/docs/components/select) and [React-Select](https://react-select.com/home) */\nconst Select = ({\n className = undefined,\n clearable = true,\n disabled = false,\n filterOption = undefined,\n renderOptionLabel = undefined,\n inputValue = undefined,\n label: _label = undefined,\n loading = false,\n multiSelect = false,\n name,\n onInputChange = undefined,\n options,\n placeholder = undefined,\n testId: _testId = undefined,\n}: SelectProps) => {\n const { control, debugMode, getFieldState } = useFormContext();\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n const [isFocused, setIsFocused] = useState(false);\n\n const variants = selectVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n\n const {\n getBaseProps,\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\n getTriggerProps,\n getValueProps,\n label,\n } = useSelect({\n children: [],\n classNames,\n errorMessage: JSON.stringify(error),\n isDisabled: disabled,\n isInvalid: invalid,\n isLoading: loading,\n isRequired: required,\n label: _label,\n labelPlacement: 'outside',\n placeholder: ' ',\n });\n\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const showLabel = label || showTestIdCopyButton;\n\n return (\n <Controller\n control={control}\n name={name}\n render={({\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n field: { onChange, value, ref, onBlur },\n }) => (\n <div\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...getBaseProps()}\n className={cn(classNames.base)}\n data-testid={`${testId}_wrapper`}\n // See NextUI styles for group-data condition (data-invalid), e.g.: https://github.com/nextui-org/nextui/blob/main/packages/components/select/src/use-select.ts\n data-required={required}\n >\n {showLabel && (\n <label\n className={classNames.label}\n data-slot=\"label\"\n htmlFor={`react-select-${name}-input`}\n id={getLabelProps().id}\n >\n {label}\n {showTestIdCopyButton && (\n <FieldCopyTestIdButton testId={testId} />\n )}\n </label>\n )}\n <ReactSelect\n aria-errormessage=\"\"\n aria-labelledby={\n getTriggerProps()['aria-labelledby']?.split(' ')[1]\n }\n aria-invalid={invalid}\n classNames={{\n control: () =>\n cn(classNames.control, {\n [classNames.control_focused]: isFocused && !invalid,\n }),\n clearIndicator: () => classNames.clearIndicator,\n dropdownIndicator: () => classNames.dropdownIndicator,\n groupHeading: () => classNames.groupHeading,\n indicatorsContainer: () => classNames.indicatorsContainer,\n indicatorSeparator: () => classNames.indicatorSeparator,\n input: () => classNames.input,\n menu: () => classNames.menu,\n menuList: () => classNames.menuList,\n menuPortal: () => classNames.menuPortal,\n multiValue: () => classNames.multiValue,\n multiValueLabel: () =>\n cn(classNames.multiValueLabel, `${getValueProps().className}`),\n multiValueRemove: () => classNames.multiValueRemove,\n noOptionsMessage: () => classNames.noOptionsMessage,\n option: ({\n isFocused: optionIsFocused,\n isSelected: optionIsSelected,\n }) =>\n cn(classNames.option, {\n [classNames.option_focused]: optionIsFocused,\n [classNames.option_selected]: optionIsSelected,\n }),\n placeholder: () => classNames.placeholder,\n singleValue: () =>\n cn(classNames.singleValue, `${getValueProps().className}`),\n valueContainer: () => classNames.valueContainer,\n }}\n components={{\n Input: InputComponent,\n Option: OptionComponent,\n DropdownIndicator: DropdownIndicatorComponent,\n Control: ControlComponent,\n }}\n // Does not affect the testId of the select, but is needed to pass it to sub-components\n data-testid={testId}\n filterOption={filterOption}\n formatOptionLabel={renderOptionLabel}\n inputValue={inputValue}\n instanceId={name}\n isClearable={clearable}\n isDisabled={disabled}\n isLoading={loading}\n isMulti={multiSelect}\n name={name}\n // set menuPosition to fixed so that menu can be rendered\n // inside Card / Modal components, menuShouldBlockScroll\n // prevents container scroll when menu is open\n menuPosition=\"fixed\"\n menuShouldBlockScroll\n options={options}\n placeholder={placeholder}\n onBlur={(_e) => {\n setIsFocused(false);\n return onBlur();\n }}\n onChange={(option) => {\n if (multiSelect) {\n onChange(\n (option as SelectOption[])?.map((_option) => _option.value),\n );\n } else {\n onChange((option as SelectOption)?.value);\n }\n }}\n onFocus={(_e) => {\n setIsFocused(true);\n }}\n onInputChange={onInputChange}\n ref={ref}\n // set complete option as value by current field value\n value={options.find((option) => option.value === value)}\n unstyled\n />\n {error && (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <div {...getHelperWrapperProps()}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <div {...getErrorMessageProps()}>\n <FieldValidationError error={error} />\n </div>\n </div>\n )}\n </div>\n )}\n />\n );\n};\n\nexport default Select;\n","import Select from './Select';\n\nexport type { SelectProps } from './Select';\n\nexport { Select };\n\nexport default Select;\n"]}
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkV5HTEMWZcjs = require('./chunk-V5HTEMWZ.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkJU5RT22Ycjs = require('./chunk-JU5RT22Y.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkC4RM2JSDcjs = require('./chunk-C4RM2JSD.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunk2NSCPLAAcjs = require('./chunk-2NSCPLAA.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunk4AXNPSXGcjs = require('./chunk-4AXNPSXG.cjs');
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
var _chunk4DAZAO6Ycjs = require('./chunk-4DAZAO6Y.cjs');
|
|
16
21
|
|
|
17
22
|
// src/RadioGroup/RadioGroup.tsx
|
|
18
23
|
var _radio = require('@nextui-org/radio');
|
|
@@ -25,7 +30,8 @@ var _Tabs = require('@fuf-stack/pixels/Tabs'); var _Tabs2 = _interopRequireDefau
|
|
|
25
30
|
var _visuallyhidden = require('@react-aria/visually-hidden');
|
|
26
31
|
|
|
27
32
|
var _jsxruntime = require('react/jsx-runtime');
|
|
28
|
-
var RadioBox = (
|
|
33
|
+
var RadioBox = (_a) => {
|
|
34
|
+
var _b = _a, { icon = void 0 } = _b, props = _chunk4DAZAO6Ycjs.__objRest.call(void 0, _b, ["icon"]);
|
|
29
35
|
const {
|
|
30
36
|
children,
|
|
31
37
|
Component,
|
|
@@ -40,8 +46,7 @@ var RadioBox = ({ icon = void 0, ...props }) => {
|
|
|
40
46
|
} = _radio.useRadio.call(void 0, props);
|
|
41
47
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
42
48
|
Component,
|
|
43
|
-
{
|
|
44
|
-
...getBaseProps(),
|
|
49
|
+
_chunk4DAZAO6Ycjs.__spreadProps.call(void 0, _chunk4DAZAO6Ycjs.__spreadValues.call(void 0, {}, getBaseProps()), {
|
|
45
50
|
className: _pixelutils.cn.call(void 0,
|
|
46
51
|
"group inline-flex flex-auto cursor-pointer items-center justify-between gap-4 rounded-lg border-2 border-default p-4 hover:bg-content2 data-[selected=true]:border-focus",
|
|
47
52
|
{
|
|
@@ -50,22 +55,21 @@ var RadioBox = ({ icon = void 0, ...props }) => {
|
|
|
50
55
|
}
|
|
51
56
|
),
|
|
52
57
|
children: [
|
|
53
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _visuallyhidden.VisuallyHidden, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "input", {
|
|
54
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", {
|
|
58
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _visuallyhidden.VisuallyHidden, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "input", _chunk4DAZAO6Ycjs.__spreadValues.call(void 0, {}, getInputProps())) }),
|
|
59
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", _chunk4DAZAO6Ycjs.__spreadProps.call(void 0, _chunk4DAZAO6Ycjs.__spreadValues.call(void 0, {}, getWrapperProps()), { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", _chunk4DAZAO6Ycjs.__spreadValues.call(void 0, {}, getControlProps())) })),
|
|
55
60
|
icon,
|
|
56
61
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
57
62
|
"div",
|
|
58
|
-
{
|
|
59
|
-
...getLabelWrapperProps(),
|
|
63
|
+
_chunk4DAZAO6Ycjs.__spreadProps.call(void 0, _chunk4DAZAO6Ycjs.__spreadValues.call(void 0, {}, getLabelWrapperProps()), {
|
|
60
64
|
className: _pixelutils.cn.call(void 0, getLabelWrapperProps().className, "grow"),
|
|
61
65
|
children: [
|
|
62
|
-
children && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", {
|
|
66
|
+
children && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", _chunk4DAZAO6Ycjs.__spreadProps.call(void 0, _chunk4DAZAO6Ycjs.__spreadValues.call(void 0, {}, getLabelProps()), { children })),
|
|
63
67
|
description && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-small text-foreground opacity-70", children: description })
|
|
64
68
|
]
|
|
65
|
-
}
|
|
69
|
+
})
|
|
66
70
|
)
|
|
67
71
|
]
|
|
68
|
-
}
|
|
72
|
+
})
|
|
69
73
|
);
|
|
70
74
|
};
|
|
71
75
|
|
|
@@ -134,14 +138,14 @@ var RadioGroup = ({
|
|
|
134
138
|
testId: _testId = void 0,
|
|
135
139
|
variant = "default"
|
|
136
140
|
}) => {
|
|
137
|
-
const { control, debugMode, getFieldState, getValues } =
|
|
141
|
+
const { control, debugMode, getFieldState, getValues } = _chunk2NSCPLAAcjs.useFormContext.call(void 0, );
|
|
138
142
|
const { error, invalid, required, testId } = getFieldState(name, _testId);
|
|
139
143
|
const showTestIdCopyButton = debugMode === "debug-testids";
|
|
140
144
|
const showLabel = label || showTestIdCopyButton;
|
|
141
145
|
const variants = radioGroupVariants();
|
|
142
146
|
const classNames = _pixelutils.variantsToClassNames.call(void 0, variants, className, "base");
|
|
143
147
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
144
|
-
|
|
148
|
+
_chunkV5HTEMWZcjs.Controller_default,
|
|
145
149
|
{
|
|
146
150
|
control,
|
|
147
151
|
disabled,
|
|
@@ -169,7 +173,7 @@ var RadioGroup = ({
|
|
|
169
173
|
RadioBox,
|
|
170
174
|
{
|
|
171
175
|
classNames: itemClassNames,
|
|
172
|
-
"data-testid":
|
|
176
|
+
"data-testid": _chunk4AXNPSXGcjs.slugify.call(void 0,
|
|
173
177
|
`${testId}_option_${option.testId || option.value}`
|
|
174
178
|
),
|
|
175
179
|
description: option.description,
|
|
@@ -195,7 +199,7 @@ var RadioGroup = ({
|
|
|
195
199
|
[classNames.itemBaseActive]: getValues()[name] !== option.value
|
|
196
200
|
}),
|
|
197
201
|
isDisabled: isDisabled || option.disabled,
|
|
198
|
-
testID:
|
|
202
|
+
testID: _chunk4AXNPSXGcjs.slugify.call(void 0,
|
|
199
203
|
`${testId}_option_${option.testId || option.value}`
|
|
200
204
|
),
|
|
201
205
|
onChange,
|
|
@@ -225,7 +229,7 @@ var RadioGroup = ({
|
|
|
225
229
|
_radio.Radio,
|
|
226
230
|
{
|
|
227
231
|
classNames: itemClassNames,
|
|
228
|
-
"data-testid":
|
|
232
|
+
"data-testid": _chunk4AXNPSXGcjs.slugify.call(void 0,
|
|
229
233
|
`${testId}_option_${option.testId || option.value}`
|
|
230
234
|
),
|
|
231
235
|
isDisabled: isDisabled || option.disabled,
|
|
@@ -246,7 +250,7 @@ var RadioGroup = ({
|
|
|
246
250
|
"data-invalid": invalid,
|
|
247
251
|
"data-required": required,
|
|
248
252
|
"data-testid": testId,
|
|
249
|
-
errorMessage: error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
253
|
+
errorMessage: error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkC4RM2JSDcjs.FieldValidationError_default, { error }),
|
|
250
254
|
isDisabled,
|
|
251
255
|
isInvalid: invalid,
|
|
252
256
|
isRequired: required,
|
|
@@ -276,4 +280,4 @@ var RadioGroup_default2 = RadioGroup_default;
|
|
|
276
280
|
|
|
277
281
|
|
|
278
282
|
exports.RadioGroup_default = RadioGroup_default; exports.RadioGroup_default2 = RadioGroup_default2;
|
|
279
|
-
//# sourceMappingURL=chunk-
|
|
283
|
+
//# sourceMappingURL=chunk-MF4JB3YT.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-MF4JB3YT.cjs","../src/RadioGroup/RadioGroup.tsx","../src/RadioGroup/Variants/RadioBox.tsx","../src/RadioGroup/Variants/RadioButton.tsx","../src/RadioGroup/index.ts"],"names":["jsx","cn"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,oBAAA;AACc,oBAAA;AAGwB,kBAAA;AAAA,kBAAA;AAR1B,gBAAA;AASd,cAAA;AAGJ,cAAA;AAAO,YAAA;AAET,YAAA;AAAA,UAAA;AAGA,YAAA;AACE,cAAA;AAAC,cAAA;AAAA,gBAAA;AACY,gBAAA;AACL,gBAAA;AACa,cAAA;AAAA,YAAA;AAGvB,YAAA;AAAA,UAAA;AAEA,YAAA;AACE,cAAA;AACE,gBAAA;AACE,kBAAA;AAAC,kBAAA;AAAA,oBAAA;AACa,oBAAA;AACC,sBAAA;AACsC,oBAAA;AACnD,oBAAA;AACiC,oBAAA;AAEjC,oBAAA;AACc,oBAAA;AAEwB,kBAAA;AAAA,kBAAA;AAJ1B,gBAAA;AAKd,cAAA;AAGJ,cAAA;AAAO,YAAA;AACR,QAAA;AAGL,QAAA;AACE,UAAA;AAAC,UAAA;AAAA,YAAA;AACC,YAAA;AAEc,YAAA;AACC,YAAA;AACF,YAAA;AAC8C,YAAA;AAC3D,YAAA;AACW,YAAA;AACC,YAAA;AAEV,4BAAA;AAGK,cAAA;AAAA,cAAA;AAEwC,YAAA;AAE3C,YAAA;AAGJ,YAAA;AACqC,YAAA;AACrC,YAAA;AACA,YAAA;AACA,YAAA;AAOE,UAAA;AAAA,QAAA;AAEJ,MAAA;AAEJ,IAAA;AAAA,EAAA;AAGN;AAEA;ADmBA;AACA;AI7QA;AJ+QA;AACA;AACA;AACA;AACA","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-MF4JB3YT.cjs","sourcesContent":[null,"import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { TabProps } from '@fuf-stack/pixels/Tabs';\nimport type { ReactElement, ReactNode } from 'react';\n\nimport { RadioGroup as NextRadioGroup, Radio } from '@nextui-org/radio';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\nimport { ButtonGroup } from '@fuf-stack/pixels';\nimport Tabs from '@fuf-stack/pixels/Tabs';\n\nimport { Controller } from '../Controller';\nimport { slugify } from '../helpers';\nimport { useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\nimport { RadioBox } from './Variants/RadioBox';\nimport { RadioButton } from './Variants/RadioButton';\n\nexport const radioGroupVariants = tv({\n slots: {\n base: 'group', // Needs group for group-data condition\n buttonGroup:\n 'rounded-xl group-data-[invalid=true]:border group-data-[invalid=true]:border-danger', // optional if a button group is used\n itemBase: '',\n itemBaseActive: 'bg-opacity-50', // optional if a button group is used\n itemControl: 'bg-focus group-data-[invalid=true]:bg-danger',\n itemDescription: '',\n itemLabel: 'text-sm',\n itemLabelWrapper: '',\n itemWrapper:\n 'group-data-[invalid=true]:!border-danger [&:not(group-data-[invalid=\"true\"]):not(group-data-[selected=\"false\"])]:border-focus', // TODO: get rid of !.\n // See NextUI styles for group-data condition, e.g.: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:text-danger',\n wrapper: '',\n // Tabs\n tabList: '',\n tab: '',\n tabContent: '',\n cursor: '',\n panel: '',\n },\n});\n\ntype VariantProps = TVProps<typeof radioGroupVariants>;\ntype ClassName = TVClassName<typeof radioGroupVariants>;\n\nexport interface RadioGroupOption {\n /** Description of the value. Works with variant radioBox. */\n description?: React.ReactNode;\n /** disables the option */\n disabled?: boolean;\n /** option label */\n label?: React.ReactNode;\n /** option icon */\n icon?: ReactNode;\n /** HTML data-testid attribute of the option */\n testId?: string;\n /** option value */\n value: string;\n}\n\nexport interface RadioGroupProps<\n V extends 'default' | 'radioBox' | 'radioButton' | 'tabs',\n> extends VariantProps {\n /** CSS class name */\n className?: ClassName;\n /** Determines if the Buttons are disabled or not. */\n disabled?: boolean;\n /** determines orientation of the Buttons. */\n inline?: boolean;\n /** Label displayed next to the RadioButton. */\n label?: ReactNode;\n /** Name the RadioButtons are registered at in HTML forms (react-hook-form). */\n name: string;\n /** Radio button configuration. */\n options: V extends 'default' | 'radioBox' | 'radioButton'\n ? RadioGroupOption[]\n : TabProps[];\n /** Id to grab element in internal tests. */\n testId?: string;\n /** How the RadioGroup should look like. */\n variant?: V;\n}\n\n/**\n * RadioGroup component based on [NextUI RadioGroup](https://nextui.org/docs/components/radio-group)\n */\nconst RadioGroup = ({\n className = undefined,\n disabled = false,\n inline = false,\n label = undefined,\n name,\n options,\n testId: _testId = undefined,\n variant = 'default',\n}: RadioGroupProps<\n 'default' | 'radioBox' | 'radioButton' | 'tabs'\n>): ReactElement => {\n const { control, debugMode, getFieldState, getValues } = useFormContext();\n\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const showLabel = label || showTestIdCopyButton;\n\n const variants = radioGroupVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n\n return (\n <Controller\n control={control}\n disabled={disabled}\n name={name}\n render={({ field: { onChange, disabled: isDisabled, onBlur, ref } }) => {\n let RadioComponents: ReactNode;\n\n const itemClassNames = {\n base: classNames.itemBase,\n control: classNames.itemControl,\n description: classNames.itemDescription,\n label: classNames.itemLabel,\n labelWrapper: classNames.itemLabelWrapper,\n wrapper: classNames.itemWrapper,\n tabList: classNames.tabList,\n tab: classNames.tab,\n tabContent: classNames.tabContent,\n cursor: classNames.cursor,\n panel: classNames.panel,\n };\n\n switch (variant) {\n case 'radioBox':\n RadioComponents = options.map((option) => {\n if ('value' in option) {\n return (\n <RadioBox\n classNames={itemClassNames}\n data-testid={slugify(\n `${testId}_option_${option.testId || option.value}`,\n )}\n description={option.description}\n icon={option.icon}\n isDisabled={isDisabled || option.disabled}\n key={option.value}\n onChange={onChange}\n value={option.value}\n >\n {option.label ? option.label : option.value}\n </RadioBox>\n );\n }\n return null;\n });\n break;\n case 'radioButton':\n RadioComponents = options.map((option) => {\n if ('value' in option) {\n return (\n <RadioButton\n className={cn(classNames.itemBase, {\n [classNames.itemBaseActive]:\n getValues()[name] !== option.value,\n })}\n isDisabled={isDisabled || option.disabled}\n key={option.value}\n testID={slugify(\n `${testId}_option_${option.testId || option.value}`,\n )}\n onChange={onChange}\n value={option.value}\n // TODO: how to do the classNames properly (make selected option darker with same color)\n >\n {option.label ? option.label : option.value}\n </RadioButton>\n );\n }\n return null;\n });\n break;\n\n case 'tabs':\n RadioComponents = (\n <Tabs\n fullWidth={false}\n tabs={options as TabProps[]}\n onSelectionChange={onChange}\n />\n );\n break;\n default:\n RadioComponents = options.map((option) => {\n if ('value' in option) {\n return (\n <Radio\n classNames={itemClassNames}\n data-testid={slugify(\n `${testId}_option_${option.testId || option.value}`,\n )}\n isDisabled={isDisabled || option.disabled}\n key={option.value}\n onChange={onChange}\n value={option.value}\n >\n {option.label ? option.label : option.value}\n </Radio>\n );\n }\n return null;\n });\n }\n\n return (\n <NextRadioGroup\n classNames={classNames}\n // See NextUI styles for group-data condition (data-invalid), e.g.: https://github.com/nextui-org/nextui/blob/main/packages/components/select/src/use-select.ts\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n errorMessage={error && <FieldValidationError error={error} />}\n isDisabled={isDisabled}\n isInvalid={invalid}\n isRequired={required}\n label={\n showLabel && (\n // eslint-disable-next-line jsx-a11y/label-has-associated-control\n <label>\n {label}\n {showTestIdCopyButton && (\n <FieldCopyTestIdButton testId={testId} />\n )}\n </label>\n )\n }\n name={name}\n orientation={inline ? 'horizontal' : 'vertical'}\n onBlur={onBlur}\n onChange={onChange}\n ref={ref}\n >\n {variant === 'radioButton' ? (\n <ButtonGroup className={classNames.buttonGroup}>\n {RadioComponents}\n </ButtonGroup>\n ) : (\n RadioComponents\n )}\n </NextRadioGroup>\n );\n }}\n />\n );\n};\n\nexport default RadioGroup;\n","import type { RadioProps as NextRadioProps } from '@nextui-org/radio';\nimport type { ReactNode } from 'react';\n\nimport { useRadio } from '@nextui-org/radio';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn } from '@fuf-stack/pixel-utils';\n\ninterface RadioProps extends NextRadioProps {\n /** icon for the option */\n icon?: ReactNode;\n}\n\nexport const RadioBox = ({ icon = undefined, ...props }: RadioProps) => {\n const {\n children,\n Component,\n description,\n getBaseProps,\n getControlProps,\n getInputProps,\n getLabelProps,\n getLabelWrapperProps,\n getWrapperProps,\n isDisabled,\n } = useRadio(props);\n\n return (\n <Component\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...getBaseProps()}\n className={cn(\n 'group inline-flex flex-auto cursor-pointer items-center justify-between gap-4 rounded-lg border-2 border-default p-4 hover:bg-content2 data-[selected=true]:border-focus',\n {\n // disabled styles\n 'pointer-events-none opacity-disabled': isDisabled,\n },\n )}\n >\n <VisuallyHidden>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <input {...getInputProps()} />\n </VisuallyHidden>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <span {...getWrapperProps()}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <span {...getControlProps()} />\n </span>\n {icon}\n <div\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...getLabelWrapperProps()}\n className={cn(getLabelWrapperProps().className, 'grow')}\n >\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n {children && <span {...getLabelProps()}>{children}</span>}\n {description && (\n <span className=\"text-small text-foreground opacity-70\">\n {description}\n </span>\n )}\n </div>\n </Component>\n );\n};\n\nexport default RadioBox;\n","import { cn } from '@fuf-stack/pixel-utils';\nimport { Button } from '@fuf-stack/pixels';\n\ninterface RadioButtonProps {\n /** label of the value. */\n children: React.ReactNode;\n /** CSS class name */\n className?: string;\n /** disables the option */\n isDisabled?: boolean;\n /** HTML data-testid attribute of the option */\n testID?: string;\n /** Callback function. Executed if the option is clicked. */\n onChange: (...event: unknown[]) => void;\n /** value of the option. */\n value: string;\n}\n\nexport const RadioButton = ({\n children,\n className = undefined,\n isDisabled = false,\n onChange,\n testID = undefined,\n value,\n}: RadioButtonProps) => {\n return (\n <Button\n className={cn(className)}\n testId={testID}\n disabled={isDisabled}\n key={`index_${value}`}\n onClick={() => {\n return onChange(value);\n }}\n >\n {children}\n </Button>\n );\n};\n\nexport default RadioButton;\n","import RadioGroup from './RadioGroup';\n\nexport type { RadioGroupProps } from './RadioGroup';\n\nexport { RadioGroup };\n\nexport default RadioGroup;\n"]}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
-
slugify
|
|
3
|
-
|
|
2
|
+
slugify,
|
|
3
|
+
toValidationFormat
|
|
4
|
+
} from "./chunk-IEF2GJ22.js";
|
|
5
|
+
import {
|
|
6
|
+
__async,
|
|
7
|
+
__objRest,
|
|
8
|
+
__spreadProps,
|
|
9
|
+
__spreadValues
|
|
10
|
+
} from "./chunk-CRTRMMJ7.js";
|
|
4
11
|
|
|
5
12
|
// src/hooks/useFieldArray/useFieldArray.ts
|
|
6
13
|
import { useFieldArray } from "react-hook-form";
|
|
@@ -14,13 +21,6 @@ import React, { useMemo, useState } from "react";
|
|
|
14
21
|
import { FormProvider as HookFormProvider, useForm } from "react-hook-form";
|
|
15
22
|
import { useLocalStorage } from "@fuf-stack/pixels";
|
|
16
23
|
import { jsx } from "react/jsx-runtime";
|
|
17
|
-
var removeNullishFields = (obj) => {
|
|
18
|
-
return JSON.parse(
|
|
19
|
-
JSON.stringify(obj, (_key, value) => {
|
|
20
|
-
return value === "" || value === null ? void 0 : value;
|
|
21
|
-
})
|
|
22
|
-
);
|
|
23
|
-
};
|
|
24
24
|
var DEBUG_MODE_LOCAL_STORAGE_KEY_DEFAULT = "uniform:debug-mode";
|
|
25
25
|
var UniformContext = React.createContext({
|
|
26
26
|
debugMode: "off",
|
|
@@ -38,14 +38,14 @@ var FormProvider = ({
|
|
|
38
38
|
}) => {
|
|
39
39
|
const [preventSubmit, setPreventSubmit] = useState(false);
|
|
40
40
|
const [debugMode, setDebugMode] = useLocalStorage(
|
|
41
|
-
debugModeSettings
|
|
41
|
+
(debugModeSettings == null ? void 0 : debugModeSettings.localStorageKey) || DEBUG_MODE_LOCAL_STORAGE_KEY_DEFAULT,
|
|
42
42
|
"off"
|
|
43
43
|
);
|
|
44
44
|
const contextValue = useMemo(
|
|
45
45
|
() => ({
|
|
46
46
|
// set debugMode to disabled when debugModeSettings.disable is true
|
|
47
47
|
// otherwise use current debug mode from localStorage
|
|
48
|
-
debugMode: debugModeSettings
|
|
48
|
+
debugMode: (debugModeSettings == null ? void 0 : debugModeSettings.disable) ? "disabled" : debugMode,
|
|
49
49
|
preventSubmit: (prevent) => {
|
|
50
50
|
setPreventSubmit(prevent);
|
|
51
51
|
},
|
|
@@ -53,41 +53,39 @@ var FormProvider = ({
|
|
|
53
53
|
validation
|
|
54
54
|
}),
|
|
55
55
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
56
|
-
[debugMode, debugModeSettings
|
|
56
|
+
[debugMode, debugModeSettings == null ? void 0 : debugModeSettings.disable]
|
|
57
57
|
);
|
|
58
|
-
const methods = useForm({
|
|
59
|
-
defaultValues: initialValues
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
});
|
|
73
|
-
const handleSubmit = async (e) => {
|
|
58
|
+
const methods = useForm(__spreadValues({
|
|
59
|
+
defaultValues: initialValues
|
|
60
|
+
}, validation ? {
|
|
61
|
+
// set rhf mode
|
|
62
|
+
// see: https://react-hook-form.com/docs/useform#mode
|
|
63
|
+
mode: validationTrigger,
|
|
64
|
+
resolver: (values) => __async(void 0, null, function* () {
|
|
65
|
+
const _a = yield validation.validateAsync(
|
|
66
|
+
toValidationFormat(values)
|
|
67
|
+
), { data, errors } = _a, rest = __objRest(_a, ["data", "errors"]);
|
|
68
|
+
return __spreadValues({ values: data || {}, errors: errors || {} }, rest);
|
|
69
|
+
})
|
|
70
|
+
} : {}));
|
|
71
|
+
const handleSubmit = (e) => __async(void 0, null, function* () {
|
|
74
72
|
if (methods.formState.isValid && preventSubmit) {
|
|
75
73
|
console.warn(
|
|
76
74
|
"[FormProvider] form submit was prevented because preventSubmit is true..."
|
|
77
75
|
);
|
|
78
|
-
e
|
|
76
|
+
e == null ? void 0 : e.preventDefault();
|
|
79
77
|
return Promise.resolve();
|
|
80
78
|
}
|
|
81
|
-
|
|
82
|
-
};
|
|
83
|
-
return /* @__PURE__ */ jsx(UniformContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(HookFormProvider, {
|
|
79
|
+
yield methods.handleSubmit(onSubmit)(e);
|
|
80
|
+
});
|
|
81
|
+
return /* @__PURE__ */ jsx(UniformContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(HookFormProvider, __spreadProps(__spreadValues({}, methods), { children: children({ handleSubmit }) })) });
|
|
84
82
|
};
|
|
85
83
|
var FormContext_default = FormProvider;
|
|
86
84
|
|
|
87
85
|
// src/hooks/useFormContext/useFormContext.ts
|
|
88
86
|
var checkFieldIsRequired = (validation, path) => {
|
|
89
87
|
const checkRequired = (schema) => {
|
|
90
|
-
if (schema.type === "array" && schema
|
|
88
|
+
if (schema.type === "array" && (schema == null ? void 0 : schema.minLength)) {
|
|
91
89
|
return true;
|
|
92
90
|
}
|
|
93
91
|
return !schema.isOptional && !schema.isNullable;
|
|
@@ -95,39 +93,41 @@ var checkFieldIsRequired = (validation, path) => {
|
|
|
95
93
|
return validation.checkSchemaPath(checkRequired, path);
|
|
96
94
|
};
|
|
97
95
|
var useFormContext = () => {
|
|
98
|
-
const {
|
|
96
|
+
const _a = useHookFormContext(), {
|
|
99
97
|
formState,
|
|
98
|
+
getFieldState: getFieldStateOrig
|
|
99
|
+
} = _a, otherMethods = __objRest(_a, [
|
|
100
|
+
"formState",
|
|
100
101
|
// https://react-hook-form.com/docs/useform/getfieldstate
|
|
101
102
|
// for getFieldState a subscription to formState properties is needed!
|
|
102
|
-
getFieldState
|
|
103
|
-
|
|
104
|
-
} = useHookFormContext();
|
|
103
|
+
"getFieldState"
|
|
104
|
+
]);
|
|
105
105
|
const uniformContext = useContext(UniformContext);
|
|
106
106
|
const getFieldState = (name, testId) => {
|
|
107
107
|
const fieldPath = typeof name === "string" ? name.replace(/\[\d+\]/g, "").split(".") : name;
|
|
108
|
-
const required = uniformContext
|
|
109
|
-
const { error,
|
|
110
|
-
return {
|
|
111
|
-
...rest,
|
|
108
|
+
const required = (uniformContext == null ? void 0 : uniformContext.validation) ? checkFieldIsRequired(uniformContext.validation, fieldPath) : false;
|
|
109
|
+
const _a2 = getFieldStateOrig(name, formState), { error } = _a2, rest = __objRest(_a2, ["error"]);
|
|
110
|
+
return __spreadProps(__spreadValues({}, rest), {
|
|
112
111
|
error,
|
|
113
112
|
// Ensure correct type for error
|
|
114
113
|
required,
|
|
115
114
|
testId: slugify(testId || name)
|
|
116
|
-
};
|
|
115
|
+
});
|
|
117
116
|
};
|
|
118
|
-
return {
|
|
119
|
-
...otherMethods,
|
|
120
|
-
...uniformContext,
|
|
117
|
+
return __spreadProps(__spreadValues(__spreadValues({}, otherMethods), uniformContext), {
|
|
121
118
|
getFieldState,
|
|
122
119
|
formState
|
|
123
|
-
};
|
|
120
|
+
});
|
|
124
121
|
};
|
|
125
122
|
|
|
123
|
+
// src/hooks/useInput/useInput.ts
|
|
124
|
+
import { useInput } from "@nextui-org/input";
|
|
125
|
+
|
|
126
126
|
export {
|
|
127
127
|
useFieldArray,
|
|
128
|
-
removeNullishFields,
|
|
129
128
|
FormContext_default,
|
|
130
129
|
checkFieldIsRequired,
|
|
131
|
-
useFormContext
|
|
130
|
+
useFormContext,
|
|
131
|
+
useInput
|
|
132
132
|
};
|
|
133
|
-
//# sourceMappingURL=chunk-
|
|
133
|
+
//# sourceMappingURL=chunk-MRXNKY72.js.map
|