ui-ingredients 0.15.1 → 0.16.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.
@@ -1,12 +1,12 @@
1
1
  <script lang="ts" module>
2
- import type {Assign, HtmlIngredientProps} from '../types.js';
3
- import type {IndicatorProps} from '@zag-js/clipboard';
2
+ import type {HtmlIngredientProps} from '../types.js';
3
+
4
+ interface IndicatorState {
5
+ copied: boolean;
6
+ }
4
7
 
5
8
  export interface ClipboardIndicatorProps
6
- extends Assign<
7
- HtmlIngredientProps<'span', HTMLSpanElement>,
8
- Partial<IndicatorProps>
9
- > {}
9
+ extends HtmlIngredientProps<'span', HTMLSpanElement, IndicatorState> {}
10
10
  </script>
11
11
 
12
12
  <script lang="ts">
@@ -15,7 +15,6 @@
15
15
 
16
16
  let {
17
17
  ref = $bindable(null),
18
- copied = false,
19
18
  asChild,
20
19
  children,
21
20
  ...props
@@ -23,15 +22,19 @@
23
22
 
24
23
  let clipboard = getClipboardContext();
25
24
 
25
+ let state = $derived({
26
+ copied: clipboard.copied,
27
+ });
28
+
26
29
  let mergedProps = $derived(
27
- mergeProps(clipboard.getIndicatorProps({copied}), props),
30
+ mergeProps(clipboard.getIndicatorProps(state), props),
28
31
  );
29
32
  </script>
30
33
 
31
34
  {#if asChild}
32
- {@render asChild(mergedProps)}
35
+ {@render asChild(mergedProps, state)}
33
36
  {:else}
34
37
  <span bind:this={ref} {...mergedProps}>
35
- {@render children?.()}
38
+ {@render children?.(state)}
36
39
  </span>
37
40
  {/if}
@@ -1,6 +1,8 @@
1
- import type { Assign, HtmlIngredientProps } from '../types.js';
2
- import type { IndicatorProps } from '@zag-js/clipboard';
3
- export interface ClipboardIndicatorProps extends Assign<HtmlIngredientProps<'span', HTMLSpanElement>, Partial<IndicatorProps>> {
1
+ import type { HtmlIngredientProps } from '../types.js';
2
+ interface IndicatorState {
3
+ copied: boolean;
4
+ }
5
+ export interface ClipboardIndicatorProps extends HtmlIngredientProps<'span', HTMLSpanElement, IndicatorState> {
4
6
  }
5
7
  interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
6
8
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
@@ -44,13 +44,22 @@ export function createDrawer(props) {
44
44
  return mergeProps(o.getTriggerProps(), parts.trigger.attrs);
45
45
  },
46
46
  getBodyProps() {
47
- return { ...parts.body.attrs };
47
+ return {
48
+ ...parts.body.attrs,
49
+ 'data-state': o.open ? 'open' : 'closed',
50
+ };
48
51
  },
49
52
  getFooterProps() {
50
- return { ...parts.footer.attrs };
53
+ return {
54
+ ...parts.footer.attrs,
55
+ 'data-state': o.open ? 'open' : 'closed',
56
+ };
51
57
  },
52
58
  getHeaderProps() {
53
- return { ...parts.header.attrs };
59
+ return {
60
+ ...parts.header.attrs,
61
+ 'data-state': o.open ? 'open' : 'closed',
62
+ };
54
63
  },
55
64
  };
56
65
  });
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "ui-ingredients",
3
3
  "type": "module",
4
4
  "license": "MIT",
5
- "version": "0.15.1",
5
+ "version": "0.16.0",
6
6
  "packageManager": "pnpm@9.12.3",
7
7
  "svelte": "./dist/index.js",
8
8
  "types": "./dist/index.d.ts",