@samline/drawer 2.0.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.
Files changed (37) hide show
  1. package/LICENSE.md +22 -0
  2. package/README.md +66 -0
  3. package/dist/browser/components-client-BC8MrVsa.mjs +2107 -0
  4. package/dist/browser/components-client-BHUFVfXB.js +2133 -0
  5. package/dist/browser/index.cjs +29211 -0
  6. package/dist/browser/index.d.mts +25 -0
  7. package/dist/browser/index.d.ts +25 -0
  8. package/dist/browser/index.js +29213 -0
  9. package/dist/browser/index.mjs +29201 -0
  10. package/dist/components-client-BC8MrVsa.mjs +2107 -0
  11. package/dist/components-client-BHUFVfXB.js +2133 -0
  12. package/dist/core/index.d.mts +56 -0
  13. package/dist/core/index.d.ts +56 -0
  14. package/dist/core/index.js +69 -0
  15. package/dist/core/index.mjs +67 -0
  16. package/dist/index.d.mts +41 -0
  17. package/dist/index.d.ts +41 -0
  18. package/dist/index.js +29190 -0
  19. package/dist/index.mjs +29180 -0
  20. package/dist/react/index.d.mts +146 -0
  21. package/dist/react/index.d.ts +146 -0
  22. package/dist/react/index.js +2719 -0
  23. package/dist/react/index.mjs +2678 -0
  24. package/dist/style.css +256 -0
  25. package/dist/svelte/components-client-BC8MrVsa.mjs +2107 -0
  26. package/dist/svelte/components-client-BHUFVfXB.js +2133 -0
  27. package/dist/svelte/index.d.mts +13 -0
  28. package/dist/svelte/index.d.ts +13 -0
  29. package/dist/svelte/index.js +29226 -0
  30. package/dist/svelte/index.mjs +29216 -0
  31. package/dist/vue/components-client-BHUFVfXB.js +2133 -0
  32. package/dist/vue/components-client-rq_o2zwK.mjs +2107 -0
  33. package/dist/vue/index.d.mts +107 -0
  34. package/dist/vue/index.d.ts +107 -0
  35. package/dist/vue/index.js +29359 -0
  36. package/dist/vue/index.mjs +29351 -0
  37. package/package.json +151 -0
