@bolttech/atoms-segmented-control 0.16.0 → 0.17.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,17 @@ 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(["&:first-of-type{border-right:0;}&:last-of-type{border-left: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
+ }) => disabled && styled.css(["border:1px solid ", ";background-color:", ";cursor:default;*{cursor:default;}"], ({
1860
+ theme
1861
+ }) =>
1862
+ // @ts-ignore
1863
+ theme.components.segmentControl.border.color.disabled, ({
1864
+ theme
1865
+ }) =>
1866
+ // @ts-ignore
1867
+ theme.components.segmentControl.container.color.disabled));
1858
1868
  const SegmentedControlContainer = /*#__PURE__*/styled__default["default"].div.withConfig({
1859
1869
  displayName: "atoms-segmented-controlstyles__SegmentedControlContainer",
1860
1870
  componentId: "sc-1lpqq2u-1"
@@ -1880,7 +1890,7 @@ const SegmentedControlWrapper = /*#__PURE__*/styled__default["default"].div.with
1880
1890
  const OptionLabel = /*#__PURE__*/styled__default["default"].label.withConfig({
1881
1891
  displayName: "atoms-segmented-controlstyles__OptionLabel",
1882
1892
  componentId: "sc-1lpqq2u-3"
1883
- })(["color:", ";font-size:", ";font-weight:", ";letter-spacing:", ";line-height:", ";text-decoration:", ";text-indent:", ";text-transform:", ";"], ({
1893
+ })(["color:", ";font-size:", ";font-weight:", ";letter-spacing:", ";line-height:", ";text-decoration:", ";text-indent:", ";text-transform:", ";", ";"], ({
1884
1894
  theme,
1885
1895
  $pressed
1886
1896
  }) => $pressed ? theme.components.segmentControl.text.color.pressed : theme.components.segmentControl.text.color.default, ({
@@ -1897,7 +1907,13 @@ const OptionLabel = /*#__PURE__*/styled__default["default"].label.withConfig({
1897
1907
  theme
1898
1908
  }) => theme.components.segmentControl.fieldLabel.paragraphSpacing, ({
1899
1909
  theme
1900
- }) => theme.components.segmentControl.fieldLabel.textCase);
1910
+ }) => theme.components.segmentControl.fieldLabel.textCase, ({
1911
+ $disabled
1912
+ }) => $disabled && styled.css(["color:", ";"], ({
1913
+ theme
1914
+ }) =>
1915
+ // @ts-ignore
1916
+ theme.components.segmentControl.text.color.disabled));
1901
1917
  const LabelError = /*#__PURE__*/styled__default["default"].label.withConfig({
1902
1918
  displayName: "atoms-segmented-controlstyles__LabelError",
1903
1919
  componentId: "sc-1lpqq2u-4"
@@ -1939,12 +1955,18 @@ const SegmentedControl = /*#__PURE__*/react.forwardRef((_a, ref) => {
1939
1955
  });
1940
1956
  return options.map(option => jsxRuntime.jsx(Option, Object.assign({
1941
1957
  "data-testid": `segmentedcontrol-option-${option.value}`,
1942
- onClick: () => onClick(option.value),
1958
+ onClick: () => {
1959
+ if (!option.disabled) {
1960
+ onClick(option.value);
1961
+ }
1962
+ },
1943
1963
  "$pressed": option.value === value,
1944
1964
  type: "button",
1965
+ disabled: option.disabled,
1945
1966
  "$hasError": !!errorMessage
1946
1967
  }, uiUtils.applyDataAttributes(props, `option-${option.value}`), {
1947
1968
  children: jsxRuntime.jsx(OptionLabel, Object.assign({
1969
+ "$disabled": option.disabled,
1948
1970
  "$pressed": option.value === value
1949
1971
  }, uiUtils.applyDataAttributes(props, `option-label-${option.label}`), {
1950
1972
  children: option.label
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@bolttech/atoms-segmented-control",
3
- "version": "0.16.0",
3
+ "version": "0.17.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",
8
+ "@bolttech/default-theme": "0.3.0",
9
9
  "@bolttech/form-engine": "0.5.0",
10
- "@bolttech/frontend-foundations": "0.3.0",
11
- "@bolttech/ui-utils": "0.2.0",
10
+ "@bolttech/frontend-foundations": "0.3.1",
11
+ "@bolttech/ui-utils": "0.2.3",
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;