@fragments-sdk/ui 0.4.0 → 0.6.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.
Files changed (97) hide show
  1. package/README.md +98 -2
  2. package/fragments.json +1 -1
  3. package/package.json +4 -3
  4. package/src/components/Accordion/Accordion.fragment.tsx +1 -1
  5. package/src/components/Alert/Alert.fragment.tsx +1 -1
  6. package/src/components/AppShell/AppShell.fragment.tsx +4 -4
  7. package/src/components/Avatar/Avatar.fragment.tsx +2 -2
  8. package/src/components/Badge/Badge.fragment.tsx +2 -2
  9. package/src/components/Badge/Badge.module.scss +1 -1
  10. package/src/components/Box/Box.fragment.tsx +1 -1
  11. package/src/components/Button/Button.fragment.tsx +2 -2
  12. package/src/components/ButtonGroup/ButtonGroup.fragment.tsx +153 -0
  13. package/src/components/Card/Card.fragment.tsx +1 -1
  14. package/src/components/Chart/Chart.fragment.tsx +213 -0
  15. package/src/components/Chart/Chart.module.scss +123 -0
  16. package/src/components/Chart/index.tsx +267 -0
  17. package/src/components/Checkbox/Checkbox.fragment.tsx +1 -1
  18. package/src/components/CodeBlock/CodeBlock.fragment.tsx +265 -6
  19. package/src/components/CodeBlock/CodeBlock.module.scss +141 -3
  20. package/src/components/CodeBlock/index.tsx +250 -36
  21. package/src/components/Collapsible/Collapsible.fragment.tsx +199 -0
  22. package/src/components/Collapsible/Collapsible.module.scss +117 -0
  23. package/src/components/Collapsible/index.tsx +219 -0
  24. package/src/components/ColorPicker/ColorPicker.fragment.tsx +196 -0
  25. package/src/components/ColorPicker/ColorPicker.module.scss +33 -23
  26. package/src/components/ColorPicker/index.tsx +34 -12
  27. package/src/components/Combobox/Combobox.fragment.tsx +220 -0
  28. package/src/components/Combobox/Combobox.module.scss +268 -0
  29. package/src/components/Combobox/index.tsx +398 -0
  30. package/src/components/ConversationList/ConversationList.fragment.tsx +202 -0
  31. package/src/components/ConversationList/ConversationList.module.scss +160 -0
  32. package/src/components/ConversationList/index.tsx +254 -0
  33. package/src/components/Dialog/Dialog.fragment.tsx +3 -3
  34. package/src/components/EmptyState/EmptyState.fragment.tsx +2 -2
  35. package/src/components/Field/Field.fragment.tsx +3 -3
  36. package/src/components/Fieldset/Fieldset.fragment.tsx +7 -7
  37. package/src/components/Form/Form.fragment.tsx +11 -11
  38. package/src/components/Grid/Grid.fragment.tsx +1 -1
  39. package/src/components/Header/Header.fragment.tsx +4 -4
  40. package/src/components/Header/Header.module.scss +9 -10
  41. package/src/components/Icon/Icon.fragment.tsx +2 -2
  42. package/src/components/Image/Image.fragment.tsx +2 -2
  43. package/src/components/Input/Input.fragment.tsx +1 -1
  44. package/src/components/Input/Input.module.scss +2 -2
  45. package/src/components/Link/Link.fragment.tsx +1 -1
  46. package/src/components/List/List.fragment.tsx +2 -2
  47. package/src/components/Listbox/Listbox.fragment.tsx +1 -1
  48. package/src/components/Loading/Loading.fragment.tsx +153 -0
  49. package/src/components/Loading/Loading.module.scss +256 -0
  50. package/src/components/Loading/index.tsx +236 -0
  51. package/src/components/Menu/Menu.fragment.tsx +3 -3
  52. package/src/components/Message/Message.fragment.tsx +200 -0
  53. package/src/components/Message/Message.module.scss +224 -0
  54. package/src/components/Message/index.tsx +278 -0
  55. package/src/components/Popover/Popover.fragment.tsx +4 -4
  56. package/src/components/Progress/Progress.fragment.tsx +1 -1
  57. package/src/components/Prompt/Prompt.fragment.tsx +2 -2
  58. package/src/components/RadioGroup/RadioGroup.fragment.tsx +1 -1
  59. package/src/components/RadioGroup/RadioGroup.module.scss +7 -4
  60. package/src/components/Select/Select.fragment.tsx +1 -1
  61. package/src/components/Select/Select.module.scss +8 -0
  62. package/src/components/Select/index.tsx +85 -5
  63. package/src/components/Separator/Separator.fragment.tsx +1 -1
  64. package/src/components/Sidebar/Sidebar.fragment.tsx +2 -2
  65. package/src/components/Sidebar/Sidebar.module.scss +19 -0
  66. package/src/components/Sidebar/index.tsx +52 -11
  67. package/src/components/Skeleton/Skeleton.fragment.tsx +1 -1
  68. package/src/components/Slider/Slider.fragment.tsx +201 -0
  69. package/src/components/Stack/Stack.fragment.tsx +194 -0
  70. package/src/components/Table/Table.fragment.tsx +3 -3
  71. package/src/components/Tabs/Tabs.fragment.tsx +1 -1
  72. package/src/components/Tabs/Tabs.module.scss +2 -2
  73. package/src/components/Text/Text.fragment.tsx +188 -0
  74. package/src/components/Textarea/Textarea.fragment.tsx +1 -1
  75. package/src/components/Theme/Theme.fragment.tsx +2 -2
  76. package/src/components/Theme/ThemeToggle.module.scss +13 -13
  77. package/src/components/ThinkingIndicator/ThinkingIndicator.fragment.tsx +182 -0
  78. package/src/components/ThinkingIndicator/ThinkingIndicator.module.scss +226 -0
  79. package/src/components/ThinkingIndicator/index.tsx +258 -0
  80. package/src/components/Toast/Toast.fragment.tsx +1 -1
  81. package/src/components/Toggle/Toggle.fragment.tsx +1 -1
  82. package/src/components/ToggleGroup/ToggleGroup.fragment.tsx +207 -0
  83. package/src/components/Tooltip/Tooltip.fragment.tsx +3 -3
  84. package/src/components/VisuallyHidden/VisuallyHidden.fragment.tsx +2 -2
  85. package/src/index.ts +99 -3
  86. package/src/recipes/AIChat.recipe.ts +266 -0
  87. package/src/tokens/_computed.scss +212 -0
  88. package/src/tokens/_density.scss +171 -0
  89. package/src/tokens/_derive.scss +287 -0
  90. package/src/tokens/_index.scss +39 -1
  91. package/src/tokens/_mixins.scss +41 -0
  92. package/src/tokens/_palettes.scss +185 -0
  93. package/src/tokens/_radius.scss +107 -0
  94. package/src/tokens/_seeds.scss +59 -0
  95. package/src/tokens/_variables.scss +171 -130
  96. package/src/components/ColorChip/ColorChip.module.scss +0 -165
  97. package/src/components/ColorChip/index.tsx +0 -157
