@allxsmith/bestax-bulma 5.8.3 → 5.8.4
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.js +60 -25
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +60 -25
- package/dist/index.esm.js.map +1 -1
- package/dist/types/form/Checkboxes.d.ts +6 -0
- package/dist/types/form/Radios.d.ts +6 -0
- package/dist/types/form/Rate.d.ts +6 -0
- package/dist/types/form/useAutoLabelId.d.ts +22 -0
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -5841,6 +5841,45 @@ const Field = withSubComponents(FieldComponent, {
|
|
|
5841
5841
|
Control,
|
|
5842
5842
|
}, 'Field');
|
|
5843
5843
|
|
|
5844
|
+
/**
|
|
5845
|
+
* Associates the convenience `label` prop with its control (#368): generates
|
|
5846
|
+
* an id for the control and returns labelProps carrying a matching `htmlFor`.
|
|
5847
|
+
* A user-supplied `id` is used as the target instead of the generated one, and
|
|
5848
|
+
* an explicit `labelProps.htmlFor` disables generation entirely — the user has
|
|
5849
|
+
* taken over the association. Internal; not part of the public API.
|
|
5850
|
+
*/
|
|
5851
|
+
function useAutoLabelId({ label, id, labelProps, rendersLabel, }) {
|
|
5852
|
+
// Called unconditionally per the rules of hooks; SSR-safe on React 18 and 19.
|
|
5853
|
+
const generatedId = React.useId();
|
|
5854
|
+
// Truthiness mirrors Field's own `if (label)` render gate.
|
|
5855
|
+
const active = !!label && rendersLabel;
|
|
5856
|
+
const controlId = id ?? (active && !labelProps?.htmlFor ? generatedId : undefined);
|
|
5857
|
+
const fieldLabelProps = active
|
|
5858
|
+
? { htmlFor: controlId, ...labelProps }
|
|
5859
|
+
: labelProps;
|
|
5860
|
+
return { controlId, fieldLabelProps };
|
|
5861
|
+
}
|
|
5862
|
+
/**
|
|
5863
|
+
* Group-input counterpart of {@link useAutoLabelId} (#494): a group of
|
|
5864
|
+
* controls cannot take a single `htmlFor`, so instead the rendered `<label>`
|
|
5865
|
+
* gets a generated id and the group container points at it with
|
|
5866
|
+
* `aria-labelledby`. A user-supplied `labelProps.id` is used as the target
|
|
5867
|
+
* instead of generating one. Any caller `htmlFor` is stripped — a group label
|
|
5868
|
+
* names the group, never a single control — so the merged labelProps always
|
|
5869
|
+
* carry an explicit `htmlFor: undefined`.
|
|
5870
|
+
* Internal; not part of the public API.
|
|
5871
|
+
*/
|
|
5872
|
+
function useAutoLabelledBy({ label, labelProps, rendersLabel, }) {
|
|
5873
|
+
// Called unconditionally per the rules of hooks; SSR-safe on React 18 and 19.
|
|
5874
|
+
const generatedId = React.useId();
|
|
5875
|
+
const active = !!label && rendersLabel;
|
|
5876
|
+
const labelId = labelProps?.id ?? (active ? generatedId : undefined);
|
|
5877
|
+
const fieldLabelProps = active
|
|
5878
|
+
? { ...labelProps, id: labelId, htmlFor: undefined }
|
|
5879
|
+
: labelProps;
|
|
5880
|
+
return { ariaLabelledBy: active ? labelId : undefined, fieldLabelProps };
|
|
5881
|
+
}
|
|
5882
|
+
|
|
5844
5883
|
/**
|
|
5845
5884
|
* The `Checkboxes` component wraps multiple `Checkbox` components in a Bulma-styled group.
|
|
5846
5885
|
*
|
|
@@ -5869,6 +5908,11 @@ const Field = withSubComponents(FieldComponent, {
|
|
|
5869
5908
|
const CheckboxesComponent = ({ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName, name, value, defaultValue, onChange, children, className, ...props }) => {
|
|
5870
5909
|
const insideField = useInsideField();
|
|
5871
5910
|
const insideControl = useInsideControl();
|
|
5911
|
+
const { ariaLabelledBy, fieldLabelProps } = useAutoLabelledBy({
|
|
5912
|
+
label,
|
|
5913
|
+
labelProps,
|
|
5914
|
+
rendersLabel: !insideField,
|
|
5915
|
+
});
|
|
5872
5916
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
5873
5917
|
...props,
|
|
5874
5918
|
});
|
|
@@ -5891,37 +5935,18 @@ const CheckboxesComponent = ({ label, labelSize, labelProps, horizontal, message
|
|
|
5891
5935
|
name,
|
|
5892
5936
|
...(groupActive ? { value: currentValue, onChange: handleChange } : {}),
|
|
5893
5937
|
}), [name, groupActive, currentValue, handleChange]);
|
|
5894
|
-
const checkboxesElement = (jsxRuntime.jsx("div", { className: wrapperClass, ...rest, children: jsxRuntime.jsx(CheckboxesProvider, { value: ctx, children: children }) }));
|
|
5938
|
+
const checkboxesElement = (jsxRuntime.jsx("div", { className: wrapperClass, role: "group", "aria-labelledby": ariaLabelledBy, ...rest, children: jsxRuntime.jsx(CheckboxesProvider, { value: ctx, children: children }) }));
|
|
5895
5939
|
let content = checkboxesElement;
|
|
5896
5940
|
if (!insideControl) {
|
|
5897
5941
|
content = jsxRuntime.jsx(Control, { children: content });
|
|
5898
5942
|
}
|
|
5899
5943
|
if (!insideField) {
|
|
5900
|
-
return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps:
|
|
5944
|
+
return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [content, messageEl] }));
|
|
5901
5945
|
}
|
|
5902
5946
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [content, messageEl] }));
|
|
5903
5947
|
};
|
|
5904
5948
|
const Checkboxes = withSubComponents(CheckboxesComponent, { Checkbox }, 'Checkboxes');
|
|
5905
5949
|
|
|
5906
|
-
/**
|
|
5907
|
-
* Associates the convenience `label` prop with its control (#368): generates
|
|
5908
|
-
* an id for the control and returns labelProps carrying a matching `htmlFor`.
|
|
5909
|
-
* A user-supplied `id` is used as the target instead of the generated one, and
|
|
5910
|
-
* an explicit `labelProps.htmlFor` disables generation entirely — the user has
|
|
5911
|
-
* taken over the association. Internal; not part of the public API.
|
|
5912
|
-
*/
|
|
5913
|
-
function useAutoLabelId({ label, id, labelProps, rendersLabel, }) {
|
|
5914
|
-
// Called unconditionally per the rules of hooks; SSR-safe on React 18 and 19.
|
|
5915
|
-
const generatedId = React.useId();
|
|
5916
|
-
// Truthiness mirrors Field's own `if (label)` render gate.
|
|
5917
|
-
const active = !!label && rendersLabel;
|
|
5918
|
-
const controlId = id ?? (active && !labelProps?.htmlFor ? generatedId : undefined);
|
|
5919
|
-
const fieldLabelProps = active
|
|
5920
|
-
? { htmlFor: controlId, ...labelProps }
|
|
5921
|
-
: labelProps;
|
|
5922
|
-
return { controlId, fieldLabelProps };
|
|
5923
|
-
}
|
|
5924
|
-
|
|
5925
5950
|
/**
|
|
5926
5951
|
* The `File` component provides a Bulma-styled file input, supporting color, size, boxed/fullwidth/align styles, icons, "has name", and filename display.
|
|
5927
5952
|
*
|
|
@@ -6077,6 +6102,11 @@ Radio.displayName = 'Radio';
|
|
|
6077
6102
|
const RadiosComponent = ({ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName, name, value, defaultValue, onChange, children, className, ...props }) => {
|
|
6078
6103
|
const insideField = useInsideField();
|
|
6079
6104
|
const insideControl = useInsideControl();
|
|
6105
|
+
const { ariaLabelledBy, fieldLabelProps } = useAutoLabelledBy({
|
|
6106
|
+
label,
|
|
6107
|
+
labelProps,
|
|
6108
|
+
rendersLabel: !insideField,
|
|
6109
|
+
});
|
|
6080
6110
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
6081
6111
|
...props,
|
|
6082
6112
|
});
|
|
@@ -6102,13 +6132,13 @@ const RadiosComponent = ({ label, labelSize, labelProps, horizontal, message, me
|
|
|
6102
6132
|
name,
|
|
6103
6133
|
...(groupActive ? { value: currentValue, onChange: handleChange } : {}),
|
|
6104
6134
|
}), [name, groupActive, currentValue, handleChange]);
|
|
6105
|
-
const radiosElement = (jsxRuntime.jsx("div", { className: wrapperClass, ...rest, children: jsxRuntime.jsx(RadiosProvider, { value: ctx, children: children }) }));
|
|
6135
|
+
const radiosElement = (jsxRuntime.jsx("div", { className: wrapperClass, role: "radiogroup", "aria-labelledby": ariaLabelledBy, ...rest, children: jsxRuntime.jsx(RadiosProvider, { value: ctx, children: children }) }));
|
|
6106
6136
|
let content = radiosElement;
|
|
6107
6137
|
if (!insideControl) {
|
|
6108
6138
|
content = jsxRuntime.jsx(Control, { children: content });
|
|
6109
6139
|
}
|
|
6110
6140
|
if (!insideField) {
|
|
6111
|
-
return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps:
|
|
6141
|
+
return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [content, messageEl] }));
|
|
6112
6142
|
}
|
|
6113
6143
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [content, messageEl] }));
|
|
6114
6144
|
};
|
|
@@ -6837,6 +6867,11 @@ function getFillPercent(iconIndex, value) {
|
|
|
6837
6867
|
const Rate = React.forwardRef(({ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName, value: controlledValue, defaultValue = 0, max = 5, size, disabled = false, showScore = false, showText = false, texts, onChange, customIcon, spaced = false, rtl = false, iconName, iconLibrary: iconLibraryProp, iconVariant, iconFeatures, color, precision = 1, customText, name, form, className, ...props }, ref) => {
|
|
6838
6868
|
const insideField = useInsideField();
|
|
6839
6869
|
const insideControl = useInsideControl();
|
|
6870
|
+
const { ariaLabelledBy, fieldLabelProps } = useAutoLabelledBy({
|
|
6871
|
+
label,
|
|
6872
|
+
labelProps,
|
|
6873
|
+
rendersLabel: !insideField,
|
|
6874
|
+
});
|
|
6840
6875
|
const { bulmaHelperClasses, rest } = useBulmaClasses(props);
|
|
6841
6876
|
const [internalValue, setInternalValue] = React.useState(defaultValue);
|
|
6842
6877
|
const [hoverValue, setHoverValue] = React.useState(null);
|
|
@@ -7033,13 +7068,13 @@ const Rate = React.forwardRef(({ label, labelSize, labelProps, horizontal, messa
|
|
|
7033
7068
|
const rateScoreClass = usePrefixedClassNames('rate-score');
|
|
7034
7069
|
const rateTextClass = usePrefixedClassNames('rate-text');
|
|
7035
7070
|
const rateCustomTextClass = usePrefixedClassNames('rate-custom-text');
|
|
7036
|
-
const rateElement = (jsxRuntime.jsxs("div", { ref: ref, className: combinedClasses, role: "radiogroup", "aria-label":
|
|
7071
|
+
const rateElement = (jsxRuntime.jsxs("div", { ref: ref, className: combinedClasses, role: "radiogroup", "aria-label": ariaLabelledBy ? undefined : 'Rating', "aria-labelledby": ariaLabelledBy, "aria-valuenow": currentValue, "aria-valuemin": 0, "aria-valuemax": max, "aria-valuetext": ariaValueText, tabIndex: disabled ? -1 : 0, onKeyDown: handleKeyDown, ...rest, children: [jsxRuntime.jsx("div", { className: rateItemsClass, children: renderIcons() }), showScore && (jsxRuntime.jsx("span", { className: rateScoreClass, children: getScoreDisplay() })), text && jsxRuntime.jsx("span", { className: rateTextClass, children: text }), customText && (jsxRuntime.jsx("span", { className: rateCustomTextClass, children: customText })), name && (jsxRuntime.jsx("input", { type: "hidden", name: name, value: currentValue, form: form }))] }));
|
|
7037
7072
|
let content = rateElement;
|
|
7038
7073
|
if (!insideControl) {
|
|
7039
7074
|
content = jsxRuntime.jsx(Control, { children: content });
|
|
7040
7075
|
}
|
|
7041
7076
|
if (!insideField) {
|
|
7042
|
-
return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps:
|
|
7077
|
+
return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [content, messageEl] }));
|
|
7043
7078
|
}
|
|
7044
7079
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [content, messageEl] }));
|
|
7045
7080
|
});
|