@tangible/ui 0.2.0 → 0.2.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.
Files changed (35) hide show
  1. package/components/ColorPicker/ColorArea.d.ts +24 -0
  2. package/components/ColorPicker/ColorArea.js +62 -0
  3. package/components/ColorPicker/ColorField.d.ts +59 -0
  4. package/components/ColorPicker/ColorField.js +88 -0
  5. package/components/ColorPicker/ColorPicker.d.ts +36 -0
  6. package/components/ColorPicker/ColorPicker.js +215 -0
  7. package/components/ColorPicker/ColorSlider.d.ts +20 -0
  8. package/components/ColorPicker/ColorSlider.js +38 -0
  9. package/components/ColorPicker/index.d.ts +14 -0
  10. package/components/ColorPicker/index.js +7 -0
  11. package/components/ColorPicker/labels.d.ts +42 -0
  12. package/components/ColorPicker/labels.js +38 -0
  13. package/components/ColorPicker/tracks.d.ts +4 -0
  14. package/components/ColorPicker/tracks.js +4 -0
  15. package/components/ColorPicker/usePointerDrag.d.ts +13 -0
  16. package/components/ColorPicker/usePointerDrag.js +34 -0
  17. package/components/Popover/index.d.ts +1 -1
  18. package/components/index.d.ts +3 -0
  19. package/components/index.js +1 -0
  20. package/icons/icons.svg +1 -0
  21. package/icons/manifest.json +8 -0
  22. package/icons/registry.d.ts +2 -0
  23. package/icons/registry.js +1 -0
  24. package/icons/system/index.d.ts +2 -0
  25. package/icons/system/index.js +11 -0
  26. package/package.json +5 -1
  27. package/styles/all.css +1 -1
  28. package/styles/all.expanded.css +273 -0
  29. package/styles/all.expanded.unlayered.css +273 -0
  30. package/styles/all.unlayered.css +1 -1
  31. package/styles/components/_bundle.scss +2 -0
  32. package/styles/components/color-picker.scss +378 -0
  33. package/tui-manifest.json +94 -4
  34. package/utils/color/color.d.ts +61 -0
  35. package/utils/color/color.js +293 -0
