@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.
package/dist/index.cjs CHANGED
@@ -3646,7 +3646,44 @@ var Checkbox = React56__namespace.forwardRef(
3646
3646
  formField?.error && formField?.hasErrorMessage ? formField.errorMessageId : null,
3647
3647
  formField?.hasHelperText ? formField.helperTextId : null
3648
3648
  ].filter(Boolean).join(" ") || void 0;
3649
+ const nativeInputNode = /* @__PURE__ */ jsxRuntime.jsx(
3650
+ "input",
3651
+ {
3652
+ type: "checkbox",
3653
+ id,
3654
+ name,
3655
+ value: valueProp,
3656
+ disabled,
3657
+ readOnly,
3658
+ required,
3659
+ checked: isControlled ? effectiveChecked : void 0,
3660
+ defaultChecked: !isControlled ? defaultChecked : void 0,
3661
+ onChange: handleChange,
3662
+ ref: mergedInputRef,
3663
+ "aria-checked": indeterminate ? "mixed" : effectiveChecked,
3664
+ "aria-invalid": error ? true : void 0,
3665
+ "aria-describedby": ariaDescribedBy,
3666
+ className: "cl-checkbox__input",
3667
+ ...inputProps
3668
+ }
3669
+ );
3649
3670
  if (asChild) {
3671
+ const childElement = React56__namespace.isValidElement(children) ? children : null;
3672
+ if (!childElement) {
3673
+ return /* @__PURE__ */ jsxRuntime.jsx(
3674
+ StyledCheckboxRoot,
3675
+ {
3676
+ as: Slot,
3677
+ ref,
3678
+ className: checkboxClassName,
3679
+ style,
3680
+ sx,
3681
+ ...rest,
3682
+ children
3683
+ }
3684
+ );
3685
+ }
3686
+ const childLabel = childElement.props.children;
3650
3687
  return /* @__PURE__ */ jsxRuntime.jsx(
3651
3688
  StyledCheckboxRoot,
3652
3689
  {
@@ -3656,7 +3693,15 @@ var Checkbox = React56__namespace.forwardRef(
3656
3693
  style,
3657
3694
  sx,
3658
3695
  ...rest,
3659
- children
3696
+ children: React56__namespace.cloneElement(
3697
+ childElement,
3698
+ void 0,
3699
+ /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3700
+ nativeInputNode,
3701
+ controlBox,
3702
+ childLabel && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "cl-checkbox__label ChellaaCheckbox-Label", children: childLabel })
3703
+ ] })
3704
+ )
3660
3705
  }
3661
3706
  );
3662
3707
  }
@@ -3670,27 +3715,7 @@ var Checkbox = React56__namespace.forwardRef(
3670
3715
  sx,
3671
3716
  ...rest,
3672
3717
  children: [
3673
- /* @__PURE__ */ jsxRuntime.jsx(
3674
- "input",
3675
- {
3676
- type: "checkbox",
3677
- id,
3678
- name,
3679
- value: valueProp,
3680
- disabled,
3681
- readOnly,
3682
- required,
3683
- checked: isControlled ? effectiveChecked : void 0,
3684
- defaultChecked: !isControlled ? defaultChecked : void 0,
3685
- onChange: handleChange,
3686
- ref: mergedInputRef,
3687
- "aria-checked": indeterminate ? "mixed" : effectiveChecked,
3688
- "aria-invalid": error ? true : void 0,
3689
- "aria-describedby": ariaDescribedBy,
3690
- className: "cl-checkbox__input",
3691
- ...inputProps
3692
- }
3693
- ),
3718
+ nativeInputNode,
3694
3719
  controlBox,
3695
3720
  children && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "cl-checkbox__label ChellaaCheckbox-Label", children })
3696
3721
  ]
@@ -3917,7 +3942,43 @@ var Radio = React56__namespace.forwardRef(
3917
3942
  formField?.error && formField?.hasErrorMessage ? formField.errorMessageId : null,
3918
3943
  formField?.hasHelperText ? formField.helperTextId : null
3919
3944
  ].filter(Boolean).join(" ") || void 0;
