@drivenets/design-system 0.0.4 → 0.0.5

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.
Files changed (60) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +51 -0
  3. package/dist/components/ds-button/ds-button.d.cts +2 -2
  4. package/dist/components/ds-button/ds-button.d.cts.map +1 -1
  5. package/dist/components/ds-button/ds-button.d.ts +2 -2
  6. package/dist/components/ds-confirmation/ds-confirmation.d.cts +8 -8
  7. package/dist/components/ds-confirmation/ds-confirmation.d.cts.map +1 -1
  8. package/dist/components/ds-confirmation/ds-confirmation.d.ts +8 -8
  9. package/dist/components/ds-drawer/ds-drawer.d.cts +9 -9
  10. package/dist/components/ds-drawer/ds-drawer.d.ts +9 -9
  11. package/dist/components/ds-expandable-text-input/ds-expandable-text-input.d.cts +2 -2
  12. package/dist/components/ds-expandable-text-input/ds-expandable-text-input.d.ts +2 -2
  13. package/dist/components/ds-form-control/ds-form-control.d.cts +7 -7
  14. package/dist/components/ds-modal/ds-modal.d.cts +8 -8
  15. package/dist/components/ds-modal/ds-modal.d.cts.map +1 -1
  16. package/dist/components/ds-modal/ds-modal.d.ts +8 -8
  17. package/dist/components/ds-panel/ds-panel.d.cts +2 -2
  18. package/dist/components/ds-panel/ds-panel.d.ts +2 -2
  19. package/dist/components/ds-segment-group/ds-segment-group.cjs +215 -0
  20. package/dist/components/ds-segment-group/ds-segment-group.d.cts +26 -0
  21. package/dist/components/ds-segment-group/ds-segment-group.d.cts.map +1 -0
  22. package/dist/components/ds-segment-group/ds-segment-group.d.ts +26 -0
  23. package/dist/components/ds-segment-group/ds-segment-group.d.ts.map +1 -0
  24. package/dist/components/ds-segment-group/ds-segment-group.js +214 -0
  25. package/dist/components/ds-segment-group/ds-segment-group.js.map +1 -0
  26. package/dist/components/ds-segment-group/ds-segment-group.module.cjs +12 -0
  27. package/dist/components/ds-segment-group/ds-segment-group.module.js +12 -0
  28. package/dist/components/ds-segment-group/ds-segment-group.module.js.map +1 -0
  29. package/dist/components/ds-segment-group/ds-segment-group.types.cjs +2 -0
  30. package/dist/components/ds-segment-group/ds-segment-group.types.d.cts +52 -0
  31. package/dist/components/ds-segment-group/ds-segment-group.types.d.cts.map +1 -0
  32. package/dist/components/ds-segment-group/ds-segment-group.types.d.ts +52 -0
  33. package/dist/components/ds-segment-group/ds-segment-group.types.d.ts.map +1 -0
  34. package/dist/components/ds-segment-group/ds-segment-group.types.js +2 -0
  35. package/dist/components/ds-segment-group/index.cjs +2 -0
  36. package/dist/components/ds-segment-group/index.d.ts +2 -0
  37. package/dist/components/ds-segment-group/index.js +2 -0
  38. package/dist/components/ds-select/ds-select.d.ts +2 -2
  39. package/dist/components/ds-smart-tabs/ds-smart-tabs.d.ts +2 -2
  40. package/dist/components/ds-stepper/components/ds-step-content.d.cts +2 -2
  41. package/dist/components/ds-stepper/components/ds-step-content.d.ts +2 -2
  42. package/dist/components/ds-stepper/components/ds-step-next-button.d.cts +2 -2
  43. package/dist/components/ds-stepper/components/ds-step-next-button.d.ts +2 -2
  44. package/dist/components/ds-stepper/components/ds-step.d.cts +2 -2
  45. package/dist/components/ds-stepper/components/ds-step.d.ts +2 -2
  46. package/dist/components/ds-stepper/ds-stepper.d.cts +2 -2
  47. package/dist/components/ds-stepper/ds-stepper.d.ts +2 -2
  48. package/dist/components/ds-table/ds-table.d.cts +2 -2
  49. package/dist/components/ds-vertical-tabs/ds-vertical-tabs.d.ts +5 -5
  50. package/dist/index.cjs +3 -0
  51. package/dist/index.d.cts +3 -1
  52. package/dist/index.d.ts +4 -1
  53. package/dist/index.js +3 -1
  54. package/dist/index.min.css +1 -1
  55. package/package.json +2 -2
  56. package/src/components/ds-segment-group/ds-segment-group.module.scss +99 -0
  57. package/src/components/ds-segment-group/ds-segment-group.tsx +76 -0
  58. package/src/components/ds-segment-group/ds-segment-group.types.tsx +64 -0
  59. package/src/components/ds-segment-group/index.tsx +2 -0
  60. package/src/index.ts +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drivenets/design-system",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.cts",
