@agnos-ui/svelte-headless 0.3.1 → 0.4.0-next.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 (44) hide show
  1. package/config.d.ts +3 -6
  2. package/generated/index.d.ts +9 -0
  3. package/generated/index.js +9 -0
  4. package/index.d.ts +0 -9
  5. package/index.js +0 -9
  6. package/package.json +8 -7
  7. package/types.d.ts +4 -12
  8. package/utils/widget.js +1 -1
  9. package/components/accordion/index.d.ts +0 -1
  10. package/components/accordion/index.js +0 -1
  11. package/components/alert/index.d.ts +0 -1
  12. package/components/alert/index.js +0 -1
  13. package/components/modal/index.d.ts +0 -1
  14. package/components/modal/index.js +0 -1
  15. package/components/pagination/index.d.ts +0 -1
  16. package/components/pagination/index.js +0 -1
  17. package/components/progressbar/index.d.ts +0 -1
  18. package/components/progressbar/index.js +0 -1
  19. package/components/rating/index.d.ts +0 -1
  20. package/components/rating/index.js +0 -1
  21. package/components/select/index.d.ts +0 -1
  22. package/components/select/index.js +0 -1
  23. package/components/slider/index.d.ts +0 -1
  24. package/components/slider/index.js +0 -1
  25. package/components/toast/index.d.ts +0 -1
  26. package/components/toast/index.js +0 -1
  27. /package/{components/accordion/accordion.d.ts → generated/components/accordion/index.d.ts} +0 -0
  28. /package/{components/accordion/accordion.js → generated/components/accordion/index.js} +0 -0
  29. /package/{components/alert/alert.d.ts → generated/components/alert/index.d.ts} +0 -0
  30. /package/{components/alert/alert.js → generated/components/alert/index.js} +0 -0
  31. /package/{components/modal/modal.d.ts → generated/components/modal/index.d.ts} +0 -0
  32. /package/{components/modal/modal.js → generated/components/modal/index.js} +0 -0
  33. /package/{components/pagination/pagination.d.ts → generated/components/pagination/index.d.ts} +0 -0
  34. /package/{components/pagination/pagination.js → generated/components/pagination/index.js} +0 -0
  35. /package/{components/progressbar/progressbar.d.ts → generated/components/progressbar/index.d.ts} +0 -0
  36. /package/{components/progressbar/progressbar.js → generated/components/progressbar/index.js} +0 -0
  37. /package/{components/rating/rating.d.ts → generated/components/rating/index.d.ts} +0 -0
  38. /package/{components/rating/rating.js → generated/components/rating/index.js} +0 -0
  39. /package/{components/select/select.d.ts → generated/components/select/index.d.ts} +0 -0
  40. /package/{components/select/select.js → generated/components/select/index.js} +0 -0
  41. /package/{components/slider/slider.d.ts → generated/components/slider/index.d.ts} +0 -0
  42. /package/{components/slider/slider.js → generated/components/slider/index.js} +0 -0
  43. /package/{components/toast/toast.d.ts → generated/components/toast/index.d.ts} +0 -0
  44. /package/{components/toast/toast.js → generated/components/toast/index.js} +0 -0
package/config.d.ts CHANGED
@@ -1,10 +1,7 @@
1
- import type { WidgetsConfig as CoreWidgetsConfig, Partial2Levels, WidgetsConfigStore } from '@agnos-ui/core/config';
1
+ import type { Partial2Levels, WidgetsConfigStore } from '@agnos-ui/core/config';
2
2
  import type { ReadableSignal } from '@amadeus-it-group/tansu';
3
- import type { AdaptPropsSlots, SlotsPresent, Widget, WidgetProps, WidgetFactory } from './types';
3
+ import type { SlotsPresent, Widget, WidgetProps, WidgetFactory } from './types';
4
4
  export * from '@agnos-ui/core/config';
5
- export type WidgetsConfig = {
6
- [WidgetName in keyof CoreWidgetsConfig]: AdaptPropsSlots<CoreWidgetsConfig[WidgetName]>;
7
- };
8
5
  type WidgetFactoryInput<Config extends {
9
6
  [widgetName: string]: object;
10
7
  }, W extends Widget> = {
@@ -40,6 +37,6 @@ export declare const widgetsConfigFactory: <Config extends {
40
37
  patchChangedProps: W["patch"];
41
38
  };
42
39
  };
