elseware-ui 3.0.3 → 3.0.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.mjs CHANGED
@@ -7778,6 +7778,17 @@ var InputListGroup = ({
7778
7778
  function isMultiCheckbox(props) {
7779
7779
  return Array.isArray(props.options);
7780
7780
  }
7781
+ function resolveCheckboxColumns(columns) {
7782
+ return columns ?? 1;
7783
+ }
7784
+ function chunkCheckboxOptions(options, columns) {
7785
+ const resolvedColumns = resolveCheckboxColumns(columns);
7786
+ const chunkSize = Math.ceil(options.length / resolvedColumns);
7787
+ return Array.from(
7788
+ { length: resolvedColumns },
7789
+ (_2, columnIndex) => options.slice(columnIndex * chunkSize, (columnIndex + 1) * chunkSize)
7790
+ ).filter((columnOptions) => columnOptions.length > 0);
7791
+ }
7781
7792
  function useResolvedCheckboxConfig({
7782
7793
  label,
7783
7794
  placeholder,
@@ -7936,6 +7947,7 @@ function Checkbox(checkboxProps) {
7936
7947
  const activeFieldName = isMulti ? multiField.name : singleField.name;
7937
7948
  const activeMeta = isMulti ? multiMeta : singleMeta;
7938
7949
  const multiProps = isMultiCheckbox(checkboxProps) ? checkboxProps : null;
7950
+ const optionColumns = multiProps ? chunkCheckboxOptions(multiProps.options, multiProps.columns) : [];
7939
7951
  const singleChecked = singleField.value;
7940
7952
  return /* @__PURE__ */ jsxs("div", { className: cn(checkboxGroupClassName, groupClassName), children: [
7941
7953
  !isMulti && /* @__PURE__ */ jsxs("div", { className: cn(checkboxOptionRowClassName, optionClassName), children: [
@@ -7979,67 +7991,74 @@ function Checkbox(checkboxProps) {
7979
7991
  }
7980
7992
  ) : null
7981
7993
  ] }),
7982
- isMulti && multiProps?.options.map((option) => {
7983
- const values = multiField.value ?? [];
7984
- const checked = values.includes(option.value);
7985
- const optionDisabled = disabled || option.disabled === true;
7986
- return /* @__PURE__ */ jsxs(
7987
- "div",
7988
- {
7989
- className: cn(checkboxOptionRowClassName, optionClassName),
7990
- children: [
7991
- /* @__PURE__ */ jsxs("span", { className: "relative inline-flex h-5 w-5 shrink-0 items-center justify-center", children: [
7992
- /* @__PURE__ */ jsx(
7993
- "input",
7994
- {
7995
- id: option.value,
7996
- name: multiField.name,
7997
- type: "checkbox",
7998
- checked,
7999
- disabled: optionDisabled,
8000
- onBlur: multiField.onBlur,
8001
- onChange: () => {
8002
- multiHelpers.setValue(
8003
- checked ? values.filter((value) => value !== option.value) : [...values, option.value]
8004
- );
8005
- },
8006
- className: getIndicatorClassName({
8007
- checked,
8008
- className,
8009
- disabled: optionDisabled,
8010
- indicatorClassName,
8011
- checkedIndicatorClassName,
8012
- resolvedShape,
8013
- variantCheckedClassName: variantStyles.checkedClassName
8014
- })
8015
- }
8016
- ),
8017
- /* @__PURE__ */ jsx(
8018
- Tick,
8019
- {
8020
- checked,
8021
- checkedIconClassName,
8022
- iconClassName: variantStyles.iconClassName
8023
- }
8024
- )
8025
- ] }),
8026
- /* @__PURE__ */ jsx(
8027
- "label",
8028
- {
8029
- htmlFor: option.value,
8030
- className: cn(
8031
- checkboxLabelClassName,
8032
- optionDisabled && "cursor-not-allowed opacity-60",
8033
- labelClassName
8034
- ),
8035
- children: option.label
8036
- }
8037
- )
8038
- ]
8039
- },
8040
- option.value
8041
- );
8042
- }),
7994
+ isMulti && multiProps ? /* @__PURE__ */ jsx("div", { className: "flex w-full flex-row gap-6", children: optionColumns.map((columnOptions, columnIndex) => /* @__PURE__ */ jsx(
7995
+ "div",
7996
+ {
7997
+ className: "flex min-w-0 flex-1 flex-col gap-2",
7998
+ children: columnOptions.map((option) => {
7999
+ const values = multiField.value ?? [];
8000
+ const checked = values.includes(option.value);
8001
+ const optionDisabled = disabled || option.disabled === true;
8002
+ return /* @__PURE__ */ jsxs(
8003
+ "div",
8004
+ {
8005
+ className: cn(checkboxOptionRowClassName, optionClassName),
8006
+ children: [
8007
+ /* @__PURE__ */ jsxs("span", { className: "relative inline-flex h-5 w-5 shrink-0 items-center justify-center", children: [
8008
+ /* @__PURE__ */ jsx(
8009
+ "input",
8010
+ {
8011
+ id: option.value,
8012
+ name: multiField.name,
8013
+ type: "checkbox",
8014
+ checked,
8015
+ disabled: optionDisabled,
8016
+ onBlur: multiField.onBlur,
8017
+ onChange: () => {
8018
+ multiHelpers.setValue(
8019
+ checked ? values.filter((value) => value !== option.value) : [...values, option.value]
8020
+ );
8021
+ },
8022
+ className: getIndicatorClassName({
8023
+ checked,
8024
+ className,
8025
+ disabled: optionDisabled,
8026
+ indicatorClassName,
8027
+ checkedIndicatorClassName,
8028
+ resolvedShape,
8029
+ variantCheckedClassName: variantStyles.checkedClassName
8030
+ })
8031
+ }
8032
+ ),
8033
+ /* @__PURE__ */ jsx(
8034
+ Tick,
8035
+ {
8036
+ checked,
8037
+ checkedIconClassName,
8038
+ iconClassName: variantStyles.iconClassName
8039
+ }
8040
+ )
8041
+ ] }),
8042
+ /* @__PURE__ */ jsx(
8043
+ "label",
8044
+ {
8045
+ htmlFor: option.value,
8046
+ className: cn(
8047
+ checkboxLabelClassName,
8048
+ optionDisabled && "cursor-not-allowed opacity-60",
8049
+ labelClassName
8050
+ ),
8051
+ children: option.label
8052
+ }
8053
+ )
8054
+ ]
8055
+ },
8056
+ option.value
8057
+ );
8058
+ })
8059
+ },
8060
+ `${multiField.name}-column-${columnIndex}`
8061
+ )) }) : null,
8043
8062
  /* @__PURE__ */ jsx(
8044
8063
  InputResponse,
8045
8064
  {
@@ -8435,6 +8454,7 @@ function MultiImageInput({
8435
8454
  );
8436
8455
  const [imageUrls, setImageUrls] = useState(fieldImageUrls);
8437
8456
  const imageInputRef = useRef(null);
8457
+ const replaceInputRefs = useRef({});
8438
8458
  const [draggedIndex, setDraggedIndex] = useState(null);
8439
8459
  const [replacingIndex, setReplacingIndex] = useState(null);
8440
8460
  const isOrganizerBusy = replacingIndex !== null;
@@ -8528,6 +8548,9 @@ function MultiImageInput({
8528
8548
  moveImage(draggedIndex, index3);
8529
8549
  setDraggedIndex(null);
8530
8550
  };
8551
+ const openReplacePicker = (index3) => {
8552
+ replaceInputRefs.current[index3]?.click();
8553
+ };
8531
8554
  return /* @__PURE__ */ jsxs("div", { children: [
8532
8555
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row flex-wrap gap-5 w-full", children: [
8533
8556
  imageUrls.map((url, index3) => {
@@ -8554,65 +8577,74 @@ function MultiImageInput({
8554
8577
  ] }),
8555
8578
  /* @__PURE__ */ jsxs("div", { className: "absolute right-2 top-2 flex gap-1", children: [
8556
8579
  /* @__PURE__ */ jsx(
8557
- "button",
8580
+ Button_web_default,
8558
8581
  {
8559
- type: "button",
8560
8582
  title: "Move image left",
8561
- "aria-label": "Move image left",
8583
+ accessibilityLabel: "Move image left",
8562
8584
  disabled: index3 === 0 || isOrganizerBusy,
8563
- onClick: () => moveImage(index3, index3 - 1),
8564
- className: "inline-flex h-8 w-8 items-center justify-center rounded bg-black/60 text-xl text-white transition-colors hover:bg-black/80 disabled:cursor-not-allowed disabled:opacity-40",
8565
- children: /* @__PURE__ */ jsx(MdKeyboardArrowLeft, {})
8585
+ glow: false,
8586
+ icon: /* @__PURE__ */ jsx(MdKeyboardArrowLeft, {}),
8587
+ onPress: () => moveImage(index3, index3 - 1),
8588
+ size: "xs",
8589
+ className: "h-8 w-8 bg-black/60 p-0 text-xl text-white hover:bg-black/80 disabled:opacity-40"
8566
8590
  }
8567
8591
  ),
8568
8592
  /* @__PURE__ */ jsx(
8569
- "button",
8593
+ Button_web_default,
8570
8594
  {
8571
- type: "button",
8572
8595
  title: "Move image right",
8573
- "aria-label": "Move image right",
8596
+ accessibilityLabel: "Move image right",
8574
8597
  disabled: index3 === imageUrls.length - 1 || isOrganizerBusy,
8575
- onClick: () => moveImage(index3, index3 + 1),
8576
- className: "inline-flex h-8 w-8 items-center justify-center rounded bg-black/60 text-xl text-white transition-colors hover:bg-black/80 disabled:cursor-not-allowed disabled:opacity-40",
8577
- children: /* @__PURE__ */ jsx(MdKeyboardArrowRight, {})
8598
+ glow: false,
8599
+ icon: /* @__PURE__ */ jsx(MdKeyboardArrowRight, {}),
8600
+ onPress: () => moveImage(index3, index3 + 1),
8601
+ size: "xs",
8602
+ className: "h-8 w-8 bg-black/60 p-0 text-xl text-white hover:bg-black/80 disabled:opacity-40"
8578
8603
  }
8579
8604
  )
8580
8605
  ] }),
8581
8606
  /* @__PURE__ */ jsxs("div", { className: "absolute bottom-2 left-2 right-2 flex items-center justify-between gap-2", children: [
8582
- /* @__PURE__ */ jsxs(
8583
- "label",
8607
+ /* @__PURE__ */ jsx(
8608
+ "input",
8584
8609
  {
8610
+ ref: (input) => {
8611
+ replaceInputRefs.current[index3] = input;
8612
+ },
8613
+ type: "file",
8614
+ className: "hidden",
8615
+ accept: "image/*",
8616
+ disabled: isOrganizerBusy,
8617
+ onChange: (event) => void handleReplaceImage(index3, event)
8618
+ }
8619
+ ),
8620
+ /* @__PURE__ */ jsx(
8621
+ Button_web_default,
8622
+ {
8623
+ block: true,
8624
+ appearance: "solid",
8585
8625
  title: "Change image",
8586
- className: classNames73(
8587
- "inline-flex h-9 flex-1 items-center justify-center gap-2 rounded bg-green-600 px-3 text-sm font-semibold text-white transition-colors",
8588
- isOrganizerBusy ? "pointer-events-none cursor-not-allowed opacity-50" : "cursor-pointer hover:bg-green-700"
8589
- ),
8590
- children: [
8591
- /* @__PURE__ */ jsx(
8592
- "input",
8593
- {
8594
- type: "file",
8595
- className: "hidden",
8596
- accept: "image/*",
8597
- disabled: isOrganizerBusy,
8598
- onChange: (event) => void handleReplaceImage(index3, event)
8599
- }
8600
- ),
8601
- /* @__PURE__ */ jsx(MdUpload, {}),
8602
- "Change"
8603
- ]
8626
+ accessibilityLabel: "Change image",
8627
+ disabled: isOrganizerBusy,
8628
+ glow: false,
8629
+ icon: /* @__PURE__ */ jsx(MdUpload, {}),
8630
+ onPress: () => openReplacePicker(index3),
8631
+ size: "sm",
8632
+ text: "Change",
8633
+ variant: "success"
8604
8634
  }
8605
8635
  ),
8606
8636
  /* @__PURE__ */ jsx(
8607
- "button",
8637
+ Button_web_default,
8608
8638
  {
8609
- type: "button",
8639
+ appearance: "solid",
8610
8640
  title: "Delete image",
8611
- "aria-label": "Delete image",
8641
+ accessibilityLabel: "Delete image",
8612
8642
  disabled: isOrganizerBusy,
8613
- onClick: () => removeImage(index3),
8614
- className: "inline-flex h-9 w-10 items-center justify-center rounded bg-red-600 text-xl text-white transition-colors hover:bg-red-700 disabled:cursor-not-allowed disabled:opacity-50",
8615
- children: /* @__PURE__ */ jsx(MdOutlineDelete, {})
8643
+ glow: false,
8644
+ icon: /* @__PURE__ */ jsx(MdOutlineDelete, {}),
8645
+ onPress: () => removeImage(index3),
8646
+ size: "sm",
8647
+ variant: "danger"
8616
8648
  }
8617
8649
  )
8618
8650
  ] }),