ui-ingredients 0.15.1 → 0.16.1

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -38,11 +38,11 @@ npm install ui-ingredients
38
38
  </Dialog.Root>
39
39
  ```
40
40
 
41
- ## Inspirations
41
+ ## Inspiration
42
42
 
43
43
  - [zag](https://zagjs.com/) - The fantastic library that powers UI ingredients
44
44
  - [ark](https://ark-ui.com/) - The outstanding headless component library that greatly inspired this one
45
45
 
46
46
  ## Documentation
47
47
 
48
- Browse our beta [documentaion](https://ui-ingredients-next.vercel.app/)
48
+ Browse the [documentation](https://ui-ingredients.vercel.app/) for more information on how to use UI Ingredients
@@ -1,37 +1,40 @@
1
- <script lang="ts" module>
2
- import type {Assign, HtmlIngredientProps} from '../types.js';
3
- import type {IndicatorProps} from '@zag-js/clipboard';
4
-
5
- export interface ClipboardIndicatorProps
6
- extends Assign<
7
- HtmlIngredientProps<'span', HTMLSpanElement>,
8
- Partial<IndicatorProps>
9
- > {}
10
- </script>
11
-
12
- <script lang="ts">
13
- import {mergeProps} from '../merge-props.js';
14
- import {getClipboardContext} from './clipboard-context.svelte.js';
15
-
16
- let {
17
- ref = $bindable(null),
18
- copied = false,
19
- asChild,
20
- children,
21
- ...props
22
- }: ClipboardIndicatorProps = $props();
23
-
24
- let clipboard = getClipboardContext();
25
-
26
- let mergedProps = $derived(
27
- mergeProps(clipboard.getIndicatorProps({copied}), props),
28
- );
29
- </script>
30
-
31
- {#if asChild}
32
- {@render asChild(mergedProps)}
33
- {:else}
34
- <span bind:this={ref} {...mergedProps}>
35
- {@render children?.()}
36
- </span>
37
- {/if}
1
+ <script lang="ts" module>
2
+ import type {HtmlIngredientProps} from '../types.js';
3
+
4
+ interface IndicatorState {
5
+ copied: boolean;
6
+ }
7
+
8
+ export interface ClipboardIndicatorProps
9
+ extends HtmlIngredientProps<'span', HTMLSpanElement, IndicatorState> {}
10
+ </script>
11
+
12
+ <script lang="ts">
13
+ import {mergeProps} from '../merge-props.js';
14
+ import {getClipboardContext} from './clipboard-context.svelte.js';
15
+
16
+ let {
17
+ ref = $bindable(null),
18
+ asChild,
19
+ children,
20
+ ...props
21
+ }: ClipboardIndicatorProps = $props();
22
+
23
+ let clipboard = getClipboardContext();
24
+
25
+ let state = $derived({
26
+ copied: clipboard.copied,
27
+ });
28
+
29
+ let mergedProps = $derived(
30
+ mergeProps(clipboard.getIndicatorProps(state), props),
31
+ );
32
+ </script>
33
+
34
+ {#if asChild}
35
+ {@render asChild(mergedProps, state)}
36
+ {:else}
37
+ <span bind:this={ref} {...mergedProps}>
38
+ {@render children?.(state)}
39
+ </span>
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,8 +2,8 @@
2
2
  "name": "ui-ingredients",
3
3
  "type": "module",
4
4
  "license": "MIT",
5
- "version": "0.15.1",
6
- "packageManager": "pnpm@9.12.3",
5
+ "version": "0.16.1",
6
+ "packageManager": "pnpm@9.14.2",
7
7
  "svelte": "./dist/index.js",
8
8
  "types": "./dist/index.d.ts",
9
9
  "exports": {
@@ -356,30 +356,30 @@
356
356
  },
357
357
  "devDependencies": {
358
358
  "@faker-js/faker": "^9.2.0",
359
- "@sveltejs/adapter-vercel": "^5.4.7",
360
- "@sveltejs/kit": "^2.8.0",
359
+ "@sveltejs/adapter-vercel": "^5.4.8",
360
+ "@sveltejs/kit": "^2.8.2",
361
361
  "@sveltejs/package": "^2.3.7",
362
- "@sveltejs/vite-plugin-svelte": "^4.0.0",
362
+ "@sveltejs/vite-plugin-svelte": "^4.0.1",
363
363
  "@testing-library/jest-dom": "^6.6.3",
364
- "@testing-library/svelte": "^5.2.4",
364
+ "@testing-library/svelte": "^5.2.6",
365
365
  "@testing-library/user-event": "^14.5.2",
366
366
  "@types/jsdom": "^21.1.7",
367
367
  "@untitled-theme/icons-svelte": "^0.12.0",
368
368
  "autoprefixer": "^10.4.20",
369
369
  "globals": "^15.12.0",
370
370
  "jsdom": "^25.0.1",
371
- "postcss": "^8.4.48",
371
+ "postcss": "^8.4.49",
372
372
  "publint": "^0.2.12",
373
373
  "release-it": "^17.10.0",
374
374
  "resize-observer-polyfill": "^1.5.1",
375
- "svelte": "^5.1.13",
376
- "svelte-check": "^4.0.6",
375
+ "svelte": "^5.2.7",
376
+ "svelte-check": "^4.1.0",
377
377
  "tailwind-merge": "^2.5.4",
378
- "tailwind-variants": "^0.2.1",
379
- "tailwindcss": "^3.4.14",
380
- "typescript": "^5.6.3",
381
- "vite": "^5.4.10",
382
- "vitest": "^2.1.4",
378
+ "tailwind-variants": "^0.3.0",
379
+ "tailwindcss": "^3.4.15",
380
+ "typescript": "^5.7.2",
381
+ "vite": "^5.4.11",
382
+ "vitest": "^2.1.5",
383
383
  "vitest-axe": "^1.0.0-pre.3",
384
384
  "vitest-canvas-mock": "^0.3.3"
385
385
  },