@seed-design/react-field-button 0.0.0-alpha-20260414104312
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/lib/FieldButton-12s-BzczO8x6.js +225 -0
- package/lib/FieldButton-12s-CG6rqNcy.cjs +231 -0
- package/lib/index.cjs +20 -0
- package/lib/index.d.ts +2096 -0
- package/lib/index.js +14 -0
- package/package.json +48 -0
- package/src/FieldButton.namespace.ts +14 -0
- package/src/FieldButton.tsx +101 -0
- package/src/dom.ts +2 -0
- package/src/index.ts +19 -0
- package/src/useFieldButton.test.tsx +276 -0
- package/src/useFieldButton.ts +210 -0
- package/src/useFieldButtonContext.tsx +21 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { composeRefs } from '@radix-ui/react-compose-refs';
|
|
4
|
+
import { elementProps, dataAttr, buttonProps, inputProps, ariaAttr, mergeProps } from '@seed-design/dom-utils';
|
|
5
|
+
import { Primitive } from '@seed-design/react-primitive';
|
|
6
|
+
import { useId, useCallback, useState, createContext, useContext, forwardRef } from 'react';
|
|
7
|
+
import { useSupports } from '@seed-design/react-supports';
|
|
8
|
+
|
|
9
|
+
const getDescriptionId = (id)=>`field-button:${id}:description`;
|
|
10
|
+
const getErrorMessageId = (id)=>`field-button:${id}:error-message`;
|
|
11
|
+
|
|
12
|
+
function useFieldButtonState({ values = [], onValuesChange = ()=>{} }) {
|
|
13
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
14
|
+
const [isActive, setIsActive] = useState(false);
|
|
15
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
16
|
+
const [isFocusVisible, setIsFocusVisible] = useState(false);
|
|
17
|
+
const [isDescriptionRendered, setIsDescriptionRendered] = useState(false);
|
|
18
|
+
const descriptionRef = useCallback((node)=>{
|
|
19
|
+
setIsDescriptionRendered(!!node);
|
|
20
|
+
}, []);
|
|
21
|
+
const [isErrorMessageRendered, setIsErrorMessageRendered] = useState(false);
|
|
22
|
+
const errorMessageRef = useCallback((node)=>{
|
|
23
|
+
setIsErrorMessageRendered(!!node);
|
|
24
|
+
}, []);
|
|
25
|
+
return {
|
|
26
|
+
values,
|
|
27
|
+
isHovered,
|
|
28
|
+
isActive,
|
|
29
|
+
isFocused,
|
|
30
|
+
isFocusVisible,
|
|
31
|
+
refs: {
|
|
32
|
+
description: descriptionRef,
|
|
33
|
+
errorMessage: errorMessageRef
|
|
34
|
+
},
|
|
35
|
+
renderedElements: {
|
|
36
|
+
description: isDescriptionRendered,
|
|
37
|
+
errorMessage: isErrorMessageRendered
|
|
38
|
+
},
|
|
39
|
+
setValues: onValuesChange,
|
|
40
|
+
setIsHovered,
|
|
41
|
+
setIsActive,
|
|
42
|
+
setIsFocused,
|
|
43
|
+
setIsFocusVisible
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function useFieldButton({ values: propValues, onValuesChange, disabled = false, invalid = false, readOnly = false, name }) {
|
|
47
|
+
const id = useId();
|
|
48
|
+
const isFocusVisibleSupported = useSupports("selector(:focus-visible)");
|
|
49
|
+
const { values: stateValues, isHovered, isActive, isFocused, isFocusVisible, refs, renderedElements, setValues, setIsHovered, setIsActive, setIsFocused, setIsFocusVisible } = useFieldButtonState({
|
|
50
|
+
values: propValues,
|
|
51
|
+
onValuesChange
|
|
52
|
+
});
|
|
53
|
+
const ariaDescribedBy = [
|
|
54
|
+
renderedElements.description ? getDescriptionId(id) : false,
|
|
55
|
+
renderedElements.errorMessage ? getErrorMessageId(id) : false
|
|
56
|
+
].filter(Boolean).join(" ") || undefined;
|
|
57
|
+
const stateProps = elementProps({
|
|
58
|
+
"data-hover": dataAttr(isHovered),
|
|
59
|
+
"data-active": dataAttr(isActive),
|
|
60
|
+
"data-focus": dataAttr(isFocused),
|
|
61
|
+
"data-focus-visible": dataAttr(isFocusVisible),
|
|
62
|
+
"data-disabled": dataAttr(disabled),
|
|
63
|
+
"data-invalid": dataAttr(invalid),
|
|
64
|
+
"data-readonly": dataAttr(readOnly)
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
values: stateValues,
|
|
68
|
+
active: isActive,
|
|
69
|
+
focused: isFocused,
|
|
70
|
+
invalid,
|
|
71
|
+
disabled,
|
|
72
|
+
readOnly,
|
|
73
|
+
setIsFocused,
|
|
74
|
+
setIsFocusVisible,
|
|
75
|
+
refs,
|
|
76
|
+
stateProps,
|
|
77
|
+
rootProps: elementProps({
|
|
78
|
+
...stateProps,
|
|
79
|
+
onPointerMove () {
|
|
80
|
+
setIsHovered(true);
|
|
81
|
+
},
|
|
82
|
+
onPointerLeave () {
|
|
83
|
+
setIsHovered(false);
|
|
84
|
+
setIsActive(false);
|
|
85
|
+
}
|
|
86
|
+
}),
|
|
87
|
+
buttonProps: buttonProps({
|
|
88
|
+
...stateProps,
|
|
89
|
+
type: "button",
|
|
90
|
+
disabled: disabled || readOnly,
|
|
91
|
+
"aria-disabled": ariaAttr(disabled || readOnly),
|
|
92
|
+
"aria-describedby": ariaDescribedBy,
|
|
93
|
+
// note that pointerdown and pointerup are attached to the button, not the root
|
|
94
|
+
// this is for preventing setting isActive to true when the clear button is pressed
|
|
95
|
+
onPointerDown () {
|
|
96
|
+
setIsActive(true);
|
|
97
|
+
},
|
|
98
|
+
onPointerUp () {
|
|
99
|
+
setIsActive(false);
|
|
100
|
+
},
|
|
101
|
+
onBlur () {
|
|
102
|
+
setIsFocused(false);
|
|
103
|
+
if (isFocusVisibleSupported) {
|
|
104
|
+
setIsFocusVisible(false);
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
onFocus (event) {
|
|
108
|
+
setIsFocused(true);
|
|
109
|
+
if (isFocusVisibleSupported) {
|
|
110
|
+
setIsFocusVisible(event.target.matches(":focus-visible"));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}),
|
|
114
|
+
clearButtonProps: buttonProps({
|
|
115
|
+
type: "button",
|
|
116
|
+
disabled: disabled || readOnly,
|
|
117
|
+
onClick: useCallback(()=>setValues([]), [
|
|
118
|
+
setValues
|
|
119
|
+
]),
|
|
120
|
+
hidden: disabled || readOnly
|
|
121
|
+
}),
|
|
122
|
+
getHiddenInputProps: useCallback((index)=>{
|
|
123
|
+
const value = stateValues[index];
|
|
124
|
+
if (value === undefined) return null;
|
|
125
|
+
return inputProps({
|
|
126
|
+
type: "hidden",
|
|
127
|
+
value,
|
|
128
|
+
disabled,
|
|
129
|
+
name: name || id
|
|
130
|
+
});
|
|
131
|
+
}, [
|
|
132
|
+
stateValues,
|
|
133
|
+
name,
|
|
134
|
+
id,
|
|
135
|
+
disabled
|
|
136
|
+
]),
|
|
137
|
+
descriptionProps: elementProps({
|
|
138
|
+
...stateProps,
|
|
139
|
+
id: getDescriptionId(id)
|
|
140
|
+
}),
|
|
141
|
+
errorMessageProps: elementProps({
|
|
142
|
+
...stateProps,
|
|
143
|
+
id: getErrorMessageId(id),
|
|
144
|
+
"aria-live": "polite"
|
|
145
|
+
})
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const FieldButtonContext = /*#__PURE__*/ createContext(null);
|
|
150
|
+
const FieldButtonProvider = FieldButtonContext.Provider;
|
|
151
|
+
function useFieldButtonContext({ strict = true } = {}) {
|
|
152
|
+
const context = useContext(FieldButtonContext);
|
|
153
|
+
if (!context && strict) {
|
|
154
|
+
throw new Error("useFieldButtonContext must be used within a FieldButton");
|
|
155
|
+
}
|
|
156
|
+
return context;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const FieldButtonRoot = /*#__PURE__*/ forwardRef(({ disabled, readOnly, invalid, name, values, onValuesChange, ...otherProps }, ref)=>{
|
|
160
|
+
const api = useFieldButton({
|
|
161
|
+
disabled,
|
|
162
|
+
readOnly,
|
|
163
|
+
invalid,
|
|
164
|
+
name,
|
|
165
|
+
values,
|
|
166
|
+
onValuesChange
|
|
167
|
+
});
|
|
168
|
+
const mergedProps = mergeProps(api.rootProps, otherProps);
|
|
169
|
+
return /*#__PURE__*/ jsx(FieldButtonProvider, {
|
|
170
|
+
value: api,
|
|
171
|
+
children: /*#__PURE__*/ jsx(Primitive.div, {
|
|
172
|
+
ref: ref,
|
|
173
|
+
...mergedProps
|
|
174
|
+
})
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
FieldButtonRoot.displayName = "FieldButtonRoot";
|
|
178
|
+
const FieldButtonButton = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
179
|
+
const { buttonProps } = useFieldButtonContext();
|
|
180
|
+
const mergedProps = mergeProps(buttonProps, props);
|
|
181
|
+
return /*#__PURE__*/ jsx(Primitive.button, {
|
|
182
|
+
ref: ref,
|
|
183
|
+
...mergedProps
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
FieldButtonButton.displayName = "FieldButtonButton";
|
|
187
|
+
const FieldButtonDescription = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
188
|
+
const { refs, descriptionProps } = useFieldButtonContext();
|
|
189
|
+
const mergedProps = mergeProps(descriptionProps, props);
|
|
190
|
+
return /*#__PURE__*/ jsx(Primitive.span, {
|
|
191
|
+
ref: composeRefs(refs.description, ref),
|
|
192
|
+
...mergedProps
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
FieldButtonDescription.displayName = "FieldButtonDescription";
|
|
196
|
+
const FieldButtonErrorMessage = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
197
|
+
const { refs, errorMessageProps } = useFieldButtonContext();
|
|
198
|
+
const mergedProps = mergeProps(errorMessageProps, props);
|
|
199
|
+
return /*#__PURE__*/ jsx(Primitive.div, {
|
|
200
|
+
ref: composeRefs(refs.errorMessage, ref),
|
|
201
|
+
...mergedProps
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
FieldButtonErrorMessage.displayName = "FieldButtonErrorMessage";
|
|
205
|
+
const FieldButtonHiddenInput = /*#__PURE__*/ forwardRef(({ valueIndex, ...props }, ref)=>{
|
|
206
|
+
const { getHiddenInputProps } = useFieldButtonContext();
|
|
207
|
+
const hiddenInputProps = getHiddenInputProps(valueIndex);
|
|
208
|
+
if (!hiddenInputProps) return null;
|
|
209
|
+
return /*#__PURE__*/ jsx(Primitive.input, {
|
|
210
|
+
ref: ref,
|
|
211
|
+
...mergeProps(hiddenInputProps, props)
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
FieldButtonHiddenInput.displayName = "FieldButtonHiddenInput";
|
|
215
|
+
const FieldButtonClearButton = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
216
|
+
const { clearButtonProps } = useFieldButtonContext();
|
|
217
|
+
const mergedProps = mergeProps(clearButtonProps, props);
|
|
218
|
+
return /*#__PURE__*/ jsx(Primitive.button, {
|
|
219
|
+
ref: ref,
|
|
220
|
+
...mergedProps
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
FieldButtonClearButton.displayName = "FieldButtonClearButton";
|
|
224
|
+
|
|
225
|
+
export { FieldButtonButton as F, FieldButtonClearButton as a, FieldButtonDescription as b, FieldButtonErrorMessage as c, FieldButtonHiddenInput as d, FieldButtonRoot as e, useFieldButtonContext as u };
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
3
|
+
var reactComposeRefs = require('@radix-ui/react-compose-refs');
|
|
4
|
+
var domUtils = require('@seed-design/dom-utils');
|
|
5
|
+
var reactPrimitive = require('@seed-design/react-primitive');
|
|
6
|
+
var react = require('react');
|
|
7
|
+
var reactSupports = require('@seed-design/react-supports');
|
|
8
|
+
|
|
9
|
+
const getDescriptionId = (id)=>`field-button:${id}:description`;
|
|
10
|
+
const getErrorMessageId = (id)=>`field-button:${id}:error-message`;
|
|
11
|
+
|
|
12
|
+
function useFieldButtonState({ values = [], onValuesChange = ()=>{} }) {
|
|
13
|
+
const [isHovered, setIsHovered] = react.useState(false);
|
|
14
|
+
const [isActive, setIsActive] = react.useState(false);
|
|
15
|
+
const [isFocused, setIsFocused] = react.useState(false);
|
|
16
|
+
const [isFocusVisible, setIsFocusVisible] = react.useState(false);
|
|
17
|
+
const [isDescriptionRendered, setIsDescriptionRendered] = react.useState(false);
|
|
18
|
+
const descriptionRef = react.useCallback((node)=>{
|
|
19
|
+
setIsDescriptionRendered(!!node);
|
|
20
|
+
}, []);
|
|
21
|
+
const [isErrorMessageRendered, setIsErrorMessageRendered] = react.useState(false);
|
|
22
|
+
const errorMessageRef = react.useCallback((node)=>{
|
|
23
|
+
setIsErrorMessageRendered(!!node);
|
|
24
|
+
}, []);
|
|
25
|
+
return {
|
|
26
|
+
values,
|
|
27
|
+
isHovered,
|
|
28
|
+
isActive,
|
|
29
|
+
isFocused,
|
|
30
|
+
isFocusVisible,
|
|
31
|
+
refs: {
|
|
32
|
+
description: descriptionRef,
|
|
33
|
+
errorMessage: errorMessageRef
|
|
34
|
+
},
|
|
35
|
+
renderedElements: {
|
|
36
|
+
description: isDescriptionRendered,
|
|
37
|
+
errorMessage: isErrorMessageRendered
|
|
38
|
+
},
|
|
39
|
+
setValues: onValuesChange,
|
|
40
|
+
setIsHovered,
|
|
41
|
+
setIsActive,
|
|
42
|
+
setIsFocused,
|
|
43
|
+
setIsFocusVisible
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function useFieldButton({ values: propValues, onValuesChange, disabled = false, invalid = false, readOnly = false, name }) {
|
|
47
|
+
const id = react.useId();
|
|
48
|
+
const isFocusVisibleSupported = reactSupports.useSupports("selector(:focus-visible)");
|
|
49
|
+
const { values: stateValues, isHovered, isActive, isFocused, isFocusVisible, refs, renderedElements, setValues, setIsHovered, setIsActive, setIsFocused, setIsFocusVisible } = useFieldButtonState({
|
|
50
|
+
values: propValues,
|
|
51
|
+
onValuesChange
|
|
52
|
+
});
|
|
53
|
+
const ariaDescribedBy = [
|
|
54
|
+
renderedElements.description ? getDescriptionId(id) : false,
|
|
55
|
+
renderedElements.errorMessage ? getErrorMessageId(id) : false
|
|
56
|
+
].filter(Boolean).join(" ") || undefined;
|
|
57
|
+
const stateProps = domUtils.elementProps({
|
|
58
|
+
"data-hover": domUtils.dataAttr(isHovered),
|
|
59
|
+
"data-active": domUtils.dataAttr(isActive),
|
|
60
|
+
"data-focus": domUtils.dataAttr(isFocused),
|
|
61
|
+
"data-focus-visible": domUtils.dataAttr(isFocusVisible),
|
|
62
|
+
"data-disabled": domUtils.dataAttr(disabled),
|
|
63
|
+
"data-invalid": domUtils.dataAttr(invalid),
|
|
64
|
+
"data-readonly": domUtils.dataAttr(readOnly)
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
values: stateValues,
|
|
68
|
+
active: isActive,
|
|
69
|
+
focused: isFocused,
|
|
70
|
+
invalid,
|
|
71
|
+
disabled,
|
|
72
|
+
readOnly,
|
|
73
|
+
setIsFocused,
|
|
74
|
+
setIsFocusVisible,
|
|
75
|
+
refs,
|
|
76
|
+
stateProps,
|
|
77
|
+
rootProps: domUtils.elementProps({
|
|
78
|
+
...stateProps,
|
|
79
|
+
onPointerMove () {
|
|
80
|
+
setIsHovered(true);
|
|
81
|
+
},
|
|
82
|
+
onPointerLeave () {
|
|
83
|
+
setIsHovered(false);
|
|
84
|
+
setIsActive(false);
|
|
85
|
+
}
|
|
86
|
+
}),
|
|
87
|
+
buttonProps: domUtils.buttonProps({
|
|
88
|
+
...stateProps,
|
|
89
|
+
type: "button",
|
|
90
|
+
disabled: disabled || readOnly,
|
|
91
|
+
"aria-disabled": domUtils.ariaAttr(disabled || readOnly),
|
|
92
|
+
"aria-describedby": ariaDescribedBy,
|
|
93
|
+
// note that pointerdown and pointerup are attached to the button, not the root
|
|
94
|
+
// this is for preventing setting isActive to true when the clear button is pressed
|
|
95
|
+
onPointerDown () {
|
|
96
|
+
setIsActive(true);
|
|
97
|
+
},
|
|
98
|
+
onPointerUp () {
|
|
99
|
+
setIsActive(false);
|
|
100
|
+
},
|
|
101
|
+
onBlur () {
|
|
102
|
+
setIsFocused(false);
|
|
103
|
+
if (isFocusVisibleSupported) {
|
|
104
|
+
setIsFocusVisible(false);
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
onFocus (event) {
|
|
108
|
+
setIsFocused(true);
|
|
109
|
+
if (isFocusVisibleSupported) {
|
|
110
|
+
setIsFocusVisible(event.target.matches(":focus-visible"));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}),
|
|
114
|
+
clearButtonProps: domUtils.buttonProps({
|
|
115
|
+
type: "button",
|
|
116
|
+
disabled: disabled || readOnly,
|
|
117
|
+
onClick: react.useCallback(()=>setValues([]), [
|
|
118
|
+
setValues
|
|
119
|
+
]),
|
|
120
|
+
hidden: disabled || readOnly
|
|
121
|
+
}),
|
|
122
|
+
getHiddenInputProps: react.useCallback((index)=>{
|
|
123
|
+
const value = stateValues[index];
|
|
124
|
+
if (value === undefined) return null;
|
|
125
|
+
return domUtils.inputProps({
|
|
126
|
+
type: "hidden",
|
|
127
|
+
value,
|
|
128
|
+
disabled,
|
|
129
|
+
name: name || id
|
|
130
|
+
});
|
|
131
|
+
}, [
|
|
132
|
+
stateValues,
|
|
133
|
+
name,
|
|
134
|
+
id,
|
|
135
|
+
disabled
|
|
136
|
+
]),
|
|
137
|
+
descriptionProps: domUtils.elementProps({
|
|
138
|
+
...stateProps,
|
|
139
|
+
id: getDescriptionId(id)
|
|
140
|
+
}),
|
|
141
|
+
errorMessageProps: domUtils.elementProps({
|
|
142
|
+
...stateProps,
|
|
143
|
+
id: getErrorMessageId(id),
|
|
144
|
+
"aria-live": "polite"
|
|
145
|
+
})
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const FieldButtonContext = /*#__PURE__*/ react.createContext(null);
|
|
150
|
+
const FieldButtonProvider = FieldButtonContext.Provider;
|
|
151
|
+
function useFieldButtonContext({ strict = true } = {}) {
|
|
152
|
+
const context = react.useContext(FieldButtonContext);
|
|
153
|
+
if (!context && strict) {
|
|
154
|
+
throw new Error("useFieldButtonContext must be used within a FieldButton");
|
|
155
|
+
}
|
|
156
|
+
return context;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const FieldButtonRoot = /*#__PURE__*/ react.forwardRef(({ disabled, readOnly, invalid, name, values, onValuesChange, ...otherProps }, ref)=>{
|
|
160
|
+
const api = useFieldButton({
|
|
161
|
+
disabled,
|
|
162
|
+
readOnly,
|
|
163
|
+
invalid,
|
|
164
|
+
name,
|
|
165
|
+
values,
|
|
166
|
+
onValuesChange
|
|
167
|
+
});
|
|
168
|
+
const mergedProps = domUtils.mergeProps(api.rootProps, otherProps);
|
|
169
|
+
return /*#__PURE__*/ jsxRuntime.jsx(FieldButtonProvider, {
|
|
170
|
+
value: api,
|
|
171
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(reactPrimitive.Primitive.div, {
|
|
172
|
+
ref: ref,
|
|
173
|
+
...mergedProps
|
|
174
|
+
})
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
FieldButtonRoot.displayName = "FieldButtonRoot";
|
|
178
|
+
const FieldButtonButton = /*#__PURE__*/ react.forwardRef((props, ref)=>{
|
|
179
|
+
const { buttonProps } = useFieldButtonContext();
|
|
180
|
+
const mergedProps = domUtils.mergeProps(buttonProps, props);
|
|
181
|
+
return /*#__PURE__*/ jsxRuntime.jsx(reactPrimitive.Primitive.button, {
|
|
182
|
+
ref: ref,
|
|
183
|
+
...mergedProps
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
FieldButtonButton.displayName = "FieldButtonButton";
|
|
187
|
+
const FieldButtonDescription = /*#__PURE__*/ react.forwardRef((props, ref)=>{
|
|
188
|
+
const { refs, descriptionProps } = useFieldButtonContext();
|
|
189
|
+
const mergedProps = domUtils.mergeProps(descriptionProps, props);
|
|
190
|
+
return /*#__PURE__*/ jsxRuntime.jsx(reactPrimitive.Primitive.span, {
|
|
191
|
+
ref: reactComposeRefs.composeRefs(refs.description, ref),
|
|
192
|
+
...mergedProps
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
FieldButtonDescription.displayName = "FieldButtonDescription";
|
|
196
|
+
const FieldButtonErrorMessage = /*#__PURE__*/ react.forwardRef((props, ref)=>{
|
|
197
|
+
const { refs, errorMessageProps } = useFieldButtonContext();
|
|
198
|
+
const mergedProps = domUtils.mergeProps(errorMessageProps, props);
|
|
199
|
+
return /*#__PURE__*/ jsxRuntime.jsx(reactPrimitive.Primitive.div, {
|
|
200
|
+
ref: reactComposeRefs.composeRefs(refs.errorMessage, ref),
|
|
201
|
+
...mergedProps
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
FieldButtonErrorMessage.displayName = "FieldButtonErrorMessage";
|
|
205
|
+
const FieldButtonHiddenInput = /*#__PURE__*/ react.forwardRef(({ valueIndex, ...props }, ref)=>{
|
|
206
|
+
const { getHiddenInputProps } = useFieldButtonContext();
|
|
207
|
+
const hiddenInputProps = getHiddenInputProps(valueIndex);
|
|
208
|
+
if (!hiddenInputProps) return null;
|
|
209
|
+
return /*#__PURE__*/ jsxRuntime.jsx(reactPrimitive.Primitive.input, {
|
|
210
|
+
ref: ref,
|
|
211
|
+
...domUtils.mergeProps(hiddenInputProps, props)
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
FieldButtonHiddenInput.displayName = "FieldButtonHiddenInput";
|
|
215
|
+
const FieldButtonClearButton = /*#__PURE__*/ react.forwardRef((props, ref)=>{
|
|
216
|
+
const { clearButtonProps } = useFieldButtonContext();
|
|
217
|
+
const mergedProps = domUtils.mergeProps(clearButtonProps, props);
|
|
218
|
+
return /*#__PURE__*/ jsxRuntime.jsx(reactPrimitive.Primitive.button, {
|
|
219
|
+
ref: ref,
|
|
220
|
+
...mergedProps
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
FieldButtonClearButton.displayName = "FieldButtonClearButton";
|
|
224
|
+
|
|
225
|
+
exports.FieldButtonButton = FieldButtonButton;
|
|
226
|
+
exports.FieldButtonClearButton = FieldButtonClearButton;
|
|
227
|
+
exports.FieldButtonDescription = FieldButtonDescription;
|
|
228
|
+
exports.FieldButtonErrorMessage = FieldButtonErrorMessage;
|
|
229
|
+
exports.FieldButtonHiddenInput = FieldButtonHiddenInput;
|
|
230
|
+
exports.FieldButtonRoot = FieldButtonRoot;
|
|
231
|
+
exports.useFieldButtonContext = useFieldButtonContext;
|
package/lib/index.cjs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var FieldButton12s = require('./FieldButton-12s-CG6rqNcy.cjs');
|
|
2
|
+
|
|
3
|
+
var FieldButton_namespace = {
|
|
4
|
+
__proto__: null,
|
|
5
|
+
Button: FieldButton12s.FieldButtonButton,
|
|
6
|
+
ClearButton: FieldButton12s.FieldButtonClearButton,
|
|
7
|
+
Description: FieldButton12s.FieldButtonDescription,
|
|
8
|
+
ErrorMessage: FieldButton12s.FieldButtonErrorMessage,
|
|
9
|
+
HiddenInput: FieldButton12s.FieldButtonHiddenInput,
|
|
10
|
+
Root: FieldButton12s.FieldButtonRoot
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
exports.FieldButtonButton = FieldButton12s.FieldButtonButton;
|
|
14
|
+
exports.FieldButtonClearButton = FieldButton12s.FieldButtonClearButton;
|
|
15
|
+
exports.FieldButtonDescription = FieldButton12s.FieldButtonDescription;
|
|
16
|
+
exports.FieldButtonErrorMessage = FieldButton12s.FieldButtonErrorMessage;
|
|
17
|
+
exports.FieldButtonHiddenInput = FieldButton12s.FieldButtonHiddenInput;
|
|
18
|
+
exports.FieldButtonRoot = FieldButton12s.FieldButtonRoot;
|
|
19
|
+
exports.useFieldButtonContext = FieldButton12s.useFieldButtonContext;
|
|
20
|
+
exports.FieldButton = FieldButton_namespace;
|