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