@@ -0,0 +1,38 @@
1
+ export const defaultColorPickerLabels = {
2
+ group: 'Color picker',
3
+ area: 'Saturation and brightness',
4
+ hue: 'Hue',
5
+ alpha: 'Alpha',
6
+ format: 'Color format',
7
+ value: 'Color value',
8
+ copy: 'Copy color value',
9
+ copied: 'Copied',
10
+ variable: 'Variable:',
11
+ formats: { hex: 'Hex', rgb: 'RGB', hsl: 'HSL', hwb: 'HWB', oklch: 'OKLCH' },
12
+ channels: {
13
+ red: 'Red',
14
+ green: 'Green',
15
+ blue: 'Blue',
16
+ hue: 'Hue',
17
+ saturation: 'Saturation',
18
+ lightness: 'Lightness',
19
+ whiteness: 'Whiteness',
20
+ blackness: 'Blackness',
21
+ chroma: 'Chroma',
22
+ alpha: 'Alpha',
23
+ },
24
+ channelGroup: (label) => `${label} value`,
25
+ hueValueText: (degrees) => `${degrees} degrees`,
26
+ alphaValueText: (percent) => `${percent} percent`,
27
+ areaValueText: (saturation, brightness) => `Saturation ${saturation}%, brightness ${brightness}%`,
28
+ };
29
+ /** Merge consumer overrides over the defaults (shallow, plus the nested maps). */
30
+ export function resolveLabels(labels) {
31
+ const d = defaultColorPickerLabels;
32
+ return {
33
+ ...d,
34
+ ...labels,
35
+ formats: { ...d.formats, ...labels?.formats },
36
+ channels: { ...d.channels, ...labels?.channels },
37
+ };
38
+ }
@@ -0,0 +1,4 @@
1
+ /** Rainbow hue track (0–360°). */
2
+ export declare const HUE_TRACK = "linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%)";
3
+ /** Alpha track: transparent → the opaque colour (rendered over the checkerboard). */
4
+ export declare const alphaTrack: (colorHex: string) => string;
@@ -0,0 +1,4 @@
1
+ /** Rainbow hue track (0–360°). */
2
+ export const HUE_TRACK = 'linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%)';
3
+ /** Alpha track: transparent → the opaque colour (rendered over the checkerboard). */
4
+ export const alphaTrack = (colorHex) => `linear-gradient(to right, transparent, ${colorHex})`;
@@ -0,0 +1,13 @@
1
+ import type React from 'react';
2
+ /**
3
+ * Pointer drag over an element. pointerdown captures the pointer and fires
4
+ * onMove(clientX, clientY); subsequent moves fire it too until pointerup. The
5
+ * consumer converts client coords to a value using its own bounding rect.
6
+ * Spread the returned handlers onto the draggable element.
7
+ */
8
+ export declare function usePointerDrag(onMove: (clientX: number, clientY: number) => void, disabled?: boolean): {
9
+ onPointerDown: (e: React.PointerEvent) => void;
10
+ onPointerMove: (e: React.PointerEvent) => void;
11
+ onPointerUp: (e: React.PointerEvent) => void;
12
+ };
13
+ export declare const clamp01: (n: number) => number;
@@ -0,0 +1,34 @@
1
+ import { useCallback, useRef } from 'react';
2
+ /**
3
+ * Pointer drag over an element. pointerdown captures the pointer and fires
4
+ * onMove(clientX, clientY); subsequent moves fire it too until pointerup. The
5
+ * consumer converts client coords to a value using its own bounding rect.
6
+ * Spread the returned handlers onto the draggable element.
7
+ */
8
+ export function usePointerDrag(onMove, disabled) {
9
+ const active = useRef(false);
10
+ const onPointerDown = useCallback((e) => {
11
+ if (disabled || e.button !== 0)
12
+ return;
13
+ e.preventDefault();
14
+ e.currentTarget.setPointerCapture?.(e.pointerId);
15
+ active.current = true;
16
+ onMove(e.clientX, e.clientY);
17
+ }, [onMove, disabled]);
18
+ const onPointerMove = useCallback((e) => {
19
+ if (!active.current)
20
+ return;
21
+ onMove(e.clientX, e.clientY);
22
+ }, [onMove]);
23
+ const onPointerUp = useCallback((e) => {
24
+ active.current = false;
25
+ try {
26
+ e.currentTarget.releasePointerCapture?.(e.pointerId);
27
+ }
28
+ catch {
29
+ /* pointer already released */
30
+ }
31
+ }, []);
32
+ return { onPointerDown, onPointerMove, onPointerUp };
33
+ }
34
+ export const clamp01 = (n) => Math.min(1, Math.max(0, n));
@@ -1,2 +1,2 @@
1
1
  export { Popover, PopoverTrigger, PopoverContent, usePopover } from './Popover';
2
- export type { PopoverProps, PopoverTriggerProps, PopoverContentProps, } from './types';
2
+ export type { PopoverProps, PopoverTriggerProps, PopoverContentProps, Side, Align, } from './types';
@@ -9,6 +9,7 @@ export { Checkbox } from './Checkbox';
9
9
  export { Chip } from './Chip';
10
10
  export { ChipGroup } from './ChipGroup';
11
11
  export { Chips } from './Chips';
12
+ export { ColorPicker, ColorField, ColorArea, ColorSlider, defaultColorPickerLabels } from './ColorPicker';
12
13
  export { ContentIndicator } from './ContentIndicator';
13
14
  export { Calendar, DatePicker, DateRangePicker, defaultDateRangePresets, defaultCalendarLabels, defaultDatePickerLabels, defaultDateRangePickerLabels, } from './DatePicker';
14
15
  export { Combobox, ComboboxContent, ComboboxOption, ComboboxGroup, ComboboxLabel, useCombobox } from './Combobox';
@@ -48,6 +49,8 @@ export type { CheckboxProps } from './Checkbox';
48
49
  export type { ChipProps } from './Chip';
49
50
  export type { ChipGroupProps, ChipGroupSingleProps, ChipGroupMultipleProps } from './ChipGroup';
50
51
  export type { ChipsProps, ChipOption } from './Chips';
52
+ export type { ColorPickerProps, ColorPickerLabels, ColorFieldProps, ColorFieldLabels, ColorAreaProps, ColorSliderProps } from './ColorPicker';
53
+ export type { ColorFormat, Hsva as ColorHsva } from './ColorPicker';
51
54
  export type { ContentIndicatorProps } from './ContentIndicator';
52
55
  export type { DropdownProps, DropdownTriggerProps, DropdownContentProps, DropdownItemProps, DropdownSeparatorProps, DropdownHeaderProps, } from './Dropdown';
53
56
  export type { ComboboxProps, ComboboxContentProps, ComboboxOptionProps, ComboboxGroupProps, ComboboxLabelProps, ComboboxRegisteredOption, } from './Combobox';