3945
+ const nativeInputNode = /* @__PURE__ */ jsxRuntime.jsx(
3946
+ "input",
3947
+ {
3948
+ type: "radio",
3949
+ id,
3950
+ name,
3951
+ value: valueProp,
3952
+ disabled,
3953
+ readOnly,
3954
+ required,
3955
+ checked: isControlled ? effectiveChecked : void 0,
3956
+ defaultChecked: !isControlled ? defaultChecked : void 0,
3957
+ onChange: handleChange,
3958
+ ref: mergedInputRef,
3959
+ "aria-invalid": error ? true : void 0,
3960
+ "aria-describedby": ariaDescribedBy,
3961
+ className: "cl-radio__input",
3962
+ ...inputProps
3963
+ }
3964
+ );
3920
3965
  if (asChild) {
3966
+ const childElement = React56__namespace.isValidElement(children) ? children : null;
3967
+ if (!childElement) {
3968
+ return /* @__PURE__ */ jsxRuntime.jsx(
3969
+ StyledRadioRoot,
3970
+ {
3971
+ as: Slot,
3972
+ ref,
3973
+ className: radioClassName,
3974
+ style,
3975
+ sx,
3976
+ ...rest,
3977
+ children
3978
+ }
3979
+ );
3980
+ }
3981
+ const childLabel = childElement.props.children;
3921
3982
  return /* @__PURE__ */ jsxRuntime.jsx(
3922
3983
  StyledRadioRoot,
3923
3984
  {
@@ -3927,7 +3988,15 @@ var Radio = React56__namespace.forwardRef(
3927
3988
  style,
3928
3989
  sx,
3929
3990
  ...rest,
3930
- children
3991
+ children: React56__namespace.cloneElement(
3992
+ childElement,
3993
+ void 0,
3994
+ /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3995
+ nativeInputNode,
3996
+ controlBox,
3997
+ childLabel && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "cl-radio__label ChellaaRadio-Label", children: childLabel })
3998
+ ] })
3999
+ )
3931
4000
  }
3932
4001
  );
3933
4002
  }
@@ -3941,26 +4010,7 @@ var Radio = React56__namespace.forwardRef(
3941
4010
  sx,
3942
4011
  ...rest,
3943
4012
  children: [
3944
- /* @__PURE__ */ jsxRuntime.jsx(
3945
- "input",
3946
- {
3947
- type: "radio",
3948
- id,
3949
- name,
3950
- value: valueProp,
3951
- disabled,
3952
- readOnly,
3953
- required,
3954
- checked: isControlled ? effectiveChecked : void 0,
3955
- defaultChecked: !isControlled ? defaultChecked : void 0,
3956
- onChange: handleChange,
3957
- ref: mergedInputRef,
3958
- "aria-invalid": error ? true : void 0,
3959
- "aria-describedby": ariaDescribedBy,
3960
- className: "cl-radio__input",
3961
- ...inputProps
3962
- }
3963
- ),
4013
+ nativeInputNode,
3964
4014
  controlBox,
3965
4015
  children && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "cl-radio__label ChellaaRadio-Label", children })
3966
4016
  ]
@@ -4181,7 +4231,46 @@ var Switch = React56__namespace.forwardRef(
4181
4231
  formField?.error && formField?.hasErrorMessage ? formField.errorMessageId : null,
4182
4232
  formField?.hasHelperText ? formField.helperTextId : null
4183
4233
  ].filter(Boolean).join(" ") || void 0;