@@ -1,157 +0,0 @@
1
- 'use client';
2
-
3
- import * as React from 'react';
4
- import { HexColorPicker } from 'react-colorful';
5
- import { Popover as BasePopover } from '@base-ui/react/popover';
6
- import styles from './ColorChip.module.scss';
7
- import '../../styles/globals.scss';
8
-
9
- export interface ColorChipProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
10
- /** Color value in hex format */
11
- value: string;
12
- /** Callback when color changes */
13
- onChange?: (color: string) => void;
14
- /** Label for the color */
15
- label?: string;
16
- /** Show the hex value */
17
- showHex?: boolean;
18
- /** Size variant */
19
- size?: 'sm' | 'md';
20
- /** Whether the chip is locked (won't change on palette generation) */
21
- locked?: boolean;
22
- /** Callback when lock state changes */
23
- onLockChange?: (locked: boolean) => void;
24
- /** Disable editing */
25
- disabled?: boolean;
26
- }
27
-
28
- export const ColorChip = React.forwardRef<HTMLDivElement, ColorChipProps>(
29
- function ColorChip(
30
- {
31
- value,
32
- onChange,
33
- label,
34
- showHex = true,
35
- size = 'md',
36
- locked = false,
37
- onLockChange,
38
- disabled = false,
39
- className,
40
- ...htmlProps
41
- },
42
- ref
43
- ) {
44
- const [inputValue, setInputValue] = React.useState(value);
45
- const [isEditing, setIsEditing] = React.useState(false);
46
-
47
- // Sync input when value changes externally
48
- React.useEffect(() => {
49
- setInputValue(value);
50
- }, [value]);
51
-
52
- const handleColorChange = (color: string) => {
53
- setInputValue(color);
54
- onChange?.(color);
55
- };
56
-
57
- const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
58
- const newValue = e.target.value;
59
- setInputValue(newValue);
60
-
61
- // Only update if valid hex
62
- if (/^#[0-9A-Fa-f]{6}$/.test(newValue)) {
63
- onChange?.(newValue);
64
- }
65
- };
66
-
67
- const handleInputBlur = () => {
68
- setIsEditing(false);
69
- // Reset to valid value on blur if invalid
70
- if (!/^#[0-9A-Fa-f]{6}$/.test(inputValue)) {
71
- setInputValue(value);
72
- }
73
- };
74
-
75
- const handleInputKeyDown = (e: React.KeyboardEvent) => {
76
- if (e.key === 'Enter') {
77
- (e.target as HTMLInputElement).blur();
78
- }
79
- if (e.key === 'Escape') {
80
- setInputValue(value);
81
- (e.target as HTMLInputElement).blur();
82
- }
83
- };
84
-
85
- const handleLockClick = (e: React.MouseEvent) => {
86
- e.stopPropagation();
87
- onLockChange?.(!locked);
88
- };
89
-
90
- const classes = [
91
- styles.wrapper,
92
- styles[`size${size.charAt(0).toUpperCase() + size.slice(1)}`],
93
- disabled && styles.disabled,
94
- className,
95
- ].filter(Boolean).join(' ');
96
-
97
- return (
98
- <div ref={ref} {...htmlProps} className={classes}>
99
- <BasePopover.Root>
100
- <BasePopover.Trigger
101
- className={styles.swatch}
102
- style={{ backgroundColor: value }}
103
- disabled={disabled}
104
- aria-label={label ? `Edit ${label} color` : 'Edit color'}
105
- />
106
- <BasePopover.Portal>
107
- <BasePopover.Positioner side="bottom" align="start" sideOffset={4} className={styles.positioner}>
108
- <BasePopover.Popup className={styles.popup}>
109
- <HexColorPicker color={value} onChange={handleColorChange} />
110
- </BasePopover.Popup>
111
- </BasePopover.Positioner>
112
- </BasePopover.Portal>
113
- </BasePopover.Root>
114
-
115
- {label && <span className={styles.label}>{label}</span>}
116
-
117
- {showHex && (
118
- <input
119
- type="text"
120
- value={inputValue}
121
- onChange={handleInputChange}
122
- onBlur={handleInputBlur}
123
- onFocus={() => setIsEditing(true)}
124
- onKeyDown={handleInputKeyDown}
125
- disabled={disabled}
126
- className={styles.hexInput}
127
- spellCheck={false}
128
- aria-label={label ? `${label} hex value` : 'Hex value'}
129
- />
130
- )}
131
-
132
- {onLockChange && (
133
- <button
134
- type="button"
135
- onClick={handleLockClick}
136
- className={[styles.lockButton, locked && styles.locked].filter(Boolean).join(' ')}
137
- disabled={disabled}
138
- aria-label={locked ? 'Unlock color' : 'Lock color'}
139
- aria-pressed={locked}
140
- >
141
- {locked ? (
142
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
143
- <rect width="18" height="11" x="3" y="11" rx="2" ry="2" />
144
- <path d="M7 11V7a5 5 0 0 1 10 0v4" />
145
- </svg>
146
- ) : (
147
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
148
- <rect width="18" height="11" x="3" y="11" rx="2" ry="2" />
149
- <path d="M7 11V7a5 5 0 0 1 9.9-1" />
150
- </svg>
151
- )}
152
- </button>
153
- )}
154
- </div>
155
- );
156
- }
157
- );