43
- export declare const widgetsDefaultConfigKey: symbol, createWidgetsDefaultConfig: CreateWidgetsDefaultConfig<WidgetsConfig>, getContextWidgetConfig: <N extends string | number | symbol>(widgetName: N) => ReadableSignal<Partial<WidgetsConfig[N]> | undefined>, callWidgetFactory: <W extends Widget>({ factory, widgetName, $$slots, defaultConfig, events, $$props, }: WidgetFactoryInput<WidgetsConfig, W>) => W & {
40
+ export declare const widgetsDefaultConfigKey: symbol, createWidgetsDefaultConfig: CreateWidgetsDefaultConfig<WidgetsConfig>, getContextWidgetConfig: <N extends string | number | symbol>(widgetName: N) => ReadableSignal<any>, callWidgetFactory: <W extends Widget>({ factory, widgetName, $$slots, defaultConfig, events, $$props, }: WidgetFactoryInput<WidgetsConfig, W>) => W & {
44
41
  patchChangedProps: W["patch"];
45
42
  };
@@ -20,3 +20,12 @@ export * from './config';
20
20
  export * from './utils/widget';
21
21
  export * from './slot';
22
22
  export * from './Slot.svelte.d';
23
+ export * from './components/toast/index';
24
+ export * from './components/slider/index';
25
+ export * from './components/select/index';
26
+ export * from './components/rating/index';
27
+ export * from './components/progressbar/index';
28
+ export * from './components/pagination/index';
29
+ export * from './components/modal/index';
30
+ export * from './components/alert/index';
31
+ export * from './components/accordion/index';
@@ -20,3 +20,12 @@ export * from './config';
20
20
  export * from './utils/widget';
21
21
  export * from './slot';
22
22
  export * from './Slot.svelte.d';
23
+ export * from './components/toast/index';
24
+ export * from './components/slider/index';
25
+ export * from './components/select/index';
26
+ export * from './components/rating/index';
27
+ export * from './components/progressbar/index';
28
+ export * from './components/pagination/index';
29
+ export * from './components/modal/index';
30
+ export * from './components/alert/index';
31
+ export * from './components/accordion/index';
package/index.d.ts CHANGED
@@ -1,10 +1 @@
1
- export * from './components/accordion/accordion';
2
- export * from './components/alert/alert';
3
- export * from './components/modal/modal';
4
- export * from './components/pagination/pagination';
5
- export * from './components/progressbar/progressbar';
6
- export * from './components/rating/rating';
7
- export * from './components/select/select';
8
- export * from './components/slider/slider';
9
- export * from './components/toast/toast';
10
1
  export * from './generated';
package/index.js CHANGED
@@ -1,10 +1 @@
1
- export * from './components/accordion/accordion';
2
- export * from './components/alert/alert';
3
- export * from './components/modal/modal';
4
- export * from './components/pagination/pagination';
5
- export * from './components/progressbar/progressbar';
6
- export * from './components/rating/rating';
7
- export * from './components/select/select';
8
- export * from './components/slider/slider';
9
- export * from './components/toast/toast';
10
1
  export * from './generated';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agnos-ui/svelte-headless",
3
3
  "description": "Headless widget library for Svelte.",
4
- "version": "0.3.1",
4
+ "version": "0.4.0-next.1",
5
5
  "type": "module",
6
6
  "main": "./index.js",
7
7
  "module": "./index.js",
@@ -13,9 +13,9 @@
13
13
  "default": "./index.js"
14
14
  },
15
15
  "./components/*": {
16
- "types": "./components/*/*.d.ts",
17
- "svelte": "./components/*/*.js",
18
- "default": "./components/*/*.js"
16
+ "types": "./generated/components/*/index.d.ts",
17
+ "svelte": "./generated/components/*/index.js",
18
+ "default": "./generated/components/*/index.js"
19
19
  },
20
20
  "./config": {
21
21
  "types": "./config.d.ts",
@@ -49,11 +49,11 @@
49
49
  }
50
50
  },
51
51
  "dependencies": {
52
- "@agnos-ui/core": "0.3.1"
52
+ "@agnos-ui/core": "0.4.0-next.1"
53
53
  },
54
54
  "peerDependencies": {
55
- "@amadeus-it-group/tansu": "*",
56
- "svelte": "*"
55
+ "@amadeus-it-group/tansu": "^1.0.0",
56
+ "svelte": "^4.2.18"
57
57
  },
58
58
  "sideEffects": false,
59
59
  "homepage": "https://amadeusitgroup.github.io/AgnosUI/latest/",
@@ -66,6 +66,7 @@
66
66
  },
