@splendidlabz/svelte 4.3.1 → 4.5.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 (88) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/components/Breadcrumbs/Breadcrumbs.svelte +10 -9
  3. package/components/Breadcrumbs/Crumb.svelte +2 -1
  4. package/components/ContentList/ContentList.svelte +1 -1
  5. package/components/Disclosure/Disclosure/DisclosureContent.svelte +6 -8
  6. package/components/Disclosure/Disclosure/DisclosureTrigger.svelte +34 -9
  7. package/components/Disclosure/Disclosure/disclosure.svelte.js +61 -79
  8. package/components/Disclosure/Drawer/DrawerCloseButton.svelte +14 -30
  9. package/components/Disclosure/Drawer/DrawerContent.svelte +58 -74
  10. package/components/Disclosure/Drawer/DrawerTrigger.svelte +13 -6
  11. package/components/Disclosure/Drawer/drawer.js +3 -27
  12. package/components/Disclosure/Drawer/index.js +6 -2
  13. package/components/Disclosure/Modal/ModalContent.svelte +122 -32
  14. package/components/Disclosure/Modal/ModalTrigger.svelte +63 -6
  15. package/components/Disclosure/Modal/index.js +2 -2
  16. package/components/Disclosure/Popover/PopoverContent.svelte +109 -97
  17. package/components/Disclosure/Popover/PopoverTrigger.svelte +67 -22
  18. package/components/Disclosure/Popover/floating.js +278 -117
  19. package/components/Disclosure/Popover/index.js +3 -2
  20. package/components/Disclosure/index.js +3 -7
  21. package/components/Disclosure/shared.js +1 -0
  22. package/components/DisclosureOld/Drawer/DrawerCloseButton.svelte +37 -0
  23. package/components/DisclosureOld/Drawer/DrawerContent.svelte +92 -0
  24. package/components/DisclosureOld/Drawer/DrawerTrigger.svelte +11 -0
  25. package/components/{Disclosure/DrawerNew → DisclosureOld/Drawer}/drawer.js +0 -26
  26. package/components/{Disclosure/DrawerNew → DisclosureOld/Drawer}/index.js +2 -6
  27. package/components/DisclosureOld/Modal/ModalContent.svelte +42 -0
  28. package/components/DisclosureOld/Modal/ModalTrigger.svelte +11 -0
  29. package/components/DisclosureOld/Modal/index.js +5 -0
  30. package/components/DisclosureOld/Old/DisclosureContentOld.svelte +97 -0
  31. package/components/DisclosureOld/Old/DisclosureTriggerOld.svelte +51 -0
  32. package/components/{Disclosure → DisclosureOld}/Popover/PopoverCloseButton.svelte +4 -1
  33. package/components/DisclosureOld/Popover/PopoverContent.svelte +107 -0
  34. package/components/DisclosureOld/Popover/PopoverTrigger.svelte +33 -0
  35. package/components/DisclosureOld/Popover/floating.js +171 -0
  36. package/components/DisclosureOld/Popover/index.js +5 -0
  37. package/components/{Disclosure → DisclosureOld}/Tooltip/TooltipTrigger.svelte +1 -1
  38. package/components/{Disclosure → DisclosureOld}/disclosure.js +44 -40
  39. package/components/Form/Combobox/AutocompleteInput.svelte +3 -3
  40. package/components/Form/Combobox/AutocompleteOptions.svelte +5 -5
  41. package/components/Form/Combobox/TimepickerInput.svelte +7 -7
  42. package/components/Form/Combobox/TimepickerOptions.svelte +7 -7
  43. package/components/Form/Combobox/autocomplete.js +2 -2
  44. package/components/Form/Combobox/combobox.js +2 -2
  45. package/components/SVG/SVG.svelte +46 -0
  46. package/components/SVG/SVGGradient.svelte +37 -0
  47. package/components/SVG/index.js +2 -1
  48. package/package.json +3 -3
  49. package/actions/resize-observer.js +0 -43
  50. package/actions/scroll-observer.js +0 -47
  51. package/components/Disclosure/Disclosure/disclosure-popover.svelte.js +0 -7
  52. package/components/Disclosure/DisclosureNew/DisclosureCloseButton.svelte +0 -38
  53. package/components/Disclosure/DisclosureNew/DisclosureContent.svelte +0 -53
  54. package/components/Disclosure/DisclosureNew/DisclosureTrigger.svelte +0 -79
  55. package/components/Disclosure/DisclosureNew/disclosures.svelte.js +0 -55
  56. package/components/Disclosure/DisclosureNew/index.js +0 -5
  57. package/components/Disclosure/Drawer/DrawerNew.svelte +0 -0
  58. package/components/Disclosure/DrawerNew/DrawerCloseButton.svelte +0 -21
  59. package/components/Disclosure/DrawerNew/DrawerContent.svelte +0 -45
  60. package/components/Disclosure/DrawerNew/DrawerTrigger.svelte +0 -15
  61. package/components/Disclosure/ModalNew/ModalContent.svelte +0 -132
  62. package/components/Disclosure/ModalNew/ModalTrigger.svelte +0 -68
  63. package/components/Disclosure/ModalNew/index.js +0 -5
  64. package/components/Disclosure/PopoverNew/PopoverContent.svelte +0 -119
  65. package/components/Disclosure/PopoverNew/PopoverTrigger.svelte +0 -77
  66. package/components/Disclosure/PopoverNew/floating.js +0 -332
  67. package/components/Disclosure/PopoverNew/index.js +0 -6
  68. package/components/Disclosure/state.svelte.js +0 -138
  69. /package/components/Disclosure/{ModalNew → Modal}/ModalClose.svelte +0 -0
  70. /package/components/Disclosure/{PopoverNew → Popover}/Popover.svelte +0 -0
  71. /package/components/Disclosure/{PopoverNew → Popover}/PopoverClose.svelte +0 -0
  72. /package/components/{Disclosure → DisclosureOld}/Drawer/Drawer.svelte +0 -0
  73. /package/components/{Disclosure → DisclosureOld}/Dropdown/DropdownContent.svelte +0 -0
  74. /package/components/{Disclosure → DisclosureOld}/Dropdown/DropdownTrigger.svelte +0 -0
  75. /package/components/{Disclosure → DisclosureOld}/Dropdown/dropdown.js +0 -0
  76. /package/components/{Disclosure → DisclosureOld}/Dropdown/index.js +0 -0
  77. /package/components/{Disclosure → DisclosureOld}/Modal/Modal.svelte +0 -0
  78. /package/components/{Disclosure → DisclosureOld}/Modal/ModalCloseButton.svelte +0 -0
  79. /package/components/{Disclosure → DisclosureOld}/Modal/exit-intent.js +0 -0
  80. /package/components/{Disclosure → DisclosureOld}/Modal/modal.js +0 -0
  81. /package/components/{Disclosure → DisclosureOld}/Popover/popover.js +0 -0
  82. /package/components/{Disclosure → DisclosureOld}/Popover/references/FollowTheMouse.svelte +0 -0
  83. /package/components/{Disclosure → DisclosureOld}/Tooltip/Tooltip.svelte +0 -0
  84. /package/components/{Disclosure → DisclosureOld}/Tooltip/TooltipContent.svelte +0 -0
  85. /package/components/{Disclosure → DisclosureOld}/Tooltip/index.js +0 -0
  86. /package/components/{Disclosure → DisclosureOld}/Tooltip/tooltip.js +0 -0
  87. /package/components/{Disclosure → DisclosureOld}/disclosure-store.js +0 -0
  88. /package/components/{Disclosure → DisclosureOld}/disclosure.svelte.js +0 -0