@@ -0,0 +1,56 @@
1
+ type CommonDrawerDirection = 'top' | 'bottom' | 'left' | 'right';
2
+ type CommonDrawerSnapPoint = number | string;
3
+ type CommonDrawerId = string;
4
+ interface CommonDrawerOptions {
5
+ id?: CommonDrawerId;
6
+ parentId?: CommonDrawerId;
7
+ open?: boolean;
8
+ defaultOpen?: boolean;
9
+ onOpenChange?: (open: boolean) => void;
10
+ onClose?: () => void;
11
+ onAnimationEnd?: (open: boolean) => void;
12
+ onDragChange?: (percentageDragged: number) => void;
13
+ onReleaseChange?: (open: boolean) => void;
14
+ dismissible?: boolean;
15
+ modal?: boolean;
16
+ nested?: boolean;
17
+ direction?: CommonDrawerDirection;
18
+ snapPoints?: CommonDrawerSnapPoint[];
19
+ fadeFromIndex?: number;
20
+ activeSnapPoint?: CommonDrawerSnapPoint | null;
21
+ closeThreshold?: number;
22
+ scrollLockTimeout?: number;
23
+ shouldScaleBackground?: boolean;
24
+ setBackgroundColorOnScale?: boolean;
25
+ handleOnly?: boolean;
26
+ fixed?: boolean;
27
+ disablePreventScroll?: boolean;
28
+ repositionInputs?: boolean;
29
+ snapToSequentialPoint?: boolean;
30
+ preventScrollRestoration?: boolean;
31
+ noBodyStyles?: boolean;
32
+ autoFocus?: boolean;
33
+ }
34
+ interface CommonDrawerState {
35
+ isOpen: boolean;
36
+ activeSnapPoint: CommonDrawerSnapPoint | null;
37
+ direction: CommonDrawerDirection;
38
+ snapPoints: CommonDrawerSnapPoint[];
39
+ dismissible: boolean;
40
+ modal: boolean;
41
+ }
42
+ interface CommonDrawerSnapshot {
43
+ options: CommonDrawerOptions;
44
+ state: CommonDrawerState;
45
+ }
46
+ interface CommonDrawerController {
47
+ getSnapshot: () => CommonDrawerSnapshot;
48
+ setOpen: (open: boolean) => CommonDrawerSnapshot;
49
+ setActiveSnapPoint: (snapPoint: CommonDrawerSnapPoint | null) => CommonDrawerSnapshot;
50
+ patch: (options: Partial<CommonDrawerOptions>) => CommonDrawerSnapshot;
51
+ subscribe: (listener: (snapshot: CommonDrawerSnapshot) => void) => () => void;
52
+ }
53
+ declare function createDrawerController(initialOptions?: CommonDrawerOptions): CommonDrawerController;
54
+
55
+ export { createDrawerController };
56
+ export type { CommonDrawerController, CommonDrawerDirection, CommonDrawerId, CommonDrawerOptions, CommonDrawerSnapPoint, CommonDrawerSnapshot, CommonDrawerState };
@@ -0,0 +1,56 @@
1
+ type CommonDrawerDirection = 'top' | 'bottom' | 'left' | 'right';
2
+ type CommonDrawerSnapPoint = number | string;
3
+ type CommonDrawerId = string;
4
+ interface CommonDrawerOptions {
5
+ id?: CommonDrawerId;
6
+ parentId?: CommonDrawerId;
7
+ open?: boolean;
8
+ defaultOpen?: boolean;
9
+ onOpenChange?: (open: boolean) => void;
10
+ onClose?: () => void;
11
+ onAnimationEnd?: (open: boolean) => void;
12
+ onDragChange?: (percentageDragged: number) => void;
13
+ onReleaseChange?: (open: boolean) => void;
14
+ dismissible?: boolean;
15
+ modal?: boolean;
16
+ nested?: boolean;
17
+ direction?: CommonDrawerDirection;
18
+ snapPoints?: CommonDrawerSnapPoint[];
19
+ fadeFromIndex?: number;
20
+ activeSnapPoint?: CommonDrawerSnapPoint | null;
21
+ closeThreshold?: number;
22
+ scrollLockTimeout?: number;
23
+ shouldScaleBackground?: boolean;
24
+ setBackgroundColorOnScale?: boolean;
25
+ handleOnly?: boolean;
26
+ fixed?: boolean;
27
+ disablePreventScroll?: boolean;
28
+ repositionInputs?: boolean;
29
+ snapToSequentialPoint?: boolean;
30
+ preventScrollRestoration?: boolean;
31
+ noBodyStyles?: boolean;
32
+ autoFocus?: boolean;
33
+ }
34
+ interface CommonDrawerState {
35
+ isOpen: boolean;
36
+ activeSnapPoint: CommonDrawerSnapPoint | null;
37
+ direction: CommonDrawerDirection;
38
+ snapPoints: CommonDrawerSnapPoint[];
39
+ dismissible: boolean;
40
+ modal: boolean;
41
+ }
42
+ interface CommonDrawerSnapshot {
43
+ options: CommonDrawerOptions;
44
+ state: CommonDrawerState;
45
+ }
46
+ interface CommonDrawerController {
47
+ getSnapshot: () => CommonDrawerSnapshot;
48
+ setOpen: (open: boolean) => CommonDrawerSnapshot;
49
+ setActiveSnapPoint: (snapPoint: CommonDrawerSnapPoint | null) => CommonDrawerSnapshot;
50
+ patch: (options: Partial<CommonDrawerOptions>) => CommonDrawerSnapshot;
51
+ subscribe: (listener: (snapshot: CommonDrawerSnapshot) => void) => () => void;
52
+ }
53
+ declare function createDrawerController(initialOptions?: CommonDrawerOptions): CommonDrawerController;
54
+
55
+ export { createDrawerController };
56
+ export type { CommonDrawerController, CommonDrawerDirection, CommonDrawerId, CommonDrawerOptions, CommonDrawerSnapPoint, CommonDrawerSnapshot, CommonDrawerState };
@@ -0,0 +1,69 @@
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+
3
+ const DEFAULT_OPTIONS = {
4
+ direction: 'bottom',
5
+ dismissible: true,
6
+ modal: true
7
+ };
8
+ function toSnapshot(options) {
9
+ var _options_open, _ref, _options_activeSnapPoint, _options_direction, _options_snapPoints, _options_dismissible, _options_modal;
10
+ var _options_snapPoints1;
11
+ return {
12
+ options,
13
+ state: {
14
+ isOpen: Boolean((_options_open = options.open) != null ? _options_open : options.defaultOpen),
15
+ activeSnapPoint: (_ref = (_options_activeSnapPoint = options.activeSnapPoint) != null ? _options_activeSnapPoint : (_options_snapPoints1 = options.snapPoints) == null ? void 0 : _options_snapPoints1[0]) != null ? _ref : null,
16
+ direction: (_options_direction = options.direction) != null ? _options_direction : DEFAULT_OPTIONS.direction,
17
+ snapPoints: (_options_snapPoints = options.snapPoints) != null ? _options_snapPoints : [],
18
+ dismissible: (_options_dismissible = options.dismissible) != null ? _options_dismissible : DEFAULT_OPTIONS.dismissible,
19
+ modal: (_options_modal = options.modal) != null ? _options_modal : DEFAULT_OPTIONS.modal
20
+ }
21
+ };
22
+ }
23
+ function createDrawerController(initialOptions = {}) {
24
+ let options = {
25
+ ...initialOptions
26
+ };
27
+ let snapshot = toSnapshot(options);
28
+ const listeners = new Set();
29
+ function publish() {
30
+ snapshot = toSnapshot(options);
31
+ listeners.forEach((listener)=>listener(snapshot));
32
+ return snapshot;
33
+ }
34
+ return {
35
+ getSnapshot () {
36
+ return snapshot;
37
+ },
38
+ setOpen (open) {
39
+ options = {
40
+ ...options,
41
+ open
42
+ };
43
+ return publish();
44
+ },
45
+ setActiveSnapPoint (activeSnapPoint) {
46
+ options = {
47
+ ...options,
48
+ activeSnapPoint
49
+ };
50
+ return publish();
51
+ },
52
+ patch (nextOptions) {
53
+ options = {
54
+ ...options,
55
+ ...nextOptions
56
+ };
57
+ return publish();
58
+ },
59
+ subscribe (listener) {
60
+ listeners.add(listener);
61
+ listener(snapshot);
62
+ return ()=>{
63
+ listeners.delete(listener);
64
+ };
65
+ }
66
+ };
67
+ }
68
+
69
+ exports.createDrawerController = createDrawerController;
@@ -0,0 +1,67 @@
1
+ const DEFAULT_OPTIONS = {
2
+ direction: 'bottom',
3
+ dismissible: true,
4
+ modal: true
5
+ };
6
+ function toSnapshot(options) {
7
+ var _options_open, _ref, _options_activeSnapPoint, _options_direction, _options_snapPoints, _options_dismissible, _options_modal;
8
+ var _options_snapPoints1;
9
+ return {
10
+ options,
11
+ state: {
12
+ isOpen: Boolean((_options_open = options.open) != null ? _options_open : options.defaultOpen),
13
+ activeSnapPoint: (_ref = (_options_activeSnapPoint = options.activeSnapPoint) != null ? _options_activeSnapPoint : (_options_snapPoints1 = options.snapPoints) == null ? void 0 : _options_snapPoints1[0]) != null ? _ref : null,
14
+ direction: (_options_direction = options.direction) != null ? _options_direction : DEFAULT_OPTIONS.direction,
15
+ snapPoints: (_options_snapPoints = options.snapPoints) != null ? _options_snapPoints : [],
16
+ dismissible: (_options_dismissible = options.dismissible) != null ? _options_dismissible : DEFAULT_OPTIONS.dismissible,
17
+ modal: (_options_modal = options.modal) != null ? _options_modal : DEFAULT_OPTIONS.modal
18
+ }
19
+ };
20
+ }
21
+ function createDrawerController(initialOptions = {}) {
22
+ let options = {
23
+ ...initialOptions
24
+ };
25
+ let snapshot = toSnapshot(options);
26
+ const listeners = new Set();
27
+ function publish() {
28
+ snapshot = toSnapshot(options);
29
+ listeners.forEach((listener)=>listener(snapshot));
30
+ return snapshot;
31
+ }
32
+ return {
33
+ getSnapshot () {
34
+ return snapshot;
35
+ },
36
+ setOpen (open) {
37
+ options = {
38
+ ...options,
39
+ open
40
+ };
41
+ return publish();
42
+ },
43
+ setActiveSnapPoint (activeSnapPoint) {
44
+ options = {
45
+ ...options,
46
+ activeSnapPoint
47
+ };
48
+ return publish();
49
+ },
50
+ patch (nextOptions) {
51
+ options = {
52
+ ...options,
53
+ ...nextOptions
54
+ };
55
+ return publish();
56
+ },
57
+ subscribe (listener) {
58
+ listeners.add(listener);
59
+ listener(snapshot);
60
+ return ()=>{
61
+ listeners.delete(listener);
62
+ };
63
+ }
64
+ };
65
+ }
66
+
67
+ export { createDrawerController };
@@ -0,0 +1,41 @@
1
+ import { CommonDrawerOptions, CommonDrawerController, CommonDrawerId } from './core/index.mjs';
2
+ export { CommonDrawerController, CommonDrawerDirection, CommonDrawerId, CommonDrawerOptions, CommonDrawerSnapPoint, CommonDrawerSnapshot, createDrawerController } from './core/index.mjs';
3
+
4
+ type VanillaRenderable = string | number | HTMLElement | (() => HTMLElement) | null | undefined;
5
+ interface VanillaDrawerOptions extends CommonDrawerOptions {
6
+ mountElement?: HTMLElement | null;
7
+ triggerElement?: HTMLElement | null;
8
+ triggerText?: string;
9
+ showHandle?: boolean;
10
+ handleClassName?: string;
11
+ title?: VanillaRenderable;
12
+ description?: VanillaRenderable;
13
+ content?: VanillaRenderable;
14
+ overlayClassName?: string;
15
+ contentClassName?: string;
16
+ }
17
+
18
+ interface VanillaDrawerController extends CommonDrawerController {
19
+ id: CommonDrawerId;
20
+ element: HTMLElement | null;
21
+ options: VanillaDrawerOptions;
22
+ update: (options?: VanillaDrawerOptions) => VanillaDrawerController;
23
+ destroy: () => void;
24
+ }
25
+ declare function createDrawer(options?: VanillaDrawerOptions): VanillaDrawerController;
26
+ declare function configureDrawer(options?: VanillaDrawerOptions): VanillaDrawerController;
27
+ declare function getDrawer(id?: CommonDrawerId | null): VanillaDrawerController | null;
28
+ declare function getDrawers(): {
29
+ [k: string]: VanillaDrawerController;
30
+ };
31
+ declare function getParentDrawer(id?: CommonDrawerId | null): VanillaDrawerController | null;
32
+ declare function getChildDrawers(id?: CommonDrawerId | null): VanillaDrawerController[];
33
+ declare function updateDrawer(idOrOptions?: CommonDrawerId | VanillaDrawerOptions | null, options?: VanillaDrawerOptions): VanillaDrawerController;
34
+ declare function openDrawer(id?: CommonDrawerId | null): VanillaDrawerController;
35
+ declare function closeDrawer(id?: CommonDrawerId | null): VanillaDrawerController;
36
+ declare function toggleDrawer(id?: CommonDrawerId | null): VanillaDrawerController;
37
+ declare function destroyDrawer(id?: CommonDrawerId | null): void;
38
+ declare function destroyDrawers(): void;
39
+
40
+ export { closeDrawer, configureDrawer, createDrawer, destroyDrawer, destroyDrawers, getChildDrawers, getDrawer, getDrawers, getParentDrawer, openDrawer, toggleDrawer, updateDrawer };
41
+ export type { VanillaDrawerController, VanillaDrawerOptions, VanillaRenderable };
@@ -0,0 +1,41 @@
1
+ import { CommonDrawerOptions, CommonDrawerController, CommonDrawerId } from './core/index.js';
2
+ export { CommonDrawerController, CommonDrawerDirection, CommonDrawerId, CommonDrawerOptions, CommonDrawerSnapPoint, CommonDrawerSnapshot, createDrawerController } from './core/index.js';
3
+
4
+ type VanillaRenderable = string | number | HTMLElement | (() => HTMLElement) | null | undefined;
5
+ interface VanillaDrawerOptions extends CommonDrawerOptions {
6
+ mountElement?: HTMLElement | null;
7
+ triggerElement?: HTMLElement | null;
8
+ triggerText?: string;
9
+ showHandle?: boolean;
10
+ handleClassName?: string;
11
+ title?: VanillaRenderable;
12
+ description?: VanillaRenderable;
13
+ content?: VanillaRenderable;
14
+ overlayClassName?: string;
15
+ contentClassName?: string;
16
+ }
17
+
18
+ interface VanillaDrawerController extends CommonDrawerController {
19
+ id: CommonDrawerId;
20
+ element: HTMLElement | null;
21
+ options: VanillaDrawerOptions;
22
+ update: (options?: VanillaDrawerOptions) => VanillaDrawerController;
23
+ destroy: () => void;
24
+ }
25
+ declare function createDrawer(options?: VanillaDrawerOptions): VanillaDrawerController;
26
+ declare function configureDrawer(options?: VanillaDrawerOptions): VanillaDrawerController;
27
+ declare function getDrawer(id?: CommonDrawerId | null): VanillaDrawerController | null;
28
+ declare function getDrawers(): {
29
+ [k: string]: VanillaDrawerController;
30
+ };
31
+ declare function getParentDrawer(id?: CommonDrawerId | null): VanillaDrawerController | null;
32
+ declare function getChildDrawers(id?: CommonDrawerId | null): VanillaDrawerController[];
33
+ declare function updateDrawer(idOrOptions?: CommonDrawerId | VanillaDrawerOptions | null, options?: VanillaDrawerOptions): VanillaDrawerController;
34
+ declare function openDrawer(id?: CommonDrawerId | null): VanillaDrawerController;
35
+ declare function closeDrawer(id?: CommonDrawerId | null): VanillaDrawerController;
36
+ declare function toggleDrawer(id?: CommonDrawerId | null): VanillaDrawerController;
37
+ declare function destroyDrawer(id?: CommonDrawerId | null): void;
38
+ declare function destroyDrawers(): void;
39
+
40
+ export { closeDrawer, configureDrawer, createDrawer, destroyDrawer, destroyDrawers, getChildDrawers, getDrawer, getDrawers, getParentDrawer, openDrawer, toggleDrawer, updateDrawer };
41
+ export type { VanillaDrawerController, VanillaDrawerOptions, VanillaRenderable };