67
67
  "keywords": [
68
68
  "svelte",
69
+ "headless",
69
70
  "AgnosUI",
70
71
  "accordion",
71
72
  "alert",
package/types.d.ts CHANGED
@@ -1,21 +1,13 @@
1
1
  export * from '@agnos-ui/core/types';
2
- import type { SlotContent as CoreSlotContent, Widget, WidgetFactory, WidgetProps, WidgetSlotContext, WidgetState } from '@agnos-ui/core/types';
2
+ import type { SlotContent as CoreSlotContent, Extends, WidgetProps, WidgetSlotContext } from '@agnos-ui/core/types';
3
3
  import type { ComponentType, SvelteComponent } from 'svelte';
4
4
  export declare const useSvelteSlot: unique symbol;
5
+ export type IsSlotContent<T> = Extends<T, SlotContent<any>> | Extends<SlotContent<any>, T> extends 1 ? T : 0;
5
6
  export type WidgetPropsSlots<Props extends object> = {
6
- [K in keyof Props & `slot${string}` as K extends `slot${infer U}` ? Uncapitalize<U> : never]: Props[K] extends SlotContent<infer U> ? U : never;
7
+ [K in keyof Props as IsSlotContent<Props[K]> extends SlotContent<any> ? K extends 'children' ? 'default' : K extends `slot${infer U}` ? Uncapitalize<U> : K : never]: Props[K] extends SlotContent<infer U> ? U : never;
7
8
  };
8
9
  export type SlotsPresent<Props extends object> = {
9
- [K in keyof Props & `slot${string}` as K extends `slot${infer U}` ? Uncapitalize<U> : never]?: boolean;
10
+ [K in keyof Props as IsSlotContent<Props[K]> extends SlotContent<any> ? K extends 'children' ? 'default' : K extends `slot${infer U}` ? Uncapitalize<U> : K : never]?: boolean;
10
11
  };
11
12
  export type SlotSvelteComponent<Props extends object = object> = ComponentType<SvelteComponent<Props, any, Props extends WidgetSlotContext<infer U> ? WidgetPropsSlots<WidgetProps<U>> : any>>;
12
13
  export type SlotContent<Props extends object = object> = CoreSlotContent<Props> | SlotSvelteComponent<Props> | typeof useSvelteSlot;
13
- export type AdaptSlotContentProps<Props extends Record<string, any>> = Props extends WidgetSlotContext<infer U> ? WidgetSlotContext<AdaptWidgetSlots<U>> & AdaptPropsSlots<Omit<Props, keyof WidgetSlotContext<any>>> : AdaptPropsSlots<Props>;
14
- export type AdaptPropsSlots<Props> = Omit<Props, `slot${string}`> & {
15
- [K in keyof Props & `slot${string}`]: Props[K] extends CoreSlotContent<infer U> ? SlotContent<AdaptSlotContentProps<U>> : Props[K];
16
- };
17
- export type AdaptWidgetFactories<T> = {
18
- [K in keyof T]: T[K] extends WidgetFactory<infer U> ? WidgetFactory<AdaptWidgetSlots<U>> : T[K];
19
- };
20
- export type AdaptWidgetSlots<W extends Widget> = Widget<AdaptPropsSlots<WidgetProps<W>>, AdaptPropsSlots<WidgetState<W>>, AdaptWidgetFactories<W['api']>, W['actions'], W['directives']>;
21
- export type PropType<Props, K extends keyof Props> = Props[K];
package/utils/widget.js CHANGED
@@ -54,7 +54,7 @@ export const callWidgetFactoryWithConfig = ({ factory, $$slots, defaultConfig, w
54
54
  if ($$slots) {
55
55
  for (const [name, present] of Object.entries($$slots)) {
56
56
  if (present) {
57
- processedSlots[`slot${name[0].toUpperCase()}${name.substring(1)}`] = useSvelteSlot;
57
+ processedSlots[name === 'default' ? 'children' : name] = useSvelteSlot;
58
58
  }
59
59
  }
60
60
  }
@@ -1 +0,0 @@
1
- export * from './accordion';
@@ -1 +0,0 @@
1
- export * from './accordion';
@@ -1 +0,0 @@
1
- export * from './alert';
@@ -1 +0,0 @@
1
- export * from './alert';
@@ -1 +0,0 @@
1
- export * from './modal';
@@ -1 +0,0 @@
1
- export * from './modal';
@@ -1 +0,0 @@
1
- export * from './pagination';
@@ -1 +0,0 @@
1
- export * from './pagination';
@@ -1 +0,0 @@
1
- export * from './progressbar';
@@ -1 +0,0 @@
1
- export * from './progressbar';
@@ -1 +0,0 @@
1
- export * from './rating';
@@ -1 +0,0 @@
1
- export * from './rating';
@@ -1 +0,0 @@
1
- export * from './select';
@@ -1 +0,0 @@
1
- export * from './select';
@@ -1 +0,0 @@
1
- export * from './slider';
@@ -1 +0,0 @@
1
- export * from './slider';
@@ -1 +0,0 @@
1
- export * from './toast';
@@ -1 +0,0 @@
1
- export * from './toast';