@@ -97,7 +97,7 @@
97
97
  "vite": "^7.3.0",
98
98
  "vitest": "^4.0.16",
99
99
  "zod": "^3.24.2",
100
- "@drivenets/vite-plugin-design-system": "0.0.3"
100
+ "@drivenets/vite-plugin-design-system": "0.0.4"
101
101
  },
102
102
  "scripts": {
103
103
  "lint": "eslint --max-warnings=0 .",
@@ -0,0 +1,99 @@
1
+ .segmentGroupRoot {
2
+ display: inline-flex;
3
+ align-items: center;
4
+ position: relative;
5
+ background: var(--color-background-secondary);
6
+ border: 1px solid var(--color-border-contrast);
7
+ border-radius: 4px;
8
+ gap: var(--spacing-2xs);
9
+ height: 36px;
10
+ padding: var(--spacing-3xs);
11
+
12
+ &.small {
13
+ height: 28px;
14
+ padding: var(--spacing-4xs);
15
+
16
+ .segmentItem {
17
+ padding: var(--spacing-4xs) var(--spacing-xs);
18
+ }
19
+ }
20
+ }
21
+
22
+ .segmentItem {
23
+ position: relative;
24
+ display: flex;
25
+ align-items: center;
26
+ justify-content: center;
27
+ padding: var(--spacing-3xs) var(--spacing-sm);
28
+ gap: var(--spacing-2xs);
29
+ flex: 1;
30
+ z-index: 1;
31
+ cursor: pointer;
32
+ border-radius: 4px;
33
+
34
+ &[data-state='checked'] {
35
+ .segmentItemText {
36
+ color: var(--color-font-main);
37
+ font-weight: var(--font-weight-medium);
38
+ }
39
+ }
40
+
41
+ &[data-state='unchecked'] {
42
+ background: transparent;
43
+
44
+ .segmentItemText {
45
+ color: var(--color-background-action);
46
+ }
47
+
48
+ &:hover:not([data-disabled]) {
49
+ background: var(--color-background-action-secondary);
50
+ }
51
+
52
+ &:active:not([data-disabled]) {
53
+ background: var(--color-background);
54
+ border-color: var(--color-border-contrast);
55
+ }
56
+ }
57
+
58
+ &[data-disabled] {
59
+ cursor: not-allowed;
60
+ background: var(--color-background-secondary);
61
+
62
+ .segmentItemText {
63
+ color: var(--color-font-disabled);
64
+ }
65
+ }
66
+
67
+ &:focus-visible {
68
+ outline: 2px solid var(--color-border-action-secondary);
69
+ outline-offset: 2px;
70
+ }
71
+ }
72
+
73
+ [data-scope='segment-group'][data-part='item-control'] {
74
+ position: absolute;
75
+ inset: 0;
76
+ pointer-events: none;
77
+ }
78
+
79
+ .segmentItemText {
80
+ display: flex;
81
+ align-items: center;
82
+ justify-content: center;
83
+ white-space: nowrap;
84
+ transition: color 150ms ease-in-out;
85
+ }
86
+
87
+ .segmentIndicator {
88
+ position: absolute;
89
+ background: var(--color-background);
90
+ border: 1px solid var(--color-border-contrast);
91
+ border-radius: 4px;
92
+ box-shadow: 0 1.25px 4px 0 rgba(0, 0, 0, 0.25);
93
+ z-index: 0;
94
+ pointer-events: none;
95
+ width: var(--width);
96
+ height: var(--height);
97
+ left: var(--left);
98
+ top: var(--top);
99
+ }
@@ -0,0 +1,76 @@
1
+ import type React from 'react';
2
+ import { SegmentGroup } from '@ark-ui/react/segment-group';
3
+ import classNames from 'classnames';
4
+ import styles from './ds-segment-group.module.scss';
5
+ import DsTypography from '../ds-typography/ds-typography';
6
+ import {
7
+ type DsSegmentGroupItemProps,
8
+ type DsSegmentGroupItemTextProps,
9
+ type DsSegmentGroupRootProps,
10
+ } from './ds-segment-group.types';
11
+
12
+ /**
13
+ * Root component - provides segment group context
14
+ */
15
+ const Root: React.FC<DsSegmentGroupRootProps> = ({
16
+ className,
17
+ children,
18
+ onValueChange,
19
+ size = 'default',
20
+ ...props
21
+ }) => (
22
+ <SegmentGroup.Root
23
+ className={classNames(styles.segmentGroupRoot, size === 'small' && styles.small, className)}
24
+ onValueChange={(details) => onValueChange?.(details.value)}
25
+ {...props}
26
+ >
27
+ <SegmentGroup.Indicator className={styles.segmentIndicator} />
28
+ {children}
29
+ </SegmentGroup.Root>
30
+ );
31
+
32
+ /**
33
+ * Item component - renders a single segment button
34
+ */
35
+ const Item: React.FC<DsSegmentGroupItemProps> = ({ value, label, className, style, children, ...props }) => {
36
+ return (
37
+ <SegmentGroup.Item
38
+ value={value}
39
+ className={classNames(styles.segmentItem, className)}
40
+ style={style}
41
+ {...props}
42
+ >
43
+ {label ? <ItemText>{label}</ItemText> : children}
44
+ <SegmentGroup.ItemControl />
45
+ <SegmentGroup.ItemHiddenInput />
46
+ </SegmentGroup.Item>
47
+ );
48
+ };
49
+
50
+ /**
51
+ * ItemText component - renders text content within an item
52
+ */
53
+ const ItemText: React.FC<DsSegmentGroupItemTextProps> = ({ className, children, ...props }) => (
54
+ <SegmentGroup.ItemText className={classNames(styles.segmentItemText, className)} {...props} asChild>
55
+ <DsTypography variant="body-sm-reg">{children}</DsTypography>
56
+ </SegmentGroup.ItemText>
57
+ );
58
+
59
+ /**
60
+ * Design system SegmentGroup component
61
+ *
62
+ * @example
63
+ * <DsSegmentGroup.Root value={value} onValueChange={setValue} size="default">
64
+ * <DsSegmentGroup.Indicator />
65
+ * <DsSegmentGroup.Item value="option1" label="Option 1" />
66
+ * <DsSegmentGroup.Item value="option2">
67
+ * <DsIcon icon="settings" />
68
+ * <DsSegmentGroup.ItemText>Option 2</DsSegmentGroup.ItemText>
69
+ * </DsSegmentGroup.Item>
70
+ * </DsSegmentGroup.Root>
71
+ */
72
+ export const DsSegmentGroup = {
73
+ Root,
74
+ Item,
75
+ ItemText,
76
+ };
@@ -0,0 +1,64 @@
1
+ import { type ReactNode } from 'react';
2
+ import {
3
+ type SegmentGroupItemProps,
4
+ type SegmentGroupItemTextProps,
5
+ type SegmentGroupRootProps,
6
+ } from '@ark-ui/react/segment-group';
7
+
8
+ /**
9
+ * Size variants for the segment group
10
+ */
11
+ export type DsSegmentGroupSize = 'small' | 'default';
12
+
13
+ /**
14
+ * Props for the DsSegmentGroup Root component
15
+ */
16
+ export interface DsSegmentGroupRootProps extends Pick<
17
+ SegmentGroupRootProps,
18
+ 'value' | 'defaultValue' | 'disabled' | 'name' | 'className' | 'style' | 'children'
19
+ > {
20
+ /**
21
+ * Size variant of the segment group
22
+ * @default 'default'
23
+ */
24
+ size?: DsSegmentGroupSize;
25
+ /**
26
+ * Event handler called when the selected value changes
27
+ */
28
+ onValueChange?: (value: string | null) => void;
29
+ }
30
+
31
+ /**
32
+ * Props for the DsSegmentGroup Item component
33
+ */
34
+ export type DsSegmentGroupItemProps = Pick<
35
+ SegmentGroupItemProps,
36
+ 'id' | 'value' | 'disabled' | 'className' | 'style'
37
+ > &
38
+ (
39
+ | {
40
+ /**
41
+ * The segment group item content
42
+ */
43
+ children: ReactNode;
44
+ /**
45
+ * Optional label text for the segment item
46
+ */
47
+ label?: never;
48
+ }
49
+ | {
50
+ /**
51
+ * The segment group item content
52
+ */
53
+ children?: never;
54
+ /**
55
+ * Optional label text for the segment item
56
+ */
57
+ label: string;
58
+ }
59
+ );
60
+
61
+ /**
62
+ * Props for the DsSegmentGroup ItemText component
63
+ */
64
+ export type DsSegmentGroupItemTextProps = Pick<SegmentGroupItemTextProps, 'className' | 'style' | 'children'>;
@@ -0,0 +1,2 @@
1
+ export { DsSegmentGroup } from './ds-segment-group';
2
+ export * from './ds-segment-group.types';
package/src/index.ts CHANGED
@@ -19,6 +19,7 @@ export * from './components/ds-panel';
19
19
  export * from './components/ds-password-input';
20
20
  export * from './components/ds-popover';
21
21
  export * from './components/ds-radio-group';
22
+ export * from './components/ds-segment-group';
22
23
  export * from './components/ds-select';
23
24
  export * from './components/ds-smart-tabs';
24
25
  export * from './components/ds-spinner';