@bolttech/atoms-segmented-control 0.11.0 → 0.12.1

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/README.md CHANGED
@@ -36,8 +36,8 @@ To use the component, import it and include it in your JSX:
36
36
 
37
37
  ```jsx
38
38
  import React from 'react';
39
- import {SegmentedControl} from '@bolttech/atoms-segmented-control';
40
- import {bolttechTheme, BolttechThemeProvider} from "@edirect/frontend-foundations";
39
+ import { SegmentedControl } from '@bolttech/atoms-segmented-control';
40
+ import { bolttechTheme, BolttechThemeProvider } from '@edirect/frontend-foundations';
41
41
 
42
42
  function App() {
43
43
  return (
@@ -45,9 +45,10 @@ function App() {
45
45
  <SegmentedControl
46
46
  value="option1"
47
47
  options={[
48
- {label: 'Option 1', value: 'option1'},
49
- {label: 'Option 2', value: 'option2'},
48
+ { label: 'Option 1', value: 'option1' },
49
+ { label: 'Option 2', value: 'option2' },
50
50
  ]}
51
+ fullWidth={false}
51
52
  errorMessage="An error occurred"
52
53
  dataTestId="segmented-control-component"
53
54
  onChange={(selectedValue) => console.log(`Selected: ${selectedValue}`)}
@@ -63,16 +64,17 @@ export default App;
63
64
 
64
65
  The **SegmentedControl** component accepts the following props:
65
66
 
66
- | Prop | Type | Description |
67
- |--------------|---------------|---------------------------------------------------|
68
- | `id` | string | The HTML `id` attribute for the segmented control.|
69
- | `dataTestId` | string | The data-testid attribute for testing purposes. |
70
- | `value` | string | The currently selected option value. |
71
- | `options` | Option[] | An array of option objects to be displayed. |
72
- | `errorMessage` | string | An optional error message to display. |
73
- | `onChange` | function | A callback function triggered on option change. |
74
- | `onBlur` | function | A callback function triggered on blur event. |
75
- | `onFocus` | function | A callback function triggered on focus event. |
67
+ | Prop | Type | Description |
68
+ | -------------- | -------- | -------------------------------------------------- |
69
+ | `id` | string | The HTML `id` attribute for the segmented control. |
70
+ | `dataTestId` | string | The data-testid attribute for testing purposes. |
71
+ | `value` | string | The currently selected option value. |
72
+ | `options` | Option[] | An array of option objects to be displayed. |
73
+ | `fullWidth` | boolean | Boolean representing if should take full width. |
74
+ | `errorMessage` | string | An optional error message to display. |
75
+ | `onChange` | function | A callback function triggered on option change. |
76
+ | `onBlur` | function | A callback function triggered on blur event. |
77
+ | `onFocus` | function | A callback function triggered on focus event. |
76
78
 
77
79
  ## Example
78
80
 
@@ -85,6 +87,7 @@ Here's an example of using the **SegmentedControl** component:
85
87
  { label: 'Option 1', value: 'option1' },
86
88
  { label: 'Option 2', value: 'option2' },
87
89
  ]}
90
+ fullWidth={false}
88
91
  errorMessage="An error occurred"
89
92
  dataTestId="segmented-control-component"
90
93
  onChange={(selectedValue) => console.log(`Selected: ${selectedValue}`)}
package/index.cjs CHANGED
@@ -1128,9 +1128,11 @@ function __rest(s, e) {
1128
1128
  const SegmentedControlContainer = /*#__PURE__*/styled__default["default"].div.withConfig({
1129
1129
  displayName: "atoms-segmented-controlstyles__SegmentedControlContainer",
1130
1130
  componentId: "sc-1lpqq2u-0"
1131
- })(["display:flex;flex-direction:column;gap:", ";"], ({
1131
+ })(["display:flex;flex-direction:column;gap:", ";", ";"], ({
1132
1132
  theme
1133
- }) => theme.tokens.padding.XS);
1133
+ }) => theme.tokens.padding.XS, ({
1134
+ fullWidth
1135
+ }) => fullWidth && styled.css(["", "{flex:1;}"], Option));
1134
1136
  const SegmentedControlWrapper = /*#__PURE__*/styled__default["default"].div.withConfig({
1135
1137
  displayName: "atoms-segmented-controlstyles__SegmentedControlWrapper",
1136
1138
  componentId: "sc-1lpqq2u-1"
@@ -1148,7 +1150,7 @@ const SegmentedControlWrapper = /*#__PURE__*/styled__default["default"].div.with
1148
1150
  const Option = /*#__PURE__*/styled__default["default"].button.withConfig({
1149
1151
  displayName: "atoms-segmented-controlstyles__Option",
1150
1152
  componentId: "sc-1lpqq2u-2"
1151
- })(["background-color:", ";border:1px solid ", ";padding:", ";: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;}"], ({
1153
+ })(["background-color:", ";border:1px solid ", ";padding:", ";cursor:pointer;: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;}*{cursor:pointer;}"], ({
1152
1154
  theme,
1153
1155
  pressed,
1154
1156
  hasError
@@ -1206,11 +1208,12 @@ const SegmentedControl = /*#__PURE__*/react.forwardRef((_a, ref) => {
1206
1208
  value,
1207
1209
  options,
1208
1210
  errorMessage,
1211
+ fullWidth = false,
1209
1212
  onChange,
1210
1213
  onBlur,
1211
1214
  onFocus
1212
1215
  } = _a,
1213
- props = __rest(_a, ["id", "dataTestId", "value", "options", "errorMessage", "onChange", "onBlur", "onFocus"]);
1216
+ props = __rest(_a, ["id", "dataTestId", "value", "options", "errorMessage", "fullWidth", "onChange", "onBlur", "onFocus"]);
1214
1217
  const onClick = valueSelected => {
1215
1218
  onChange && onChange(valueSelected);
1216
1219
  };
@@ -1235,6 +1238,7 @@ const SegmentedControl = /*#__PURE__*/react.forwardRef((_a, ref) => {
1235
1238
  return jsxRuntime.jsxs(SegmentedControlContainer, Object.assign({
1236
1239
  id: id,
1237
1240
  "data-testid": dataTestId,
1241
+ fullWidth: fullWidth,
1238
1242
  ref: ref
1239
1243
  }, uiUtils.applyDataAttributes(props), {
1240
1244
  children: [jsxRuntime.jsx(SegmentedControlWrapper, {
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@bolttech/atoms-segmented-control",
3
- "version": "0.11.0",
3
+ "version": "0.12.1",
4
4
  "main": "./index.cjs",
5
5
  "type": "commonjs",
6
6
  "types": "./src/index.d.ts",
7
7
  "dependencies": {
8
8
  "@bolttech/ui-utils": "0.1.1",
9
- "@edirect/frontend-foundations": "0.0.69",
9
+ "@edirect/frontend-foundations": "0.0.70",
10
10
  "react": "18.2.0",
11
11
  "styled-components": "5.3.6"
12
12
  },
@@ -8,6 +8,7 @@ export declare const SegmentedControl: import("react").ForwardRefExoticComponent
8
8
  value: string | number;
9
9
  }[];
10
10
  errorMessage?: string | undefined;
11
+ fullWidth?: boolean | undefined;
11
12
  onChange?: ((value: string | number) => void) | undefined;
12
13
  onBlur?: ((value: unknown) => void) | ((evt: import("react").FocusEvent<HTMLElement, Element>) => void) | undefined;
13
14
  onFocus?: ((value: unknown) => void) | ((evt: import("react").FocusEvent<HTMLElement, Element>) => void) | undefined;
@@ -1,4 +1,6 @@
1
- export declare const SegmentedControlContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
1
+ export declare const SegmentedControlContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
2
+ fullWidth: boolean;
3
+ }, never>;
2
4
  export declare const SegmentedControlWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
3
5
  export declare const Option: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, {
4
6
  pressed: boolean;
@@ -9,6 +9,7 @@ export type SegmentedControlProps = DefaultProps & {
9
9
  value: string | number;
10
10
  }[];
11
11
  errorMessage?: string;
12
+ fullWidth?: boolean;
12
13
  onChange?: (value: string | number) => void;
13
14
  onBlur?: ((value: unknown) => void) | ((evt: React.FocusEvent<HTMLElement, Element>) => void);
14
15
  onFocus?: ((value: unknown) => void) | ((evt: React.FocusEvent<HTMLElement, Element>) => void);