@@ -0,0 +1,42 @@
1
+ <script>
2
+ import { splitObject } from '@splendidlabz/utils'
3
+ import { mergeOpts } from '../../../utils'
4
+ import {
5
+ TRANSITION_OPT_KEYS,
6
+ applyTransition,
7
+ } from '../../../utils/transitions.js'
8
+ import DisclosureContent from '../Disclosure/DisclosureContent.svelte'
9
+ import { MODAL_CONTENT_OPTS } from './modal.js'
10
+
11
+ let { ref = $bindable(null), ...p } = $props()
12
+ const opts = mergeOpts(MODAL_CONTENT_OPTS, p)
13
+
14
+ const {
15
+ class: klass = '',
16
+ backdrop,
17
+ backdropClass,
18
+ blurBackdrop,
19
+ ...rest
20
+ } = opts
21
+
22
+ const { picked: transitionOpts } = splitObject(rest, TRANSITION_OPT_KEYS)
23
+ </script>
24
+
25
+ {#snippet modalBackdrop()}
26
+ <div
27
+ class="modal-backdrop {backdropClass} "
28
+ class:backdrop-blur={backdrop && blurBackdrop}
29
+ transition:applyTransition|global={{
30
+ ...transitionOpts,
31
+ transition: 'fade',
32
+ }}
33
+ >
34
+ {@render modalContent()}
35
+ </div>
36
+ {/snippet}
37
+
38
+ {#snippet modalContent()}
39
+ <DisclosureContent class="modal-content {klass}" bind:ref {...rest} />
40
+ {/snippet}
41
+
42
+ {@render modalBackdrop()}
@@ -0,0 +1,11 @@
1
+ <script>
2
+ import DisclosureTrigger from '../Disclosure/DisclosureTrigger.svelte'
3
+
4
+ const { class: klass = '', ...rest } = $props()
5
+ </script>
6
+
7
+ <DisclosureTrigger
8
+ {...rest}
9
+ componentName="ModalTrigger"
10
+ class="modal-trigger {klass}"
11
+ />
@@ -0,0 +1,5 @@
1
+ import ModalCloseButton from './ModalCloseButton.svelte'
2
+ import ModalContent from './ModalContent.svelte'
3
+ import ModalTrigger from './ModalTrigger.svelte'
4
+
5
+ export { ModalCloseButton, ModalContent, ModalTrigger }
@@ -0,0 +1,97 @@
1
+ <script>
2
+ import { splitObject } from '@splendidlabz/utils'
3
+ import {
4
+ hasAccessibleName,
5
+ markActiveAnchorIn,
6
+ scrollToElement,
7
+ } from '@splendidlabz/utils/dom'
8
+ import {
9
+ TRANSITION_OPT_KEYS,
10
+ applyTransition,
11
+ } from '../../../utils/transitions.js'
12
+ import Portal from '../../Portal.svelte'
13
+ import {
14
+ DISCLOSURE_CONTENT_OPT_KEYS,
15
+ disclosureContent,
16
+ getDisclosure,
17
+ } from '../disclosure.svelte.js'
18
+
19
+ let { ref = $bindable(null), ...p } = $props()
20
+
21
+ const {
22
+ class: klass,
23
+ id,
24
+ role = 'dialog',
25
+ 'aria-label': ariaLabel,
26
+ 'aria-labelledBy': ariaLabelledBy,
27
+ 'aria-describedby': ariaDescribedBy,
28
+ componentName = 'DisclosureContent',
29
+ portal = true,
30
+ scrollToAnchor = false,
31
+
32
+ // Slots
33
+ children,
34
+
35
+ // Event handlers are spread directly into ...rest
36
+ // Custom events are onopen and onclose
37
+ ...restProps
38
+ } = p
39
+
40
+ const { picked: disclosureContentOpts, omitted: rest } = splitObject(
41
+ restProps,
42
+ DISCLOSURE_CONTENT_OPT_KEYS,
43
+ )
44
+
45
+ const { picked: transitionOpts, omitted: remaining } = splitObject(
46
+ rest,
47
+ TRANSITION_OPT_KEYS,
48
+ )
49
+
50
+ if (!id) throw new Error(`${componentName} requires an id`)
51
+
52
+ // Accessible name warning
53
+ if (role === 'dialog' && !hasAccessibleName(ariaLabel, ariaLabelledBy)) {
54
+ console.warn(
55
+ `DrawerContent (with id: ${id}) is a dialog and should have an accessible name. Please create one with aria-label or aria-labelledby.`,
56
+ )
57
+ }
58
+
59
+ let d = $derived(getDisclosure(id))
60
+ let show = $derived(d?.state.show)
61
+
62
+ $effect(_ => {
63
+ if (show && ref && scrollToAnchor) {
64
+ const anchor = markActiveAnchorIn(ref)
65
+ scrollToElement(anchor)
66
+ }
67
+ })
68
+ </script>
69
+
70
+ <!-- Snippets -->
71
+ {#snippet dc()}
72
+ <div
73
+ {...remaining}
74
+ {id}
75
+ class="disclosure-content {klass}"
76
+ {role}
77
+ bind:this={ref}
78
+ use:disclosureContent={{ options: disclosureContentOpts }}
79
+ aria-label={ariaLabel}
80
+ aria-labelledby={ariaLabelledBy}
81
+ aria-describedby={ariaDescribedBy}
82
+ transition:applyTransition|global={transitionOpts}
83
+ >
84
+ {#if children}
85
+ {@render children()}
86
+ {/if}
87
+ </div>
88
+ {/snippet}
89
+
90
+ <!-- Render -->
91
+ {#if show}
92
+ {#if portal}
93
+ <Portal>{@render dc()}</Portal>
94
+ {:else}
95
+ {@render dc()}
96
+ {/if}
97
+ {/if}
@@ -0,0 +1,51 @@
1
+ <script>
2
+ import { splitObject } from '@splendidlabz/utils'
3
+ import Icon from '../../Icon/Icon.svelte'
4
+ import {
5
+ DISCLOSURE_TRIGGER_OPT_KEYS,
6
+ disclosureTrigger,
7
+ } from '../disclosure.svelte.js'
8
+
9
+ let { show = $bindable(false), ...p } = $props()
10
+
11
+ const {
12
+ class: klass = '',
13
+ componentName = 'DisclosureTrigger',
14
+ icon = 'tabler:menu',
15
+ iconClass,
16
+ 'aria-haspopup': ariaHasPopup = 'dialog',
17
+ target,
18
+
19
+ // Slots
20
+ children,
21
+ ...restProps
22
+ } = p
23
+
24
+ const { picked: triggerOpts, omitted: rest } = splitObject(
25
+ restProps,
26
+ DISCLOSURE_TRIGGER_OPT_KEYS,
27
+ )
28
+
29
+ if (!target)
30
+ throw new Error(`${componentName} must contain a target property`)
31
+
32
+ // TODO: Test creating an IconSnippet to render the icon vs contents
33
+ // <script module> currently breaks when prettier is enabled. So, ¯\_(ツ)_/¯ if we can ever do that.
34
+ </script>
35
+
36
+ <button
37
+ {...rest}
38
+ {target}
39
+ class="button {klass}"
40
+ aria-haspopup={ariaHasPopup}
41
+ use:disclosureTrigger={{
42
+ state: { show },
43
+ options: triggerOpts,
44
+ }}
45
+ >
46
+ {#if children}
47
+ {@render children()}
48
+ {:else if icon}
49
+ <Icon class={iconClass} {icon} />
50
+ {/if}
51
+ </button>
@@ -1,6 +1,9 @@
1
1
  <script>
2
2
  import SVG from '../../Icon/Icon.svelte'
3
- import { close, getDisclosure } from '../disclosure.js'
3
+ import {
4
+ close,
5
+ getDisclosure,
6
+ } from '../Disclosure/Old/disclosure.jsd/disclosure.js'
4
7
 
5
8
  export let klass = ''
6
9
  export { klass as class }
@@ -0,0 +1,107 @@
1
+ <script>
2
+ import { splitObject } from '@splendidlabz/utils'
3
+ import { hasAccessibleName } from '@splendidlabz/utils/dom'
4
+ import * as easing from 'svelte/easing'
5
+ import { fade } from 'svelte/transition'
6
+ import Portal from '../../Portal.svelte'
7
+ import { disclosures } from '../disclosure-store.js'
8
+ import {
9
+ DISCLOSURE_CONTENT_OPT_KEYS,
10
+ disclosureContent,
11
+ } from '../Disclosure/Old/disclosure.jsd/disclosure.js'
12
+ import { FLOATING_CONTENT_OPT_KEYS, floatingContent } from './floating.js'
13
+ import {
14
+ DEFAULT_POPOVER_CONTENT_OPTS,
15
+ DEFAULT_POPOVER_TRANSITION_OPTS,
16
+ } from './popover.js'
17
+
18
+ let klass = ''
19
+ export { klass as class }
20
+
21
+ export let id
22
+ export let role = 'dialog'
23
+ export let ariaLabel = $$restProps['aria-label']
24
+ export let ariaLabelledBy = $$restProps['aria-labelledby']
25
+ export let ariaDescribedBy = $$restProps['aria-describedby']
26
+ export let options = {}
27
+
28
+ if (!hasAccessibleName(ariaLabel, ariaLabelledBy)) {
29
+ console.warn(
30
+ `PopoverContent (with id: ${id}) should have an accessible name. Please create one with aria-label or aria-labelledby.`,
31
+ )
32
+ }
33
+
34
+ const opts = {
35
+ ...DEFAULT_POPOVER_CONTENT_OPTS.disclosure,
36
+ ...DEFAULT_POPOVER_CONTENT_OPTS.popover,
37
+ ...DEFAULT_POPOVER_TRANSITION_OPTS,
38
+ ...options,
39
+ }
40
+
41
+ const { picked: disclosureOpts } = splitObject(
42
+ opts,
43
+ DISCLOSURE_CONTENT_OPT_KEYS,
44
+ )
45
+
46
+ const { picked: floatingOpts } = splitObject(opts, FLOATING_CONTENT_OPT_KEYS)
47
+ const { picked: transitionOpts } = splitObject(
48
+ opts,
49
+ Object.keys(DEFAULT_POPOVER_TRANSITION_OPTS),
50
+ )
51
+
52
+ transitionOpts.easing = easing[transitionOpts.easing]
53
+
54
+ const { portal } = opts
55
+ let d
56
+ $: d = $disclosures.find(d => d.id === id)
57
+ </script>
58
+
59
+ {#if d?.state.show}
60
+ {#if portal}
61
+ <Portal>
62
+ <div
63
+ {id}
64
+ {role}
65
+ tabindex="-1"
66
+ class={`PopoverContent ${klass}`}
67
+ use:floatingContent={floatingOpts}
68
+ use:disclosureContent={{ options: disclosureOpts }}
69
+ on:open
70
+ on:close
71
+ transition:fade={transitionOpts}
72
+ aria-label={ariaLabel}
73
+ aria-labelledby={ariaLabelledBy}
74
+ aria-describedby={ariaDescribedBy}
75
+ {...$$restProps}
76
+ >
77
+ <slot />
78
+ {#if floatingOpts.arrow}
79
+ <div class="PopoverArrow"></div>
80
+ {/if}
81
+ </div>
82
+ </Portal>
83
+ {:else}
84
+ <div
85
+ {id}
86
+ {role}
87
+ tabindex="-1"
88
+ class={`PopoverContent ${klass}`}
89
+ use:floatingContent={floatingOpts}
90
+ use:disclosureContent={{ options: disclosureOpts }}
91
+ on:open
92
+ on:close
93
+ transition:fade={transitionOpts}
94
+ aria-label={ariaLabel}
95
+ aria-labelledby={ariaLabelledBy}
96
+ aria-describedby={ariaDescribedBy}
97
+ {...$$restProps}
98
+ >
99
+ <slot />
100
+ {#if floatingOpts.arrow}
101
+ <div class="PopoverArrow"></div>
102
+ {/if}
103
+ </div>
104
+ {/if}
105
+ {/if}
106
+
107
+ <!-- transition:custom={transitionOptions} -->
@@ -0,0 +1,33 @@
1
+ <script>
2
+ import { isInvalidAriaPopup } from '@splendidlabz/utils/dom'
3
+ import { disclosureTrigger } from '../Disclosure/Old/disclosure.jsd/disclosure.js'
4
+ import { DEFAULT_POPOVER_TRIGGER_OPTS } from './popover.js'
5
+
6
+ let klass = ''
7
+ export { klass as class }
8
+
9
+ export let target
10
+ export let show = false
11
+ export let ariaPopup = $$restProps['aria-haspopup'] || 'dialog'
12
+ export let options = {}
13
+
14
+ // Prevent invalid aria-haspopup values
15
+ if (isInvalidAriaPopup(ariaPopup)) ariaPopup = undefined
16
+
17
+ const opts = {
18
+ ...DEFAULT_POPOVER_TRIGGER_OPTS,
19
+ ...options,
20
+ }
21
+ </script>
22
+
23
+ <button
24
+ {target}
25
+ class="Button PopoverTrigger {klass}"
26
+ aria-haspopup={ariaPopup}
27
+ aria-details={target}
28
+ use:disclosureTrigger={{ state: { show }, options: opts }}
29
+ {...$$restProps}
30
+ on:click
31
+ >
32
+ <slot />
33
+ </button>
@@ -0,0 +1,171 @@
1
+ import {
2
+ arrow,
3
+ autoUpdate,
4
+ computePosition,
5
+ flip,
6
+ offset,
7
+ shift,
8
+ } from '@floating-ui/dom'
9
+ import { mix, splitUnit } from '@splendidlabz/utils'
10
+ import { em, rem } from '@splendidlabz/utils/dom'
11
+
12
+ // TODO: Add inline for tooltips
13
+ export const DEFAULT_FLOATING_CONTENT_OPTS = {
14
+ placement: 'top',
15
+ strategy: 'absolute',
16
+ offset: '0.5rem',
17
+ arrow: false,
18
+ arrowWidth: '0.6rem',
19
+ arrowDelta: 0,
20
+ inline: false,
21
+ }
22
+
23
+ export const FLOATING_CONTENT_OPT_KEYS = Object.keys(
24
+ DEFAULT_FLOATING_CONTENT_OPTS,
25
+ )
26
+
27
+ export function floatingContent(node, options) {
28
+ const floatingNode = node
29
+ const referenceNode = document.querySelector(`[target="${node.id}"]`)
30
+ let arrowNode
31
+
32
+ options = mix(DEFAULT_FLOATING_CONTENT_OPTS, options)
33
+
34
+ if (options.arrow) {
35
+ arrowNode = node.querySelector('.PopoverArrow')
36
+ arrowNode.style.width = calculateArrowWidth(options.arrowWidth) + 'px'
37
+ }
38
+
39
+ const offsetValue = calculateOffsetValue({ ...options, arrowNode })
40
+
41
+ options.middleware = [
42
+ offset(offsetValue),
43
+ // options.middleware.push(inline()), // Should be placed here. Padding option might be useful.
44
+ flip({ fallbackAxisSideDirection: 'start' }),
45
+ shift(),
46
+ ]
47
+
48
+ if (options.arrow) {
49
+ options.middleware.push(arrow({ element: arrowNode }))
50
+ }
51
+
52
+ autoUpdate(referenceNode, floatingNode, () => {
53
+ computePosition(referenceNode, floatingNode, options).then(
54
+ middlewareState => {
55
+ const { x, y } = middlewareState
56
+ // Position Popover
57
+ Object.assign(floatingNode.style, {
58
+ left: `${x}px`,
59
+ top: `${y}px`,
60
+ })
61
+
62
+ if (options.arrow) {
63
+ const arrowPosStyle = calculateArrowPosition({
64
+ middlewareState,
65
+ floatingNode,
66
+ arrowNode,
67
+ arrowDelta: options.arrowDelta,
68
+ })
69
+ Object.assign(arrowNode.style, arrowPosStyle)
70
+ }
71
+ },
72
+ )
73
+ })
74
+ }
75
+
76
+ function calculateOffsetValue({ offset, arrow, arrowNode }) {
77
+ // SSR Ready
78
+ if (typeof window === 'undefined') return
79
+ if (!offset) offset = 0
80
+
81
+ const [value, unit] = splitUnit(offset)
82
+
83
+ let finalValue = 0
84
+
85
+ if (unit === 'rem') finalValue = value * rem()
86
+ if (unit === 'em') finalValue = value * em()
87
+ if (unit === 'px') finalValue = value
88
+ if (!unit) finalValue = value // Default to px offsets
89
+
90
+ if (!arrow) return finalValue
91
+
92
+ // Arrow Offset compensation
93
+ const arrowWidth = arrowNode.offsetWidth
94
+ const half = arrowWidth / 2
95
+ const arrowOffsetCompensation = Math.floor(Math.sqrt(half * half * 2))
96
+
97
+ return finalValue + arrowOffsetCompensation
98
+ }
99
+
100
+ function calculateArrowWidth(givenWidth) {
101
+ const remValue = rem()
102
+ const [value, unit] = splitUnit(givenWidth)
103
+ let finalValue = 0
104
+
105
+ if (unit === 'rem') finalValue = value * remValue
106
+ if (unit === 'px') finalValue = value
107
+ if (!unit) finalValue = value // Default to px offsets
108
+
109
+ return finalValue
110
+ }
111
+
112
+ function calculateArrowPosition({
113
+ middlewareState,
114
+ floatingNode,
115
+ arrowNode,
116
+ arrowDelta,
117
+ }) {
118
+ const { placement, middlewareData } = middlewareState
119
+
120
+ let x = middlewareData.arrow?.x
121
+ let y = middlewareData.arrow?.y
122
+
123
+ const staticSide = {
124
+ top: 'bottom',
125
+ right: 'left',
126
+ bottom: 'top',
127
+ left: 'right',
128
+ }[placement.split('-')[0]]
129
+
130
+ // Calculates arrow direction
131
+ let rotate = 45
132
+ // prettier-ignore
133
+ switch (staticSide) {
134
+ case 'top': rotate = 45; break;
135
+ case 'right': rotate = 135; break;
136
+ case 'bottom': rotate = 225; break;
137
+ case 'left': rotate = 315; break;
138
+ }
139
+
140
+ // Calculates maximum X and Y on cross-axis
141
+ const { width, height } = floatingNode.getBoundingClientRect()
142
+ const borderRadius = parseFloat(getComputedStyle(floatingNode).borderRadius)
143
+ const borderWidth = parseFloat(getComputedStyle(floatingNode).borderWidth)
144
+ const arrowWidth = arrowNode.offsetWidth
145
+
146
+ if (x || x === 0) {
147
+ const startEdge = borderRadius
148
+ const endEdge = width - borderRadius - arrowWidth
149
+
150
+ if (x <= startEdge) x = startEdge
151
+ if (x >= endEdge) x = endEdge
152
+ }
153
+
154
+ if (y || y === 0) {
155
+ const startEdge = borderRadius
156
+ const endEdge = height - borderRadius - arrowWidth
157
+
158
+ if (y <= startEdge) y = startEdge
159
+ if (y >= endEdge) y = endEdge
160
+ }
161
+
162
+ // Centers the arrow on the static side
163
+ const staticSideOffset = Math.round((arrowNode.offsetWidth + borderWidth) / 2)
164
+
165
+ return {
166
+ left: x != null ? `${x}px` : '',
167
+ top: y != null ? `${y}px` : '',
168
+ [staticSide]: `-${staticSideOffset + arrowDelta}px`,
169
+ transform: `rotate(${rotate}deg)`,
170
+ }
171
+ }
@@ -0,0 +1,5 @@
1
+ import PopoverCloseButton from './PopoverCloseButton.svelte'
2
+ import PopoverContent from './PopoverContent.svelte'
3
+ import PopoverTrigger from './PopoverTrigger.svelte'
4
+
5
+ export { PopoverTrigger, PopoverCloseButton, PopoverContent }
@@ -2,7 +2,7 @@
2
2
 
3
3
  <script>
4
4
  import { disclosures, initDisclosure } from '../disclosure-store.js'
5
- import { disclosureTrigger } from '../disclosure.js'
5
+ import { disclosureTrigger } from '../Disclosure/Old/disclosure.jsd/disclosure.js'
6
6
  import { defaultTooltipTriggerOpts } from './tooltip.js'
7
7
 
8
8
  // let klass