sit-onyx 1.2.0-dev-20251016073921 → 1.2.0-dev-20251016092305

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.
@@ -40,9 +40,15 @@ export type Merge<Target, Source> = {
40
40
  */
41
41
  export type MergeAll<T extends unknown[]> = T extends [infer First, ...infer Rest] ? Rest extends [] ? First : Merge<First, MergeAll<Rest>> : never;
42
42
  /**
43
- * Pick a value from `T` for the key `K`, if it exists.
43
+ * Take the value types from `T` for the key `K`, if it exists.
44
44
  */
45
- export type MaybePick<T, Key, Fallback = never> = Key extends keyof T ? T[Key] : Fallback;
45
+ export type MaybeUnwrap<T, Key, Fallback = never> = Key extends keyof T ? T[Key] : Fallback;
46
+ /**
47
+ * Create a subset of `T` for all keys `Key` that exist in `T`
48
+ */
49
+ export type MaybePick<T, Key extends PropertyKey> = {
50
+ [P in Key as P extends keyof T ? P : never]: P extends keyof T ? T[P] : never;
51
+ };
46
52
  /**
47
53
  * Recursive / deep implementation of TypeScript's built-in `Partial<T>` type.
48
54
  */
@@ -0,0 +1,30 @@
1
+ import { ComponentProps } from 'vue-component-type-helpers';
2
+ import { Data, MaybePick } from '../types/utils.js';
3
+ /**
4
+ * The computed value is an object, that only contains properties that are defined by the target component.
5
+ * Is useful to forward only a matching subset of properties from a parent component to a wrapped child component.
6
+ *
7
+ * This is necessary when the parent defines props, which are not defined in the child component.
8
+ * Otherwise, the child component will set the extraneous props as attributes, which bloats the DOM and can lead to unexpected side-effects.
9
+ *
10
+ * @example
11
+ *
12
+ * ```vue
13
+ * <script setup lang="ts">
14
+ * import { useForwardProps } from "sit-onyx";
15
+ * import MyChildComponent from "./MyChildComponent.vue";
16
+ *
17
+ * const props = defineProps<ParentProps & ChildProps>();
18
+ * const childProps = useForwardProps(props, MyChildComponent);
19
+ * </script>
20
+ * <template>
21
+ * <!-- childProps only includes props that exist on MyChildComponent -->
22
+ * <MyChildComponent v-bind="childProps" />
23
+ * </template>
24
+ * ```
25
+ *
26
+ * @param props The reactive props object of the parent component.
27
+ * @param target Component for which the properties are to be forwarded.
28
+ * @returns computed value with properties that are also defined the target component.
29
+ */
30
+ export declare const useForwardProps: <T extends Data, TComponent, TProps = ComponentProps<TComponent>, R = MaybePick<T, keyof TProps>>(props: T, target: TComponent) => import('vue').ComputedRef<R>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sit-onyx",
3
3
  "description": "A design system and Vue.js component library created by Schwarz IT",
4
- "version": "1.2.0-dev-20251016073921",
4
+ "version": "1.2.0-dev-20251016092305",
5
5
  "type": "module",
6
6
  "author": "Schwarz IT KG",
7
7
  "license": "Apache-2.0",
@@ -59,10 +59,10 @@
59
59
  "vue-i18n": "^11.1.12",
60
60
  "vue-router": "^4.6.0",
61
61
  "@sit-onyx/flags": "^1.0.0",
62
- "@sit-onyx/headless": "^0.2.0-dev-20251016073921",
63
- "@sit-onyx/storybook-utils": "^1.0.2-dev-20251016073921",
62
+ "@sit-onyx/headless": "^0.2.0-dev-20251016092305",
63
+ "@sit-onyx/playwright-utils": "^1.0.0",
64
64
  "@sit-onyx/shared": "^0.1.0",
65
- "@sit-onyx/playwright-utils": "^1.0.0"
65
+ "@sit-onyx/storybook-utils": "^1.0.2-dev-20251016092305"
66
66
  },
67
67
  "scripts": {
68
68
  "dev": "storybook dev -p 6006 --no-open",