4234
+ const nativeInputNode = /* @__PURE__ */ jsxRuntime.jsx(
4235
+ "input",
4236
+ {
4237
+ type: "checkbox",
4238
+ role: "switch",
4239
+ id,
4240
+ name,
4241
+ value,
4242
+ disabled,
4243
+ readOnly,
4244
+ required,
4245
+ checked: isControlled ? effectiveChecked : void 0,
4246
+ defaultChecked: !isControlled ? defaultChecked : void 0,
4247
+ onChange: handleChange,
4248
+ onKeyDown: handleKeyDown,
4249
+ ref: mergedInputRef,
4250
+ "aria-checked": effectiveChecked,
4251
+ "aria-invalid": error ? true : void 0,
4252
+ "aria-describedby": ariaDescribedBy,
4253
+ className: "cl-switch__input",
4254
+ ...inputProps
4255
+ }
4256
+ );
4184
4257
  if (asChild) {
4258
+ const childElement = React56__namespace.isValidElement(children) ? children : null;
4259
+ if (!childElement) {
4260
+ return /* @__PURE__ */ jsxRuntime.jsx(
4261
+ StyledSwitchRoot,
4262
+ {
4263
+ as: Slot,
4264
+ ref,
4265
+ className: switchClassName,
4266
+ style,
4267
+ sx,
4268
+ ...rest,
4269
+ children
4270
+ }
4271
+ );
4272
+ }
4273
+ const childLabel = childElement.props.children;
4185
4274
  return /* @__PURE__ */ jsxRuntime.jsx(
4186
4275
  StyledSwitchRoot,
4187
4276
  {
@@ -4191,7 +4280,15 @@ var Switch = React56__namespace.forwardRef(
4191
4280
  style,
4192
4281
  sx,
4193
4282
  ...rest,
4194
- children
4283
+ children: React56__namespace.cloneElement(
4284
+ childElement,
4285
+ void 0,
4286
+ /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4287
+ nativeInputNode,
4288
+ trackControl,
4289
+ childLabel && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "cl-switch__label ChellaaSwitch-Label", children: childLabel })
4290
+ ] })
4291
+ )
4195
4292
  }
4196
4293
  );
4197
4294
  }
@@ -4205,29 +4302,7 @@ var Switch = React56__namespace.forwardRef(
4205
4302
  sx,
4206
4303
  ...rest,
4207
4304
  children: [
4208
- /* @__PURE__ */ jsxRuntime.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
- ),
4305
+ nativeInputNode,
4231
4306
  trackControl,
4232
4307
  children && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "cl-switch__label ChellaaSwitch-Label", children })
4233
4308
  ]
