@chekinapp/ui 0.0.42 → 0.0.44

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 CHANGED
@@ -1109,10 +1109,10 @@ var Button = React4.forwardRef(
1109
1109
  disabled: isDisabled,
1110
1110
  className: classNames,
1111
1111
  ...props,
1112
- children: loading ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "inline-flex items-center gap-1.5", children: [
1112
+ children: loading ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
1113
1113
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Spinner, {}),
1114
1114
  showLoadingLabel ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { children: loadingText || t("please_wait") }) : null
1115
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "inline-flex items-center gap-2", children })
1115
+ ] }) : children
1116
1116
  }
1117
1117
  );
1118
1118
  }
@@ -9270,6 +9270,16 @@ var getValueArray2 = (value) => {
9270
9270
  }
9271
9271
  return [];
9272
9272
  };
9273
+ function getToggleContent(label, disabled, readOnly, active) {
9274
+ if ((0, import_react66.isValidElement)(label)) {
9275
+ return (0, import_react66.cloneElement)(label, {
9276
+ disabled,
9277
+ readOnly,
9278
+ active
9279
+ });
9280
+ }
9281
+ return label;
9282
+ }
9273
9283
  function TogglesInternal({
9274
9284
  className,
9275
9285
  groupClassName,
@@ -9286,6 +9296,7 @@ function TogglesInternal({
9286
9296
  readOnly,
9287
9297
  minSelected = 0,
9288
9298
  disabledItems,
9299
+ readonlyItems,
9289
9300
  label,
9290
9301
  multiple = true
9291
9302
  }, ref) {
@@ -9351,19 +9362,21 @@ function TogglesInternal({
9351
9362
  return /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)("div", { ref, className, children: [
9352
9363
  label && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)("div", { className: "mb-2", children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)("div", { className: "select-none text-base font-normal text-[var(--chekin-color-brand-navy)]", children: label }) }),
9353
9364
  /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(ToggleGroup, { className: groupClassName, ...toggleGroupProps, children: options.map((option, index) => {
9354
- const isSelected = getValueArray2(value).includes(option.value);
9365
+ const isSelected = Boolean(
9366
+ getValueArray2(value).find((selectedValue) => selectedValue === option.value)
9367
+ );
9355
9368
  const isDisabled = disabled || disabledItems?.includes(option.value) || option.disabled;
9356
9369
  const isMinSelected = getValueArray2(value).length <= minSelected;
9357
- const isItemReadOnly = readOnly || isMinSelected && isSelected;
9370
+ const isItemReadOnly = readOnly || isMinSelected && isSelected || readonlyItems?.includes(option.value);
9358
9371
  return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
9359
9372
  ToggleGroupItem,
9360
9373
  {
9361
9374
  value: String(option.value),
9362
9375
  disabled: isDisabled || isItemReadOnly || loading,
9363
9376
  onClick: handleItemClick(option),
9364
- children: option.label
9377
+ children: getToggleContent(option.label, isDisabled, isItemReadOnly, isSelected)
9365
9378
  },
9366
- `${option.value}-${index}`
9379
+ index
9367
9380
  );
9368
9381
  }) })
9369
9382
  ] });