@bolttech/atoms-segmented-control 0.16.1 → 0.18.0

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/index.cjs CHANGED
@@ -1842,7 +1842,7 @@ const tokenToInteger = token => Number(token.replace('px', ''));
1842
1842
  const Option = /*#__PURE__*/styled__default["default"].button.withConfig({
1843
1843
  displayName: "atoms-segmented-controlstyles__Option",
1844
1844
  componentId: "sc-1lpqq2u-0"
1845
- })(["background-color:", ";border:1px solid ", ";padding:", ";cursor:pointer;", " *{cursor:pointer;}"], ({
1845
+ })(["background-color:", ";border:1px solid ", ";padding:", ";cursor:pointer;", " *{cursor:pointer;}", ";"], ({
1846
1846
  theme,
1847
1847
  $pressed,
1848
1848
  $hasError
@@ -1854,7 +1854,14 @@ const Option = /*#__PURE__*/styled__default["default"].button.withConfig({
1854
1854
  theme
1855
1855
  }) => `${theme.components.segmentControl.paddingVertical} ${theme.components.segmentControl.paddingVertical}`, ({
1856
1856
  theme
1857
- }) => tokenToInteger(theme.components.segmentControl.gap) === 0 && styled.css(["&:last-of-type{border-left:0;}&:first-of-type:nth-last-child(3){border-right:0;}&:not(:first-of-type) + &:not(:last-of-type){border-right:0;border-left:0;}"]));
1857
+ }) => tokenToInteger(theme.components.segmentControl.gap) === 0 && styled.css(["&:last-of-type{border-left:0;}&:first-of-type:nth-last-child(3){border-right:0;}&:not(:first-of-type) + &:not(:last-of-type){border-right:0;border-left:0;}"]), ({
1858
+ disabled,
1859
+ $pressed
1860
+ }) => disabled && !$pressed && styled.css(["border:1px solid ", ";background-color:", ";cursor:default;*{cursor:default;}"], ({
1861
+ theme
1862
+ }) => theme.components.segmentControl.border.color.disabled, ({
1863
+ theme
1864
+ }) => theme.components.segmentControl.container.color.disabled));
1858
1865
  const SegmentedControlContainer = /*#__PURE__*/styled__default["default"].div.withConfig({
1859
1866
  displayName: "atoms-segmented-controlstyles__SegmentedControlContainer",
1860
1867
  componentId: "sc-1lpqq2u-1"
@@ -1880,7 +1887,7 @@ const SegmentedControlWrapper = /*#__PURE__*/styled__default["default"].div.with
1880
1887
  const OptionLabel = /*#__PURE__*/styled__default["default"].label.withConfig({
1881
1888
  displayName: "atoms-segmented-controlstyles__OptionLabel",
1882
1889
  componentId: "sc-1lpqq2u-3"
1883
- })(["color:", ";font-size:", ";font-weight:", ";letter-spacing:", ";line-height:", ";text-decoration:", ";text-indent:", ";text-transform:", ";"], ({
1890
+ })(["color:", ";font-size:", ";font-weight:", ";letter-spacing:", ";line-height:", ";text-decoration:", ";text-indent:", ";text-transform:", ";", ";"], ({
1884
1891
  theme,
1885
1892
  $pressed
1886
1893
  }) => $pressed ? theme.components.segmentControl.text.color.pressed : theme.components.segmentControl.text.color.default, ({
@@ -1897,7 +1904,11 @@ const OptionLabel = /*#__PURE__*/styled__default["default"].label.withConfig({
1897
1904
  theme
1898
1905
  }) => theme.components.segmentControl.fieldLabel.paragraphSpacing, ({
1899
1906
  theme
1900
- }) => theme.components.segmentControl.fieldLabel.textCase);
1907
+ }) => theme.components.segmentControl.fieldLabel.textCase, ({
1908
+ $disabled
1909
+ }) => $disabled && styled.css(["color:", ";"], ({
1910
+ theme
1911
+ }) => theme.components.segmentControl.text.color.disabled));
1901
1912
  const LabelError = /*#__PURE__*/styled__default["default"].label.withConfig({
1902
1913
  displayName: "atoms-segmented-controlstyles__LabelError",
1903
1914
  componentId: "sc-1lpqq2u-4"
@@ -1939,12 +1950,18 @@ const SegmentedControl = /*#__PURE__*/react.forwardRef((_a, ref) => {
1939
1950
  });
1940
1951
  return options.map(option => jsxRuntime.jsx(Option, Object.assign({
1941
1952
  "data-testid": `segmentedcontrol-option-${option.value}`,
1942
- onClick: () => onClick(option.value),
1953
+ onClick: () => {
1954
+ if (!option.disabled) {
1955
+ onClick(option.value);
1956
+ }
1957
+ },
1943
1958
  "$pressed": option.value === value,
1944
1959
  type: "button",
1960
+ disabled: option.disabled,
1945
1961
  "$hasError": !!errorMessage
1946
1962
  }, uiUtils.applyDataAttributes(props, `option-${option.value}`), {
1947
1963
  children: jsxRuntime.jsx(OptionLabel, Object.assign({
1964
+ "$disabled": option.disabled,
1948
1965
  "$pressed": option.value === value
1949
1966
  }, uiUtils.applyDataAttributes(props, `option-label-${option.label}`), {
1950
1967
  children: option.label
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@bolttech/atoms-segmented-control",
3
- "version": "0.16.1",
3
+ "version": "0.18.0",
4
4
  "main": "./index.cjs",
5
5
  "type": "commonjs",
6
6
  "types": "./src/index.d.ts",
7
7
  "dependencies": {
8
- "@bolttech/default-theme": "0.1.0",
9
- "@bolttech/form-engine": "0.5.0",
8
+ "@bolttech/default-theme": "0.3.0",
9
+ "@bolttech/form-engine": "0.10.3",
10
10
  "@bolttech/frontend-foundations": "0.3.1",
11
- "@bolttech/ui-utils": "0.2.1",
11
+ "@bolttech/ui-utils": "0.2.4",
12
12
  "react": "18.2.0",
13
13
  "styled-components": "6.1.1"
14
14
  },
@@ -6,6 +6,7 @@ export declare const SegmentedControl: import("react").ForwardRefExoticComponent
6
6
  options: {
7
7
  label: string;
8
8
  value: string | number;
9
+ disabled?: boolean | undefined;
9
10
  }[];
10
11
  errorMessage?: string | undefined;
11
12
  fullWidth?: boolean | undefined;
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  /// <reference types="react" />
3
+ import 'styled-components';
3
4
  export declare const Option: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {
4
5
  $pressed: boolean;
5
6
  $hasError: boolean;
@@ -281,6 +282,7 @@ export declare const SegmentedControlWrapper: import("styled-components").IStyle
281
282
  }>;
282
283
  export declare const OptionLabel: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, {
283
284
  $pressed: boolean;
285
+ $disabled: boolean | undefined;
284
286
  }>>;
285
287
  export declare const LabelError: import("styled-components").IStyledComponent<"web", {
286
288
  ref?: import("react").LegacyRef<HTMLLabelElement> | undefined;
@@ -7,6 +7,7 @@ export type SegmentedControlProps = DefaultProps & {
7
7
  options: {
8
8
  label: string;
9
9
  value: string | number;
10
+ disabled?: boolean;
10
11
  }[];
11
12
  errorMessage?: string;
12
13
  fullWidth?: boolean;