horizon-design 0.0.10 → 0.0.12

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
@@ -559,19 +559,25 @@ Full-featured HSLA color picker with hex input and swatches.
559
559
 
560
560
  ```svelte
561
561
  <script>
562
- import { ColorPicker } from 'horizon-design';
562
+ import { ColorPicker, parseColor } from 'horizon-design';
563
563
 
564
- let color = $state('#737efa');
564
+ let color = $state(parseColor('#737efa'));
565
565
  </script>
566
566
 
567
567
  <ColorPicker label="Brand color" bind:value={color} />
568
568
  ```
569
569
 
570
- | Prop | Type | Default |
571
- | -------------- | -------- | ------- |
572
- | `label` | `string` | — |
573
- | `defaultValue` | `string` | — |
574
- | `value` | `string` | — |
570
+ | Prop | Type | Default |
571
+ | ------- | -------- | ------- |
572
+ | `label` | `string` | — |
573
+ | `value` | `Color` | — |
574
+
575
+ `Color` is a type exported from `horizon-design` representing a parsed color object. `parseColor` accepts any of the following string formats:
576
+
577
+ - Hex: `#RGB`, `#RGBA`, `#RRGGBB`, `#RRGGBBAA`
578
+ - RGB: `rgb(r, g, b)`, `rgba(r, g, b, a)`
579
+ - HSL: `hsl(h, s%, l%)`, `hsla(h, s%, l%, a)`
580
+ - HSB: `hsb(h, s%, b%)`, `hsba(h, s%, b%, a)`
575
581
 
576
582
  ---
577
583
 
@@ -1,32 +1,26 @@
1
1
  <script lang="ts">
2
- import { ColorPicker, parseColor } from '@ark-ui/svelte';
2
+ import { ColorPicker, type ColorPickerColor as Color } from '@ark-ui/svelte';
3
3
  import { cn } from '../../utils';
4
+ import { untrack } from 'svelte';
4
5
 
5
6
  let {
6
7
  class: className = '',
7
8
  label = '',
8
- defaultValue,
9
9
  value = $bindable(undefined),
10
10
  ...rest
11
11
  }: {
12
12
  class?: string;
13
13
  label?: string;
14
- defaultValue?: string | ReturnType<typeof parseColor>;
15
- value?: string | ReturnType<typeof parseColor>;
14
+ value?: Color;
16
15
  [key: string]: unknown;
17
16
  } = $props();
18
-
19
- const parsedDefaultValue = $derived(
20
- typeof defaultValue === 'string' ? parseColor(defaultValue) : defaultValue
21
- );
22
- const parsedValue = $derived(typeof value === 'string' ? parseColor(value) : value);
23
17
  </script>
24
18
 
25
19
  <ColorPicker.Root
26
20
  class={cn('flex flex-col gap-1.5', className)}
27
21
  data-slot="color-picker"
28
- defaultValue={parsedDefaultValue}
29
- value={parsedValue}
22
+ defaultValue={untrack(() => value)}
23
+ {value}
30
24
  onValueChange={(details) => (value = details.value)}
31
25
  {...rest}
32
26
  >
@@ -1,9 +1,8 @@
1
- import { ColorPicker, parseColor } from '@ark-ui/svelte';
1
+ import { ColorPicker, type ColorPickerColor as Color } from '@ark-ui/svelte';
2
2
  type $$ComponentProps = {
3
3
  class?: string;
4
4
  label?: string;
5
- defaultValue?: string | ReturnType<typeof parseColor>;
6
- value?: string | ReturnType<typeof parseColor>;
5
+ value?: Color;
7
6
  [key: string]: unknown;
8
7
  };
9
8
  declare const ColorPicker: import("svelte").Component<$$ComponentProps, {}, "value">;
@@ -1 +1,3 @@
1
1
  export { default as ColorPicker } from './ColorPicker.svelte';
2
+ export type { ColorPickerColor as Color } from '@ark-ui/svelte';
3
+ export { parseColor } from '@ark-ui/svelte';
@@ -1 +1,2 @@
1
1
  export { default as ColorPicker } from './ColorPicker.svelte';
2
+ export { parseColor } from '@ark-ui/svelte';
@@ -23,7 +23,7 @@
23
23
  </script>
24
24
 
25
25
  <Menu.Root {...rest}>
26
- <Menu.ContextTrigger data-slot="context-menu-trigger">
26
+ <Menu.ContextTrigger class="contents" data-slot="context-menu-trigger">
27
27
  {@render children?.()}
28
28
  </Menu.ContextTrigger>
29
29
  <Portal>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "horizon-design",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/horizon-engine/horizon-design"