@@ -7124,7 +7199,7 @@ var SelectRoot = React56__namespace.forwardRef(
7124
7199
  if (children) {
7125
7200
  return children;
7126
7201
  }
7127
- if (options && options.length > 0) {
7202
+ if (options !== void 0) {
7128
7203
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
7129
7204
  /* @__PURE__ */ jsxRuntime.jsxs(SelectTrigger, { children: [
7130
7205
  /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: placeholder ?? void 0 }),
@@ -9062,6 +9137,13 @@ var ComboboxTag = React56__namespace.forwardRef(
9062
9137
  } else {
9063
9138
  ctx.removeItem(tagVal);
9064
9139
  }
9140
+ ctx.inputRef.current?.focus();
9141
+ };
9142
+ const handleKeyDown = (e) => {
9143
+ if (e.key === "Enter" || e.key === " ") {
9144
+ e.preventDefault();
9145
+ handleRemove(e);
9146
+ }
9065
9147
  };
9066
9148
  return /* @__PURE__ */ jsxRuntime.jsxs(
9067
9149
  "span",
@@ -9075,11 +9157,13 @@ var ComboboxTag = React56__namespace.forwardRef(
9075
9157
  "button",
9076
9158
  {
9077
9159
  type: "button",
9078
- tabIndex: -1,
9160
+ tabIndex: isDisabled ? -1 : 0,
9079
9161
  "aria-label": `Remove ${typeof children === "string" ? children : tagVal}`,
9080
9162
  className: "cl-combobox__tag-remove",
9081
9163
  disabled: isDisabled,
9082
9164
  onClick: handleRemove,
9165
+ onKeyDown: handleKeyDown,
9166
+ onMouseDown: (e) => e.preventDefault(),
9083
9167
  children: "\xD7"
9084
9168
  }
9085
9169
  )
@@ -9091,7 +9175,15 @@ var ComboboxTag = React56__namespace.forwardRef(
9091
9175
  var ComboboxClear = React56__namespace.forwardRef(
9092
9176
  function ComboboxClear2(props, ref) {
9093
9177
  const ctx = useComboboxContext();
9094
- const { className, onClick, children, disabled: disabledProp, ...rest } = props;
9178
+ const {
9179
+ className,
9180
+ onClick,
9181
+ onKeyDown,
9182
+ children,
9183
+ disabled: disabledProp,
9184
+ tabIndex = 0,
9185
+ ...rest
9186
+ } = props;
9095
9187
  const isDisabled = disabledProp ?? ctx.isDisabled;
9096
9188
  const hasValue = ctx.isMulti ? Array.isArray(ctx.value) && ctx.value.length > 0 : Boolean(ctx.value || ctx.searchValue);
9097
9189
  if (!hasValue) {
@@ -9101,18 +9193,28 @@ var ComboboxClear = React56__namespace.forwardRef(
9101
9193
  e.stopPropagation();
9102
9194
  if (isDisabled) return;
9103
9195
  ctx.clearSelection();
9196
+ ctx.inputRef.current?.focus();
9104
9197
  onClick?.(e);
9105
9198
  };
9199
+ const handleKeyDown = (e) => {
9200
+ if (e.key === "Enter" || e.key === " ") {
9201
+ e.preventDefault();
9202
+ handleClick(e);
9203
+ }
9204
+ onKeyDown?.(e);
9205
+ };
9106
9206
  return /* @__PURE__ */ jsxRuntime.jsx(
9107
9207
  "button",
9108
9208
  {
9109
9209
  ref,
9110
9210
  type: "button",
9111
- tabIndex: -1,
9211
+ tabIndex: isDisabled ? -1 : tabIndex,
9112
9212
  "aria-label": "Clear selection",
9113
9213
  className: classNames("cl-combobox__clear", className),
9114
9214
  disabled: isDisabled,
9115
9215
  onClick: handleClick,
9216
+ onKeyDown: handleKeyDown,
9217
+ onMouseDown: (e) => e.preventDefault(),
9116
9218
  ...rest,
9117
9219
  children: children ?? /* @__PURE__ */ jsxRuntime.jsxs(
9118
9220
  "svg",
@@ -9714,6 +9816,9 @@ var TableTh = React56__namespace.forwardRef(
9714
9816
  scope = "col",
9715
9817
  className,
9716
9818
  children,
9819
+ tabIndex,
9820
+ onClick,
9821
+ onKeyDown,
9717
9822
  ...props
9718
9823
  }, ref) => {
9719
9824
  const computedAriaSort = isSortable ? sortDirection === "asc" ? "ascending" : sortDirection === "desc" ? "descending" : "none" : props["aria-sort"];
@@ -9725,13 +9830,23 @@ var TableTh = React56__namespace.forwardRef(
9725
9830
  sortDirection && sortDirection !== "none" && `cl-table__th--sorted-${sortDirection}`,
9726
9831
  className
9727
9832
  ].filter(Boolean).join(" ");
9833
+ const handleKeyDown = (e) => {
9834
+ if (isSortable && (e.key === "Enter" || e.key === " ")) {
9835
+ e.preventDefault();
9836
+ onClick?.(e);
9837
+ }
9838
+ onKeyDown?.(e);
9839
+ };
9728
9840
  return /* @__PURE__ */ jsxRuntime.jsx(
9729
9841
  "th",
9730
9842
  {
9731
9843
  ref,
9732
9844
  scope,
9845
+ tabIndex: tabIndex ?? (isSortable ? 0 : void 0),
9733
9846
  "aria-sort": computedAriaSort,
9734
9847
  className: classNames2,
9848
+ onClick,
9849
+ onKeyDown: handleKeyDown,
9735
9850
  ...props,
9736
9851
  children
9737
9852
  }