@agnos-ui/svelte-headless 0.2.0 → 0.3.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.
- package/Slot.svelte +1 -9
- package/components/accordion/accordion.d.ts +0 -11
- package/components/accordion/accordion.js +0 -2
- package/components/alert/alert.d.ts +0 -6
- package/components/alert/alert.js +0 -2
- package/components/modal/modal.d.ts +0 -7
- package/components/modal/modal.js +0 -2
- package/components/pagination/pagination.d.ts +0 -8
- package/components/pagination/pagination.js +0 -2
- package/components/progressbar/progressbar.d.ts +0 -6
- package/components/progressbar/progressbar.js +0 -2
- package/components/rating/rating.d.ts +0 -6
- package/components/rating/rating.js +0 -2
- package/components/select/select.d.ts +0 -6
- package/components/select/select.js +0 -2
- package/components/slider/slider.d.ts +0 -6
- package/components/slider/slider.js +0 -2
- package/components/toast/toast.d.ts +0 -6
- package/components/toast/toast.js +0 -2
- package/config.d.ts +2 -2
- package/generated/index.d.ts +1 -1
- package/generated/index.js +1 -1
- package/generated/services/matchMedia.d.ts +1 -0
- package/generated/services/matchMedia.js +1 -0
- package/package.json +9 -8
- package/types.d.ts +1 -0
- package/utils/widget.d.ts +7 -7
- package/utils/widget.js +9 -5
- package/generated/services/transitions/bootstrap.d.ts +0 -1
- package/generated/services/transitions/bootstrap.js +0 -1
package/Slot.svelte
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {BROWSER} from 'esm-env';
|
|
3
2
|
import type {SlotContent, SlotSvelteComponent} from './types';
|
|
4
|
-
import {useSvelteSlot} from './types';
|
|
5
3
|
import {isSvelteComponent} from './utils/widget';
|
|
4
|
+
import {useSvelteSlot} from './types';
|
|
6
5
|
type Props = $$Generic<object>; // eslint-disable-line no-undef
|
|
7
6
|
// cf https://github.com/ota-meshi/eslint-plugin-svelte/issues/348
|
|
8
7
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -12,13 +11,6 @@
|
|
|
12
11
|
};
|
|
13
12
|
export let slotContent: SlotContent<Props> = null;
|
|
14
13
|
export let props: Props;
|
|
15
|
-
|
|
16
|
-
// Workaround for a svelte issue that prevents code generation for SSR/slot
|
|
17
|
-
// To be removed when https://github.com/sveltejs/svelte/issues/9137 is fixed
|
|
18
|
-
if (!BROWSER) {
|
|
19
|
-
// @ts-expect-error Setting the global variable `props`, which is not defined in the SSR Svelte-kit compilation
|
|
20
|
-
globalThis['props'] = props;
|
|
21
|
-
}
|
|
22
14
|
</script>
|
|
23
15
|
|
|
24
16
|
{#if slotContent === useSvelteSlot}
|
|
@@ -1,12 +1 @@
|
|
|
1
|
-
import type { AdaptSlotContentProps, AdaptWidgetSlots, WidgetFactory, WidgetProps, WidgetState, WidgetPropsSlots } from '../../types';
|
|
2
1
|
export * from '@agnos-ui/core/components/accordion';
|
|
3
|
-
export type AccordionWidget = AdaptWidgetSlots<import('@agnos-ui/core/components/accordion').AccordionWidget>;
|
|
4
|
-
export type AccordionProps = WidgetProps<AccordionWidget>;
|
|
5
|
-
export type AccordionState = WidgetState<AccordionWidget>;
|
|
6
|
-
export type AccordionApi = AccordionWidget['api'];
|
|
7
|
-
export type AccordionSlots = WidgetPropsSlots<AccordionProps>;
|
|
8
|
-
export type AccordionItemWidget = AdaptWidgetSlots<import('@agnos-ui/core/components/accordion').AccordionItemWidget>;
|
|
9
|
-
export type AccordionItemProps = WidgetProps<AccordionItemWidget>;
|
|
10
|
-
export type AccordionItemState = WidgetState<AccordionItemWidget>;
|
|
11
|
-
export type AccordionItemContext = AdaptSlotContentProps<import('@agnos-ui/core/components/accordion').AccordionItemContext>;
|
|
12
|
-
export declare const createAccordion: WidgetFactory<AccordionWidget>;
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
import type { AdaptWidgetSlots, WidgetPropsSlots, WidgetFactory, WidgetProps, WidgetState } from '../../types';
|
|
2
1
|
export * from '@agnos-ui/core/components/alert';
|
|
3
|
-
export type AlertWidget = AdaptWidgetSlots<import('@agnos-ui/core/components/alert').AlertWidget>;
|
|
4
|
-
export type AlertProps = WidgetProps<AlertWidget>;
|
|
5
|
-
export type AlertState = WidgetState<AlertWidget>;
|
|
6
|
-
export type AlertSlots = WidgetPropsSlots<AlertProps>;
|
|
7
|
-
export declare const createAlert: WidgetFactory<AlertWidget>;
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
import type { AdaptSlotContentProps, AdaptWidgetSlots, WidgetPropsSlots, PropsConfig, WidgetProps, WidgetState } from '../../types';
|
|
2
1
|
export * from '@agnos-ui/core/components/modal';
|
|
3
|
-
export type ModalWidget<Data> = AdaptWidgetSlots<import('@agnos-ui/core/components/modal').ModalWidget<Data>>;
|
|
4
|
-
export type ModalProps<Data> = WidgetProps<ModalWidget<Data>>;
|
|
5
|
-
export type ModalState<Data> = WidgetState<ModalWidget<Data>>;
|
|
6
|
-
export type ModalContext<Data> = AdaptSlotContentProps<import('@agnos-ui/core/components/modal').ModalContext<Data>>;
|
|
7
|
-
export type ModalSlots<Data> = WidgetPropsSlots<ModalProps<Data>>;
|
|
8
|
-
export declare const createModal: <Data>(propsConfig?: PropsConfig<ModalProps<Data>>) => ModalWidget<Data>;
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
import type { AdaptSlotContentProps, AdaptWidgetSlots, WidgetPropsSlots, WidgetFactory, WidgetProps, WidgetState } from '../../types';
|
|
2
1
|
export * from '@agnos-ui/core/components/pagination';
|
|
3
|
-
export type PaginationWidget = AdaptWidgetSlots<import('@agnos-ui/core/components/pagination').PaginationWidget>;
|
|
4
|
-
export type PaginationProps = WidgetProps<PaginationWidget>;
|
|
5
|
-
export type PaginationState = WidgetState<PaginationWidget>;
|
|
6
|
-
export type PaginationContext = AdaptSlotContentProps<import('@agnos-ui/core/components/pagination').PaginationContext>;
|
|
7
|
-
export type PaginationNumberContext = AdaptSlotContentProps<import('@agnos-ui/core/components/pagination').PaginationNumberContext>;
|
|
8
|
-
export type PaginationSlots = WidgetPropsSlots<PaginationProps>;
|
|
9
|
-
export declare const createPagination: WidgetFactory<PaginationWidget>;
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
import type { AdaptWidgetSlots, WidgetPropsSlots, WidgetFactory, WidgetProps, WidgetState } from '../../types';
|
|
2
1
|
export * from '@agnos-ui/core/components/progressbar';
|
|
3
|
-
export type ProgressbarWidget = AdaptWidgetSlots<import('@agnos-ui/core/components/progressbar').ProgressbarWidget>;
|
|
4
|
-
export type ProgressbarProps = WidgetProps<ProgressbarWidget>;
|
|
5
|
-
export type ProgressbarState = WidgetState<ProgressbarWidget>;
|
|
6
|
-
export type ProgressbarSlots = WidgetPropsSlots<ProgressbarProps>;
|
|
7
|
-
export declare const createProgressbar: WidgetFactory<ProgressbarWidget>;
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
import type { AdaptWidgetSlots, WidgetPropsSlots, WidgetFactory, WidgetProps, WidgetState } from '../../types';
|
|
2
1
|
export * from '@agnos-ui/core/components/rating';
|
|
3
|
-
export type RatingWidget = AdaptWidgetSlots<import('@agnos-ui/core/components/rating').RatingWidget>;
|
|
4
|
-
export type RatingProps = WidgetProps<RatingWidget>;
|
|
5
|
-
export type RatingState = WidgetState<RatingWidget>;
|
|
6
|
-
export type RatingSlots = WidgetPropsSlots<RatingProps>;
|
|
7
|
-
export declare const createRating: WidgetFactory<RatingWidget>;
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
import type { AdaptWidgetSlots, WidgetPropsSlots, PropsConfig, WidgetProps, WidgetState } from '../../types';
|
|
2
1
|
export * from '@agnos-ui/core/components/select';
|
|
3
|
-
export type SelectWidget<Item> = AdaptWidgetSlots<import('@agnos-ui/core/components/select').SelectWidget<Item>>;
|
|
4
|
-
export type SelectProps<Item> = WidgetProps<SelectWidget<Item>>;
|
|
5
|
-
export type SelectState<Item> = WidgetState<SelectWidget<Item>>;
|
|
6
|
-
export type SelectSlots<Item> = WidgetPropsSlots<SelectProps<Item>>;
|
|
7
|
-
export declare const createSelect: <Item>(propsConfig?: PropsConfig<SelectProps<Item>>) => SelectWidget<Item>;
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
import type { AdaptWidgetSlots, WidgetPropsSlots, WidgetFactory, WidgetProps, WidgetState } from '../../types';
|
|
2
1
|
export * from '@agnos-ui/core/components/slider';
|
|
3
|
-
export type SliderWidget = AdaptWidgetSlots<import('@agnos-ui/core/components/slider').SliderWidget>;
|
|
4
|
-
export type SliderProps = WidgetProps<SliderWidget>;
|
|
5
|
-
export type SliderState = WidgetState<SliderWidget>;
|
|
6
|
-
export type SliderSlots = WidgetPropsSlots<SliderProps>;
|
|
7
|
-
export declare const createSlider: WidgetFactory<SliderWidget>;
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
import type { AdaptWidgetSlots, WidgetPropsSlots, WidgetFactory, WidgetProps, WidgetState } from '../../types';
|
|
2
1
|
export * from '@agnos-ui/core/components/toast';
|
|
3
|
-
export type ToastWidget = AdaptWidgetSlots<import('@agnos-ui/core/components/toast').ToastWidget>;
|
|
4
|
-
export type ToastProps = WidgetProps<ToastWidget>;
|
|
5
|
-
export type ToastState = WidgetState<ToastWidget>;
|
|
6
|
-
export type ToastSlots = WidgetPropsSlots<ToastProps>;
|
|
7
|
-
export declare const createToast: WidgetFactory<ToastWidget>;
|
package/config.d.ts
CHANGED
|
@@ -10,9 +10,9 @@ type WidgetFactoryInput<Config extends {
|
|
|
10
10
|
}, W extends Widget> = {
|
|
11
11
|
factory: WidgetFactory<W>;
|
|
12
12
|
widgetName?: null | keyof Config;
|
|
13
|
-
$$slots
|
|
13
|
+
$$slots?: SlotsPresent<WidgetProps<W>>;
|
|
14
14
|
defaultConfig?: Partial<WidgetProps<W>> | ReadableSignal<Partial<WidgetProps<W>> | undefined>;
|
|
15
|
-
events
|
|
15
|
+
events?: Pick<WidgetProps<W>, keyof WidgetProps<W> & `on${string}Change`>;
|
|
16
16
|
$$props: Partial<WidgetProps<W>>;
|
|
17
17
|
};
|
|
18
18
|
type AdaptParentConfig<Config> = (config: Partial2Levels<Config>) => Partial2Levels<Config>;
|
package/generated/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './services/siblingsInert';
|
|
|
2
2
|
export * from './services/resizeObserver';
|
|
3
3
|
export * from './services/portal';
|
|
4
4
|
export * from './services/navManager';
|
|
5
|
+
export * from './services/matchMedia';
|
|
5
6
|
export * from './services/intersection';
|
|
6
7
|
export * from './services/hash';
|
|
7
8
|
export * from './services/focustrack';
|
|
@@ -10,7 +11,6 @@ export * from './services/extendWidget';
|
|
|
10
11
|
export * from './services/transitions/simpleClassTransition';
|
|
11
12
|
export * from './services/transitions/cssTransitions';
|
|
12
13
|
export * from './services/transitions/collapse';
|
|
13
|
-
export * from './services/transitions/bootstrap';
|
|
14
14
|
export * from './services/transitions/baseTransitions';
|
|
15
15
|
export * from './utils/writables';
|
|
16
16
|
export * from './utils/stores';
|
package/generated/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from './services/siblingsInert';
|
|
|
2
2
|
export * from './services/resizeObserver';
|
|
3
3
|
export * from './services/portal';
|
|
4
4
|
export * from './services/navManager';
|
|
5
|
+
export * from './services/matchMedia';
|
|
5
6
|
export * from './services/intersection';
|
|
6
7
|
export * from './services/hash';
|
|
7
8
|
export * from './services/focustrack';
|
|
@@ -10,7 +11,6 @@ export * from './services/extendWidget';
|
|
|
10
11
|
export * from './services/transitions/simpleClassTransition';
|
|
11
12
|
export * from './services/transitions/cssTransitions';
|
|
12
13
|
export * from './services/transitions/collapse';
|
|
13
|
-
export * from './services/transitions/bootstrap';
|
|
14
14
|
export * from './services/transitions/baseTransitions';
|
|
15
15
|
export * from './utils/writables';
|
|
16
16
|
export * from './utils/stores';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@agnos-ui/core/services/matchMedia';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@agnos-ui/core/services/matchMedia';
|
package/package.json
CHANGED
|
@@ -1,6 +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
5
|
"type": "module",
|
|
5
6
|
"main": "./index.js",
|
|
6
7
|
"module": "./index.js",
|
|
@@ -48,33 +49,33 @@
|
|
|
48
49
|
}
|
|
49
50
|
},
|
|
50
51
|
"dependencies": {
|
|
51
|
-
"@agnos-ui/core": "0.
|
|
52
|
-
"esm-env": "^1.0.0"
|
|
52
|
+
"@agnos-ui/core": "0.3.1"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@amadeus-it-group/tansu": "*",
|
|
56
56
|
"svelte": "*"
|
|
57
57
|
},
|
|
58
58
|
"sideEffects": false,
|
|
59
|
-
"version": "0.2.0",
|
|
60
59
|
"homepage": "https://amadeusitgroup.github.io/AgnosUI/latest/",
|
|
61
60
|
"bugs": "https://github.com/AmadeusITGroup/AgnosUI/issues",
|
|
62
61
|
"license": "MIT",
|
|
63
62
|
"repository": {
|
|
64
63
|
"type": "git",
|
|
65
|
-
"url": "https://github.com/AmadeusITGroup/AgnosUI.git",
|
|
64
|
+
"url": "git+https://github.com/AmadeusITGroup/AgnosUI.git",
|
|
66
65
|
"directory": "svelte/headless"
|
|
67
66
|
},
|
|
68
67
|
"keywords": [
|
|
69
68
|
"svelte",
|
|
70
|
-
"
|
|
71
|
-
"components",
|
|
72
|
-
"widgets",
|
|
69
|
+
"AgnosUI",
|
|
73
70
|
"accordion",
|
|
74
71
|
"alert",
|
|
72
|
+
"components",
|
|
75
73
|
"modal",
|
|
76
74
|
"pagination",
|
|
75
|
+
"progressbar",
|
|
77
76
|
"rating",
|
|
78
|
-
"slider"
|
|
77
|
+
"slider",
|
|
78
|
+
"toast",
|
|
79
|
+
"widgets"
|
|
79
80
|
]
|
|
80
81
|
}
|
package/types.d.ts
CHANGED
|
@@ -18,3 +18,4 @@ export type AdaptWidgetFactories<T> = {
|
|
|
18
18
|
[K in keyof T]: T[K] extends WidgetFactory<infer U> ? WidgetFactory<AdaptWidgetSlots<U>> : T[K];
|
|
19
19
|
};
|
|
20
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.d.ts
CHANGED
|
@@ -14,13 +14,13 @@ import type { SlotContent, SlotSvelteComponent, SlotsPresent, WidgetFactory, Wid
|
|
|
14
14
|
*/
|
|
15
15
|
export declare const callWidgetFactoryWithConfig: <W extends Widget>({ factory, $$slots, defaultConfig, widgetConfig, events, $$props, }: {
|
|
16
16
|
factory: WidgetFactory<W>;
|
|
17
|
-
$$slots
|
|
18
|
-
defaultConfig?:
|
|
19
|
-
widgetConfig?:
|
|
20
|
-
events
|
|
21
|
-
$$props: WidgetProps<W
|
|
17
|
+
$$slots?: SlotsPresent<WidgetProps<W>>;
|
|
18
|
+
defaultConfig?: Partial<WidgetProps<W>> | ReadableSignal<Partial<WidgetProps<W>> | undefined>;
|
|
19
|
+
widgetConfig?: null | undefined | ReadableSignal<Partial<WidgetProps<W>> | undefined>;
|
|
20
|
+
events?: Pick<WidgetProps<W>, keyof WidgetProps<W> & `on${string}Change`>;
|
|
21
|
+
$$props: Partial<WidgetProps<W>>;
|
|
22
22
|
}) => W & {
|
|
23
|
-
patchChangedProps: W[
|
|
23
|
+
patchChangedProps: W['patch'];
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
26
26
|
* A type guard checking if a provided slot content is a Svelte component.
|
|
@@ -28,4 +28,4 @@ export declare const callWidgetFactoryWithConfig: <W extends Widget>({ factory,
|
|
|
28
28
|
* @param content - the slot content
|
|
29
29
|
* @returns true if the slot content is a svelte component
|
|
30
30
|
*/
|
|
31
|
-
export declare const isSvelteComponent: <Props extends object>(content:
|
|
31
|
+
export declare const isSvelteComponent: <Props extends object>(content: SlotContent<Props>) => content is SlotSvelteComponent<Props>;
|
package/utils/widget.js
CHANGED
|
@@ -51,14 +51,18 @@ const eventStore = (event, prop) => {
|
|
|
51
51
|
export const callWidgetFactoryWithConfig = ({ factory, $$slots, defaultConfig, widgetConfig, events, $$props, }) => {
|
|
52
52
|
const defaultConfig$ = toReadableStore(defaultConfig);
|
|
53
53
|
const processedSlots = {};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
if ($$slots) {
|
|
55
|
+
for (const [name, present] of Object.entries($$slots)) {
|
|
56
|
+
if (present) {
|
|
57
|
+
processedSlots[`slot${name[0].toUpperCase()}${name.substring(1)}`] = useSvelteSlot;
|
|
58
|
+
}
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
61
|
const props = { ...$$props };
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
if (events) {
|
|
63
|
+
for (const event of Object.keys(events)) {
|
|
64
|
+
props[event] = eventStore(events[event], $$props[event]);
|
|
65
|
+
}
|
|
62
66
|
}
|
|
63
67
|
const widget = factory({
|
|
64
68
|
config: computed(() => ({ ...defaultConfig$(), ...widgetConfig?.(), ...processedSlots })),
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@agnos-ui/core/services/transitions/bootstrap';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@agnos-ui/core/services/transitions/bootstrap';
|