@chellaa/react 0.2.2 → 0.2.3

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.
@@ -3620,7 +3620,44 @@ var Checkbox = React56.forwardRef(
3620
3620
  formField?.error && formField?.hasErrorMessage ? formField.errorMessageId : null,
3621
3621
  formField?.hasHelperText ? formField.helperTextId : null
3622
3622
  ].filter(Boolean).join(" ") || void 0;
3623
+ const nativeInputNode = /* @__PURE__ */ jsx(
3624
+ "input",
3625
+ {
3626
+ type: "checkbox",
3627
+ id,
3628
+ name,
3629
+ value: valueProp,
3630
+ disabled,
3631
+ readOnly,
3632
+ required,
3633
+ checked: isControlled ? effectiveChecked : void 0,
3634
+ defaultChecked: !isControlled ? defaultChecked : void 0,
3635
+ onChange: handleChange,
3636
+ ref: mergedInputRef,
3637
+ "aria-checked": indeterminate ? "mixed" : effectiveChecked,
3638
+ "aria-invalid": error ? true : void 0,
3639
+ "aria-describedby": ariaDescribedBy,
3640
+ className: "cl-checkbox__input",
3641
+ ...inputProps
3642
+ }
3643
+ );
3623
3644
  if (asChild) {
3645
+ const childElement = React56.isValidElement(children) ? children : null;
3646
+ if (!childElement) {
3647
+ return /* @__PURE__ */ jsx(
3648
+ StyledCheckboxRoot,
3649
+ {
3650
+ as: Slot,
3651
+ ref,
3652
+ className: checkboxClassName,
3653
+ style,
3654
+ sx,
3655
+ ...rest,
3656
+ children
3657
+ }
3658
+ );
3659
+ }
3660
+ const childLabel = childElement.props.children;
3624
3661
  return /* @__PURE__ */ jsx(
3625
3662
  StyledCheckboxRoot,
3626
3663
  {
@@ -3630,7 +3667,15 @@ var Checkbox = React56.forwardRef(
3630
3667
  style,
3631
3668
  sx,
3632
3669
  ...rest,
3633
- children
3670
+ children: React56.cloneElement(
3671
+ childElement,
3672
+ void 0,
3673
+ /* @__PURE__ */ jsxs(Fragment, { children: [
3674
+ nativeInputNode,
3675
+ controlBox,
3676
+ childLabel && /* @__PURE__ */ jsx("span", { className: "cl-checkbox__label ChellaaCheckbox-Label", children: childLabel })
3677
+ ] })
3678
+ )
3634
3679
  }
3635
3680
  );
3636
3681
  }
@@ -3644,27 +3689,7 @@ var Checkbox = React56.forwardRef(
3644
3689
  sx,
3645
3690
  ...rest,
3646
3691
  children: [
3647
- /* @__PURE__ */ jsx(
3648
- "input",
3649
- {
3650
- type: "checkbox",
3651
- id,
3652
- name,
3653
- value: valueProp,
3654
- disabled,
3655
- readOnly,
3656
- required,
3657
- checked: isControlled ? effectiveChecked : void 0,
3658
- defaultChecked: !isControlled ? defaultChecked : void 0,
3659
- onChange: handleChange,
3660
- ref: mergedInputRef,
3661
- "aria-checked": indeterminate ? "mixed" : effectiveChecked,
3662
- "aria-invalid": error ? true : void 0,
3663
- "aria-describedby": ariaDescribedBy,
3664
- className: "cl-checkbox__input",
3665
- ...inputProps
3666
- }
3667
- ),
3692
+ nativeInputNode,
3668
3693
  controlBox,
3669
3694
  children && /* @__PURE__ */ jsx("span", { className: "cl-checkbox__label ChellaaCheckbox-Label", children })
3670
3695
  ]
@@ -3891,7 +3916,43 @@ var Radio = React56.forwardRef(
3891
3916
  formField?.error && formField?.hasErrorMessage ? formField.errorMessageId : null,
3892
3917
  formField?.hasHelperText ? formField.helperTextId : null
3893
3918
  ].filter(Boolean).join(" ") || void 0;
3919
+ const nativeInputNode = /* @__PURE__ */ jsx(
3920
+ "input",
3921
+ {
3922
+ type: "radio",
3923
+ id,
3924
+ name,
3925
+ value: valueProp,
3926
+ disabled,
3927
+ readOnly,
3928
+ required,
3929
+ checked: isControlled ? effectiveChecked : void 0,
3930
+ defaultChecked: !isControlled ? defaultChecked : void 0,
3931
+ onChange: handleChange,
3932
+ ref: mergedInputRef,
3933
+ "aria-invalid": error ? true : void 0,
3934
+ "aria-describedby": ariaDescribedBy,
3935
+ className: "cl-radio__input",
3936
+ ...inputProps
3937
+ }
3938
+ );
3894
3939
  if (asChild) {
3940
+ const childElement = React56.isValidElement(children) ? children : null;
3941
+ if (!childElement) {
3942
+ return /* @__PURE__ */ jsx(
3943
+ StyledRadioRoot,
3944
+ {
3945
+ as: Slot,
3946
+ ref,
3947
+ className: radioClassName,
3948
+ style,
3949
+ sx,
3950
+ ...rest,
3951
+ children
3952
+ }
3953
+ );
3954
+ }
3955
+ const childLabel = childElement.props.children;
3895
3956
  return /* @__PURE__ */ jsx(
3896
3957
  StyledRadioRoot,
3897
3958
  {
@@ -3901,7 +3962,15 @@ var Radio = React56.forwardRef(
3901
3962
  style,
3902
3963
  sx,
3903
3964
  ...rest,
3904
- children
3965
+ children: React56.cloneElement(
3966
+ childElement,
3967
+ void 0,
3968
+ /* @__PURE__ */ jsxs(Fragment, { children: [
3969
+ nativeInputNode,
3970
+ controlBox,
3971
+ childLabel && /* @__PURE__ */ jsx("span", { className: "cl-radio__label ChellaaRadio-Label", children: childLabel })
3972
+ ] })
3973
+ )
3905
3974
  }
3906
3975
  );
3907
3976
  }
@@ -3915,26 +3984,7 @@ var Radio = React56.forwardRef(
3915
3984
  sx,
3916
3985
  ...rest,
3917
3986
  children: [
3918
- /* @__PURE__ */ jsx(
3919
- "input",
3920
- {
3921
- type: "radio",
3922
- id,
3923
- name,
3924
- value: valueProp,
3925
- disabled,
3926
- readOnly,
3927
- required,
3928
- checked: isControlled ? effectiveChecked : void 0,
3929
- defaultChecked: !isControlled ? defaultChecked : void 0,
3930
- onChange: handleChange,
3931
- ref: mergedInputRef,
3932
- "aria-invalid": error ? true : void 0,
3933
- "aria-describedby": ariaDescribedBy,
3934
- className: "cl-radio__input",
3935
- ...inputProps
3936
- }
3937
- ),
3987
+ nativeInputNode,
3938
3988
  controlBox,
3939
3989
  children && /* @__PURE__ */ jsx("span", { className: "cl-radio__label ChellaaRadio-Label", children })
3940
3990
  ]
@@ -4155,7 +4205,46 @@ var Switch = React56.forwardRef(
4155
4205
  formField?.error && formField?.hasErrorMessage ? formField.errorMessageId : null,
4156
4206
  formField?.hasHelperText ? formField.helperTextId : null
4157
4207
  ].filter(Boolean).join(" ") || void 0;
4208
+ const nativeInputNode = /* @__PURE__ */ jsx(
4209
+ "input",
4210
+ {
4211
+ type: "checkbox",
4212
+ role: "switch",
4213
+ id,
4214
+ name,
4215
+ value,
4216
+ disabled,
4217
+ readOnly,
4218
+ required,
4219
+ checked: isControlled ? effectiveChecked : void 0,
4220
+ defaultChecked: !isControlled ? defaultChecked : void 0,
4221
+ onChange: handleChange,
4222
+ onKeyDown: handleKeyDown,
4223
+ ref: mergedInputRef,
4224
+ "aria-checked": effectiveChecked,
4225
+ "aria-invalid": error ? true : void 0,
4226
+ "aria-describedby": ariaDescribedBy,
4227
+ className: "cl-switch__input",
4228
+ ...inputProps
4229
+ }
4230
+ );
4158
4231
  if (asChild) {
4232
+ const childElement = React56.isValidElement(children) ? children : null;
4233
+ if (!childElement) {
4234
+ return /* @__PURE__ */ jsx(
4235
+ StyledSwitchRoot,
4236
+ {
4237
+ as: Slot,
4238
+ ref,
4239
+ className: switchClassName,
4240
+ style,
4241
+ sx,
4242
+ ...rest,
4243
+ children
4244
+ }
4245
+ );
4246
+ }
4247
+ const childLabel = childElement.props.children;
4159
4248
  return /* @__PURE__ */ jsx(
4160
4249
  StyledSwitchRoot,
4161
4250
  {
@@ -4165,7 +4254,15 @@ var Switch = React56.forwardRef(
4165
4254
  style,
4166
4255
  sx,
4167
4256
  ...rest,
4168
- children
4257
+ children: React56.cloneElement(
4258
+ childElement,
4259
+ void 0,
4260
+ /* @__PURE__ */ jsxs(Fragment, { children: [
4261
+ nativeInputNode,
4262
+ trackControl,
4263
+ childLabel && /* @__PURE__ */ jsx("span", { className: "cl-switch__label ChellaaSwitch-Label", children: childLabel })
4264
+ ] })
4265
+ )
4169
4266
  }
4170
4267
  );
4171
4268
  }
@@ -4179,29 +4276,7 @@ var Switch = React56.forwardRef(
4179
4276
  sx,
4180
4277
  ...rest,
4181
4278
  children: [
4182
- /* @__PURE__ */ jsx(
4183
- "input",
4184
- {
4185
- type: "checkbox",
4186
- role: "switch",
4187
- id,
4188
- name,
4189
- value,
4190
- disabled,
4191
- readOnly,
4192
- required,
4193
- checked: isControlled ? effectiveChecked : void 0,
4194
- defaultChecked: !isControlled ? defaultChecked : void 0,
4195
- onChange: handleChange,
4196
- onKeyDown: handleKeyDown,
4197
- ref: mergedInputRef,
4198
- "aria-checked": effectiveChecked,
4199
- "aria-invalid": error ? true : void 0,
4200
- "aria-describedby": ariaDescribedBy,
4201
- className: "cl-switch__input",
4202
- ...inputProps
4203
- }
4204
- ),
4279
+ nativeInputNode,
4205
4280
  trackControl,
4206
4281
  children && /* @__PURE__ */ jsx("span", { className: "cl-switch__label ChellaaSwitch-Label", children })
4207
4282
  ]
@@ -7098,7 +7173,7 @@ var SelectRoot = React56.forwardRef(
7098
7173
  if (children) {
7099
7174
  return children;
7100
7175
  }
7101
- if (options && options.length > 0) {
7176
+ if (options !== void 0) {
7102
7177
  return /* @__PURE__ */ jsxs(Fragment, { children: [
7103
7178
  /* @__PURE__ */ jsxs(SelectTrigger, { children: [
7104
7179
  /* @__PURE__ */ jsx(SelectValue, { placeholder: placeholder ?? void 0 }),
@@ -9036,6 +9111,13 @@ var ComboboxTag = React56.forwardRef(
9036
9111
  } else {
9037
9112
  ctx.removeItem(tagVal);
9038
9113
  }
9114
+ ctx.inputRef.current?.focus();
9115
+ };
9116
+ const handleKeyDown = (e) => {
9117
+ if (e.key === "Enter" || e.key === " ") {
9118
+ e.preventDefault();
9119
+ handleRemove(e);
9120
+ }
9039
9121
  };
9040
9122
  return /* @__PURE__ */ jsxs(
9041
9123
  "span",
@@ -9049,11 +9131,13 @@ var ComboboxTag = React56.forwardRef(
9049
9131
  "button",
9050
9132
  {
9051
9133
  type: "button",
9052
- tabIndex: -1,
9134
+ tabIndex: isDisabled ? -1 : 0,
9053
9135
  "aria-label": `Remove ${typeof children === "string" ? children : tagVal}`,
9054
9136
  className: "cl-combobox__tag-remove",
9055
9137
  disabled: isDisabled,
9056
9138
  onClick: handleRemove,
9139
+ onKeyDown: handleKeyDown,
9140
+ onMouseDown: (e) => e.preventDefault(),
9057
9141
  children: "\xD7"
9058
9142
  }
9059
9143
  )
@@ -9065,7 +9149,15 @@ var ComboboxTag = React56.forwardRef(
9065
9149
  var ComboboxClear = React56.forwardRef(
9066
9150
  function ComboboxClear2(props, ref) {
9067
9151
  const ctx = useComboboxContext();
9068
- const { className, onClick, children, disabled: disabledProp, ...rest } = props;
9152
+ const {
9153
+ className,
9154
+ onClick,
9155
+ onKeyDown,
9156
+ children,
9157
+ disabled: disabledProp,
9158
+ tabIndex = 0,
9159
+ ...rest
9160
+ } = props;
9069
9161
  const isDisabled = disabledProp ?? ctx.isDisabled;
9070
9162
  const hasValue = ctx.isMulti ? Array.isArray(ctx.value) && ctx.value.length > 0 : Boolean(ctx.value || ctx.searchValue);
9071
9163
  if (!hasValue) {
@@ -9075,18 +9167,28 @@ var ComboboxClear = React56.forwardRef(
9075
9167
  e.stopPropagation();
9076
9168
  if (isDisabled) return;
9077
9169
  ctx.clearSelection();
9170
+ ctx.inputRef.current?.focus();
9078
9171
  onClick?.(e);
9079
9172
  };
9173
+ const handleKeyDown = (e) => {
9174
+ if (e.key === "Enter" || e.key === " ") {
9175
+ e.preventDefault();
9176
+ handleClick(e);
9177
+ }
9178
+ onKeyDown?.(e);
9179
+ };
9080
9180
  return /* @__PURE__ */ jsx(
9081
9181
  "button",
9082
9182
  {
9083
9183
  ref,
9084
9184
  type: "button",
9085
- tabIndex: -1,
9185
+ tabIndex: isDisabled ? -1 : tabIndex,
9086
9186
  "aria-label": "Clear selection",
9087
9187
  className: classNames("cl-combobox__clear", className),
9088
9188
  disabled: isDisabled,
9089
9189
  onClick: handleClick,
9190
+ onKeyDown: handleKeyDown,
9191
+ onMouseDown: (e) => e.preventDefault(),
9090
9192
  ...rest,
9091
9193
  children: children ?? /* @__PURE__ */ jsxs(
9092
9194
  "svg",
@@ -9688,6 +9790,9 @@ var TableTh = React56.forwardRef(
9688
9790
  scope = "col",
9689
9791
  className,
9690
9792
  children,
9793
+ tabIndex,
9794
+ onClick,
9795
+ onKeyDown,
9691
9796
  ...props
9692
9797
  }, ref) => {
9693
9798
  const computedAriaSort = isSortable ? sortDirection === "asc" ? "ascending" : sortDirection === "desc" ? "descending" : "none" : props["aria-sort"];
@@ -9699,13 +9804,23 @@ var TableTh = React56.forwardRef(
9699
9804
  sortDirection && sortDirection !== "none" && `cl-table__th--sorted-${sortDirection}`,
9700
9805
  className
9701
9806
  ].filter(Boolean).join(" ");
9807
+ const handleKeyDown = (e) => {
9808
+ if (isSortable && (e.key === "Enter" || e.key === " ")) {
9809
+ e.preventDefault();
9810
+ onClick?.(e);
9811
+ }
9812
+ onKeyDown?.(e);
9813
+ };
9702
9814
  return /* @__PURE__ */ jsx(
9703
9815
  "th",
9704
9816
  {
9705
9817
  ref,
9706
9818
  scope,
9819
+ tabIndex: tabIndex ?? (isSortable ? 0 : void 0),
9707
9820
  "aria-sort": computedAriaSort,
9708
9821
  className: classNames2,
9822
+ onClick,
9823
+ onKeyDown: handleKeyDown,
9709
9824
  ...props,
9710
9825
  children
9711
9826
  }