@@ -7,6 +7,7 @@ export { Checkbox } from './Checkbox/index.js';
7
7
  export { Chip } from './Chip/index.js';
8
8
  export { ChipGroup } from './ChipGroup/index.js';
9
9
  export { Chips } from './Chips/index.js';
10
+ export { ColorPicker, ColorField, ColorArea, ColorSlider, defaultColorPickerLabels } from './ColorPicker/index.js';
10
11
  export { ContentIndicator } from './ContentIndicator/index.js';
11
12
  export { Calendar, DatePicker, DateRangePicker, defaultDateRangePresets, defaultCalendarLabels, defaultDatePickerLabels, defaultDateRangePickerLabels, } from './DatePicker/index.js';
12
13
  export { Combobox, ComboboxContent, ComboboxOption, ComboboxGroup, ComboboxLabel, useCombobox } from './Combobox/index.js';
package/icons/icons.svg CHANGED
@@ -175,6 +175,7 @@
175
175
  <symbol id="tui-system-download" viewBox="0 0 24 24"><path d="M5.5 9a.5.5 0 0 1 .5-.5h3V7H6a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8.75A1.75 1.75 0 0 0 18.25 7H15v1.5h3.25a.25.25 0 0 1 .25.25V18a.5.5 0 0 1-.5.5H6a.5.5 0 0 1-.5-.5z"/><path d="M12 17.004 7.002 12.56l.996-1.122 3.252 2.89V4h1.5v10.33l3.252-2.89.996 1.12z"/></symbol>
176
176
  <symbol id="tui-system-drag" viewBox="0 0 24 24"><path d="M10 5H8v2h2zm0 6H8v2h2zm-2 6h2v2H8zm8-12h-2v2h2zm-2 6h2v2h-2zm2 6h-2v2h2z"/></symbol>
177
177
  <symbol id="tui-system-duplicate" viewBox="0 0 24 24"><path d="M14.25 12.75H17v1.5h-2.75V17h-1.5v-2.75H10v-1.5h2.75V10h1.5z"/><path fill-rule="evenodd" d="M17 7h1a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2v-1H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2zm-2-1.5H6a.5.5 0 0 0-.5.5v9a.5.5 0 0 0 .5.5h1V9a2 2 0 0 1 2-2h6.5V6a.5.5 0 0 0-.5-.5m-6 3h9a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5H9a.5.5 0 0 1-.5-.5V9a.5.5 0 0 1 .5-.5" clip-rule="evenodd"/></symbol>
178
+ <symbol id="tui-system-edit-small" viewBox="0 0 24 24"><path fill-rule="evenodd" d="M18.168 9.14 14.924 6l-7.621 7.726L6 18.136l4.527-1.251z" clip-rule="evenodd"/></symbol>
178
179
  <symbol id="tui-system-edit" viewBox="0 0 24 24"><path d="M19.864 4.304a2 2 0 0 0-2.733.732l-.635 1.1 3.464 2 .636-1.1a2 2 0 0 0-.732-2.732m-.746 5.292-3.464-2-4.903 8.49.062 3.893 3.402-1.892zM4 5.25h9v1.5H4zm7 4H4v1.5h7zm-7 4h5v1.5H4zm5 4H4v1.5h5z"/></symbol>
179
180
  <symbol id="tui-system-ellipsis-h" viewBox="0 0 24 24"><path fill-rule="evenodd" d="M5 11h2v2H5zm6 0h2v2h-2zm6 0h2v2h-2z" clip-rule="evenodd"/></symbol>
180
181
  <symbol id="tui-system-ellipsis-v" viewBox="0 0 24 24"><path fill-rule="evenodd" d="M11 19v-2h2v2zm0-6v-2h2v2zm0-6V5h2v2z" clip-rule="evenodd"/></symbol>
@@ -1407,6 +1407,14 @@
1407
1407
  "viewBox": "0 0 24 24",
1408
1408
  "sprite": true
1409
1409
  },
