@wix/form-public 0.500.0 → 0.502.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/index.cjs +30 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +19 -10
- package/dist/index.css.map +1 -1
- package/dist/index.js +30 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -51067,7 +51067,8 @@ Label.Image = LabelImage;
|
|
|
51067
51067
|
|
|
51068
51068
|
// ../form-fields/dist/esm/headless/styled/shared/use-element-state-class-name.js
|
|
51069
51069
|
__toESM(require_classnames());
|
|
51070
|
-
createContext(void 0);
|
|
51070
|
+
var ElementPropsContext = createContext(void 0);
|
|
51071
|
+
var useElementProps = () => useContext(ElementPropsContext) ?? {};
|
|
51071
51072
|
function useFocus({ onBlur, onFocus }) {
|
|
51072
51073
|
const containerRef = useRef(null);
|
|
51073
51074
|
const isFocused = useRef(false);
|
|
@@ -55143,9 +55144,27 @@ Donation.Options = Options2;
|
|
|
55143
55144
|
Donation.OtherInput = OtherInput2;
|
|
55144
55145
|
Donation.Description = Description;
|
|
55145
55146
|
Donation.Error = Error2;
|
|
55147
|
+
var DROPDOWN_FIELD_TYPES = [
|
|
55148
|
+
FIELD_TYPES.DROPDOWN,
|
|
55149
|
+
FIELD_TYPES.DEXT_DROPDOWN,
|
|
55150
|
+
FIELD_TYPES.SERVICES_DROPDOWN
|
|
55151
|
+
];
|
|
55152
|
+
var isOpenableDropdown = ({ fieldType, properties }) => DROPDOWN_FIELD_TYPES.includes(fieldType) && !properties.hidden && !properties.disabled && !properties.readOnly;
|
|
55153
|
+
var byLayoutPosition = (first2, second) => first2.layout.row - second.layout.row || first2.layout.column - second.layout.column;
|
|
55154
|
+
var useIsForcedOpenDropdown = (fieldId) => {
|
|
55155
|
+
const isOpenState = useElementProps().dropdown?.open === true;
|
|
55156
|
+
const formView = useContext(FormViewContext);
|
|
55157
|
+
const firstDropdownId = useMemo(() => formView && !formView.parentId ? formView.fields.filter(isOpenableDropdown).sort(byLayoutPosition)[0]?.id : void 0, [
|
|
55158
|
+
formView
|
|
55159
|
+
]);
|
|
55160
|
+
return isOpenState && firstDropdownId === fieldId;
|
|
55161
|
+
};
|
|
55162
|
+
|
|
55163
|
+
// ../form-fields/dist/esm/ui/dropdown-field/dropdown-field-headless.js
|
|
55146
55164
|
var Dropdown = ({ children }) => {
|
|
55147
55165
|
const { id: id6, value, defaultValue, options = [], readOnly, onChange, placeholder, disabled, required, onBlur, onFocus, FieldLayout, hasError } = useFieldPropsV2();
|
|
55148
55166
|
const [isOpen, setIsOpen] = useState(false);
|
|
55167
|
+
const isForcedOpen = useIsForcedOpenDropdown(id6);
|
|
55149
55168
|
const [container, setContainer] = useState(null);
|
|
55150
55169
|
const selectedValue = value && options.some((option2) => (option2.value ?? option2.label) === value) ? value : defaultValue || null;
|
|
55151
55170
|
const { labelId } = useFieldAttributes();
|
|
@@ -55179,8 +55198,8 @@ var Dropdown = ({ children }) => {
|
|
|
55179
55198
|
}, /* @__PURE__ */ React172.createElement(Select, {
|
|
55180
55199
|
"aria-labelledby": labelId,
|
|
55181
55200
|
value: selectedValue,
|
|
55182
|
-
isOpen: isOpen && !disabled && !readOnly,
|
|
55183
|
-
onOpenChange: handleOpenChange,
|
|
55201
|
+
isOpen: isForcedOpen || isOpen && !disabled && !readOnly,
|
|
55202
|
+
onOpenChange: isForcedOpen ? void 0 : handleOpenChange,
|
|
55184
55203
|
onChange: handleChange,
|
|
55185
55204
|
isDisabled: disabled,
|
|
55186
55205
|
isInvalid: hasError,
|
|
@@ -55188,7 +55207,9 @@ var Dropdown = ({ children }) => {
|
|
|
55188
55207
|
placeholder,
|
|
55189
55208
|
onBlur,
|
|
55190
55209
|
onFocus
|
|
55191
|
-
}, triggerElement, optionsElement
|
|
55210
|
+
}, triggerElement, applyInternalProps(optionsElement, {
|
|
55211
|
+
isForcedOpen
|
|
55212
|
+
})))),
|
|
55192
55213
|
renderDescription: () => /* @__PURE__ */ React172.createElement(React172.Fragment, null, errorElement, descriptionElement)
|
|
55193
55214
|
});
|
|
55194
55215
|
};
|
|
@@ -55208,14 +55229,17 @@ var Trigger2 = ({ children, className }) => {
|
|
|
55208
55229
|
"data-loading": isLoading || void 0
|
|
55209
55230
|
}, /* @__PURE__ */ React172.createElement(SelectValue, null), children);
|
|
55210
55231
|
};
|
|
55211
|
-
var Options3 = ({ children, className }) => {
|
|
55232
|
+
var Options3 = ({ children, className, ...internal }) => {
|
|
55233
|
+
const { isForcedOpen } = internal;
|
|
55212
55234
|
const { options = [] } = useFieldPropsV2();
|
|
55213
55235
|
const optionElement = findChildOfType(children, Options3.Option);
|
|
55214
55236
|
return /* @__PURE__ */ React172.createElement(NonModalPopover, {
|
|
55215
55237
|
className,
|
|
55216
55238
|
containerPadding: 0,
|
|
55217
55239
|
offset: 0
|
|
55218
|
-
}, /* @__PURE__ */ React172.createElement(ListBox,
|
|
55240
|
+
}, /* @__PURE__ */ React172.createElement(ListBox, {
|
|
55241
|
+
autoFocus: isForcedOpen ? false : void 0
|
|
55242
|
+
}, options.map((option2) => applyInternalProps(optionElement, {
|
|
55219
55243
|
key: option2.value ?? option2.label,
|
|
55220
55244
|
value: option2.value ?? option2.label,
|
|
55221
55245
|
label: option2.label
|