1410
+ "system/edit-small": {
1411
+ "id": "tui-system-edit-small",
1412
+ "set": "system",
1413
+ "name": "edit-small",
1414
+ "file": "system/edit-small.svg",
1415
+ "viewBox": "0 0 24 24",
1416
+ "sprite": true
1417
+ },
1410
1418
  "system/edit": {
1411
1419
  "id": "tui-system-edit",
1412
1420
  "set": "system",
@@ -179,6 +179,7 @@ export type IconName =
179
179
  | 'system/download'
180
180
  | 'system/drag'
181
181
  | 'system/duplicate'
182
+ | 'system/edit-small'
182
183
  | 'system/edit'
183
184
  | 'system/ellipsis-h'
184
185
  | 'system/ellipsis-v'
@@ -407,6 +408,7 @@ export declare const iconRegistry: {
407
408
  'system/download': IconComponent;
408
409
  'system/drag': IconComponent;
409
410
  'system/duplicate': IconComponent;
411
+ 'system/edit-small': IconComponent;
410
412
  'system/edit': IconComponent;
411
413
  'system/ellipsis-h': IconComponent;
412
414
  'system/ellipsis-v': IconComponent;
package/icons/registry.js CHANGED
@@ -182,6 +182,7 @@ export const iconRegistry = {
182
182
  'system/download': systemIcons['download'],
183
183
  'system/drag': systemIcons['drag'],
184
184
  'system/duplicate': systemIcons['duplicate'],
185
+ 'system/edit-small': systemIcons['edit-small'],
185
186
  'system/edit': systemIcons['edit'],
186
187
  'system/ellipsis-h': systemIcons['ellipsis-h'],
187
188
  'system/ellipsis-v': systemIcons['ellipsis-v'],
@@ -46,6 +46,7 @@ export declare const CustomFunction: IconComponent;
46
46
  export declare const Download: IconComponent;
47
47
  export declare const Drag: IconComponent;
48
48
  export declare const Duplicate: IconComponent;
49
+ export declare const EditSmall: IconComponent;
49
50
  export declare const Edit: IconComponent;
50
51
  export declare const EllipsisH: IconComponent;
51
52
  export declare const EllipsisV: IconComponent;
@@ -142,6 +143,7 @@ export declare const systemIcons: {
142
143
  'download': IconComponent;
143
144
  'drag': IconComponent;
144
145
  'duplicate': IconComponent;
146
+ 'edit-small': IconComponent;
145
147
  'edit': IconComponent;
146
148
  'ellipsis-h': IconComponent;
147
149
  'ellipsis-v': IconComponent;
@@ -440,6 +440,16 @@ export function Duplicate(props) {
440
440
  }, props), [_c("path", {d:"M14.25 12.75H17v1.5h-2.75V17h-1.5v-2.75H10v-1.5h2.75V10h1.5z"}), _c("path", {fillRule:"evenodd",d:"M17 7h1a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2v-1H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2zm-2-1.5H6a.5.5 0 0 0-.5.5v9a.5.5 0 0 0 .5.5h1V9a2 2 0 0 1 2-2h6.5V6a.5.5 0 0 0-.5-.5m-6 3h9a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5H9a.5.5 0 0 1-.5-.5V9a.5.5 0 0 1 .5-.5",clipRule:"evenodd"})]);
441
441
  }
442
442
 
443
+ export function EditSmall(props) {
444
+ return _c("svg", Object.assign({
445
+ xmlns: "http://www.w3.org/2000/svg",
446
+ viewBox: "0 0 24 24",
447
+ width: "1em",
448
+ height: "1em",
449
+ fill: "currentColor"
450
+ }, props), _c("path", {fillRule:"evenodd",d:"M18.168 9.14 14.924 6l-7.621 7.726L6 18.136l4.527-1.251z",clipRule:"evenodd"}));
451
+ }
452
+
443
453
  export function Edit(props) {
444
454
  return _c("svg", Object.assign({
445
455
  xmlns: "http://www.w3.org/2000/svg",
@@ -985,6 +995,7 @@ export const systemIcons = {
985
995
  'download': Download,
986
996
  'drag': Drag,
987
997
  'duplicate': Duplicate,
998
+ 'edit-small': EditSmall,
988
999
  'edit': Edit,
989
1000
  'ellipsis-h': EllipsisH,
990
1001
  'ellipsis-v': EllipsisV,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangible/ui",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Tangible Design System",
5
5
  "type": "module",
6
6
  "main": "./components/index.js",
@@ -80,6 +80,10 @@
80
80
  "import": "./components/Chips/index.js",
81
81
  "types": "./components/Chips/index.d.ts"
82
82
  },
83
+ "./components/ColorPicker": {
84
+ "import": "./components/ColorPicker/index.js",
85
+ "types": "./components/ColorPicker/index.d.ts"
86
+ },
83
87
  "./components/Combobox": {
84
88
  "import": "./components/Combobox/index.js",
85
89
  "types": "./components/Combobox/index.d.ts"