@flightlesslabs/dodo-ui 0.11.0 → 0.12.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.
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/stories/components/Form/Button/Button.svelte +18 -18
- package/dist/stories/components/Form/Button/utils/scss/mixins.scss +3 -3
- package/dist/stories/components/Form/DatePicker/DatePicker.svelte +1 -11
- package/dist/stories/components/Form/NumericInput/Roundness/Roundness.stories.svelte +20 -0
- package/dist/stories/components/Form/NumericInput/Roundness/Roundness.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Form/NumericInput/Size/Size.stories.svelte +16 -0
- package/dist/stories/components/Form/NumericInput/Size/Size.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Form/NumericInput/WithIcon/WithIcon.stories.svelte +31 -0
- package/dist/stories/components/Form/NumericInput/WithIcon/WithIcon.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Form/RangeSlider/Color/Color.stories.svelte +19 -0
- package/dist/stories/components/Form/RangeSlider/Color/Color.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Form/RangeSlider/Events/Events.stories.svelte +59 -0
- package/dist/stories/components/Form/RangeSlider/Events/Events.stories.svelte.d.ts +18 -0
- package/dist/stories/components/Form/RangeSlider/RangeSlider.stories.svelte +64 -0
- package/dist/stories/components/Form/RangeSlider/RangeSlider.stories.svelte.d.ts +21 -0
- package/dist/stories/components/Form/RangeSlider/RangeSlider.svelte +525 -0
- package/dist/stories/components/Form/RangeSlider/RangeSlider.svelte.d.ts +48 -0
- package/dist/stories/components/Form/RangeSlider/Roundness/Roundness.stories.svelte +30 -0
- package/dist/stories/components/Form/RangeSlider/Roundness/Roundness.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Form/RangeSlider/Size/Size.stories.svelte +16 -0
- package/dist/stories/components/Form/RangeSlider/Size/Size.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Form/RangeSlider/WithIcon/WithIcon.stories.svelte +30 -0
- package/dist/stories/components/Form/RangeSlider/WithIcon/WithIcon.stories.svelte.d.ts +18 -0
- package/dist/stories/components/Form/RangeSlider/utils/scss/mixins.scss +91 -0
- package/dist/stories/developer tools/components/Popper/Popper.stories.svelte +16 -0
- package/dist/stories/developer tools/components/Popper/Popper.svelte +10 -14
- package/dist/stories/developer tools/components/Popper/Popper.svelte.d.ts +2 -0
- package/dist/stories/developer tools/components/Popper/PopperPopup/PopperPopup.svelte +25 -11
- package/dist/stories/developer tools/components/Popper/PopperPopup/PopperPopup.svelte.d.ts +2 -0
- package/dist/stories/developer tools/components/Popper/PopperPopup/utils/getPopupPosition.d.ts +10 -8
- package/dist/stories/developer tools/components/Popper/PopperPopup/utils/getPopupPosition.js +40 -23
- package/dist/stories/developer tools/directives/drag/drag.d.ts +3 -0
- package/dist/stories/developer tools/directives/drag/drag.js +40 -0
- package/dist/styles/_components.css +5 -0
- package/package.json +10 -10
- package/src/lib/index.ts +4 -0
- package/src/lib/stories/components/Form/Button/utils/scss/mixins.scss +3 -3
- package/src/lib/stories/components/Form/DatePicker/DatePicker.svelte +1 -13
- package/src/lib/stories/components/Form/RangeSlider/RangeSlider.svelte +476 -0
- package/src/lib/stories/components/Form/RangeSlider/utils/scss/mixins.scss +91 -0
- package/src/lib/stories/developer tools/components/Popper/Popper.svelte +13 -14
- package/src/lib/stories/developer tools/components/Popper/PopperPopup/PopperPopup.svelte +36 -10
- package/src/lib/stories/developer tools/components/Popper/PopperPopup/utils/getPopupPosition.ts +45 -31
- package/src/lib/stories/developer tools/directives/drag/drag.ts +47 -0
- package/src/lib/styles/_components.css +5 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script module lang="ts">import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
2
|
+
import RangeSlider from '../RangeSlider.svelte';
|
|
3
|
+
import { storyRangeSliderArgTypes } from '../RangeSlider.stories.svelte';
|
|
4
|
+
import Icon from '@iconify/svelte';
|
|
5
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
6
|
+
const { Story } = defineMeta({
|
|
7
|
+
component: RangeSlider,
|
|
8
|
+
tags: ['autodocs'],
|
|
9
|
+
argTypes: storyRangeSliderArgTypes,
|
|
10
|
+
});
|
|
11
|
+
let value = $state(30);
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<!-- RangeSlider icon in front. -->
|
|
15
|
+
<Story name="Icon Before" asChild>
|
|
16
|
+
<RangeSlider {value}>
|
|
17
|
+
{#snippet before()}
|
|
18
|
+
<Icon icon="material-symbols:content-copy" />
|
|
19
|
+
{/snippet}
|
|
20
|
+
</RangeSlider>
|
|
21
|
+
</Story>
|
|
22
|
+
|
|
23
|
+
<!-- RangeSlider icon in front. -->
|
|
24
|
+
<Story name="Icon After" asChild>
|
|
25
|
+
<RangeSlider {value}>
|
|
26
|
+
{#snippet after()}
|
|
27
|
+
<Icon icon="material-symbols:download-2" />
|
|
28
|
+
{/snippet}
|
|
29
|
+
</RangeSlider>
|
|
30
|
+
</Story>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const WithIcon: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type WithIcon = InstanceType<typeof WithIcon>;
|
|
18
|
+
export default WithIcon;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/// Mixin: generate-dodo-ui-range-slider-colors
|
|
2
|
+
/// Generates CSS custom properties for Dodo UI range-slider styles (text & solid)
|
|
3
|
+
/// across different interaction states (default, hover, active).
|
|
4
|
+
/// @param {String} $color-name - The theme color name (e.g., "primary", "safe", etc.)
|
|
5
|
+
@mixin generate-dodo-ui-range-slider-colors($color-name) {
|
|
6
|
+
--dodo-ui-RangeSlider-thumb-#{$color-name}-bg: var(--dodo-color-#{$color-name}-500);
|
|
7
|
+
--dodo-ui-RangeSlider-thumb-#{$color-name}-hover-bg: var(--dodo-color-#{$color-name}-600);
|
|
8
|
+
--dodo-ui-RangeSlider-thumb-#{$color-name}-active-bg: var(--dodo-color-#{$color-name}-700);
|
|
9
|
+
|
|
10
|
+
--dodo-ui-RangeSlider-track-filled-#{$color-name}-bg: var(--dodo-color-#{$color-name}-500);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/// Mixin: generate-dodo-ui-range-slider-colors
|
|
14
|
+
/// Generates CSS custom properties for Dodo UI range-slider styles (text & solid)
|
|
15
|
+
/// across different interaction states (default, hover, active).
|
|
16
|
+
/// @param {String} $color-name - The theme color name (e.g., "primary", "safe", etc.)
|
|
17
|
+
@mixin generate-dodo-ui-range-slider-colors-dark($color-name) {
|
|
18
|
+
--dodo-ui-RangeSlider-thumb-#{$color-name}-bg: var(--dodo-color-#{$color-name}-500);
|
|
19
|
+
--dodo-ui-RangeSlider-thumb-#{$color-name}-hover-bg: var(--dodo-color-#{$color-name}-400);
|
|
20
|
+
--dodo-ui-RangeSlider-thumb-#{$color-name}-active-bg: var(--dodo-color-#{$color-name}-300);
|
|
21
|
+
|
|
22
|
+
--dodo-ui-RangeSlider-track-filled-#{$color-name}-bg: var(--dodo-color-#{$color-name}-500);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/// Mixin: generate-dodo-ui-range-slider-color
|
|
26
|
+
/// Auto-generates .color--[theme] > .variant--text & .variant--solid styles
|
|
27
|
+
/// @param {String} $theme - e.g., default, safe, danger, etc.
|
|
28
|
+
@mixin generate-dodo-ui-range-slider-color($theme) {
|
|
29
|
+
&--#{$theme} {
|
|
30
|
+
.NativeRangeSlider {
|
|
31
|
+
&::-webkit-slider-runnable-track {
|
|
32
|
+
background-color: var(--dodo-ui-RangeSlider-track-#{$theme}-bg);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&::-moz-range-track {
|
|
36
|
+
background-color: var(--dodo-ui-RangeSlider-track-#{$theme}-bg);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&:focus-visible {
|
|
40
|
+
&::-webkit-slider-thumb {
|
|
41
|
+
background: var(--dodo-ui-RangeSlider-thumb-#{$theme}-active-bg);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&::-moz-range-thumb {
|
|
45
|
+
background: var(--dodo-ui-RangeSlider-thumb-#{$theme}-active-bg);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&::-webkit-slider-runnable-track {
|
|
50
|
+
background: linear-gradient(
|
|
51
|
+
to right,
|
|
52
|
+
var(--dodo-ui-RangeSlider-track-filled-#{$theme}-bg) 0%,
|
|
53
|
+
var(--dodo-ui-RangeSlider-track-filled-#{$theme}-bg)
|
|
54
|
+
calc(var(--dodo-ui-RangeSlider-value-percent, 50%) * 1%),
|
|
55
|
+
var(--dodo-ui-RangeSlider-track-bg)
|
|
56
|
+
calc(var(--dodo-ui-RangeSlider-value-percent, 50%) * 1%),
|
|
57
|
+
var(--dodo-ui-RangeSlider-track-bg) 100%
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&::-moz-range-progress {
|
|
62
|
+
background: var(--dodo-ui-RangeSlider-track-filled-#{$theme}-bg);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Thumb
|
|
66
|
+
&::-webkit-slider-thumb {
|
|
67
|
+
background: var(--dodo-ui-RangeSlider-thumb-#{$theme}-bg);
|
|
68
|
+
|
|
69
|
+
&:hover {
|
|
70
|
+
background: var(--dodo-ui-RangeSlider-thumb-#{$theme}-hover-bg);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&:active {
|
|
74
|
+
background: var(--dodo-ui-RangeSlider-thumb-#{$theme}-active-bg);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&::-moz-range-thumb {
|
|
79
|
+
background: var(--dodo-ui-RangeSlider-thumb-#{$theme}-bg);
|
|
80
|
+
|
|
81
|
+
&:hover {
|
|
82
|
+
background: var(--dodo-ui-RangeSlider-thumb-#{$theme}-hover-bg);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
&:active {
|
|
86
|
+
background: var(--dodo-ui-RangeSlider-thumb-#{$theme}-active-bg);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -82,6 +82,7 @@ let open = $state(false);
|
|
|
82
82
|
</Popper>
|
|
83
83
|
</Story>
|
|
84
84
|
|
|
85
|
+
<!-- Expand the Popper to full width -->
|
|
85
86
|
<Story name="FullWidth" asChild>
|
|
86
87
|
<Popper {open} fullWidth onClickOutside={() => (open = false)}>
|
|
87
88
|
<Button onclick={() => (open = true)}>Click to see Popup</Button>
|
|
@@ -96,6 +97,21 @@ let open = $state(false);
|
|
|
96
97
|
</Popper>
|
|
97
98
|
</Story>
|
|
98
99
|
|
|
100
|
+
<!-- Expand the Popper to full width but not the popup -->
|
|
101
|
+
<Story name="PopupFullWidthFalse" asChild>
|
|
102
|
+
<Popper {open} fullWidth popupFullWidth={false} onClickOutside={() => (open = false)}>
|
|
103
|
+
<Button onclick={() => (open = true)}>Click to see Popup</Button>
|
|
104
|
+
|
|
105
|
+
{#snippet popupChildren()}
|
|
106
|
+
<Menu>
|
|
107
|
+
<MenuItem>One</MenuItem>
|
|
108
|
+
<MenuItem>Two</MenuItem>
|
|
109
|
+
<MenuItem>Three</MenuItem>
|
|
110
|
+
</Menu>
|
|
111
|
+
{/snippet}
|
|
112
|
+
</Popper>
|
|
113
|
+
</Story>
|
|
114
|
+
|
|
99
115
|
<Story
|
|
100
116
|
name="CustomPopup"
|
|
101
117
|
args={{
|
|
@@ -3,19 +3,19 @@ import { clickOutside } from '../../directives/clickOutside/clickOutside.js';
|
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
5
|
<script lang="ts">"use strict";
|
|
6
|
-
let { children, popupChildren, id, class: className = '', ref = $bindable(), open = false, popupRef = $bindable(), paperProps, popupMaxHeight, popupWidth, popupClass, popupPositionX, popupPositionY, popupOffsetX, popupOffsetY, onClickOutside = () => { }, customPopup, popperHeightForVerticalPosition, lockPoistions, fullWidth = false, } = $props();
|
|
6
|
+
let { children, popupChildren, id, class: className = '', ref = $bindable(), open = false, popupRef = $bindable(), paperProps, popupMaxHeight, popupWidth, popupClass, popupPositionX, popupPositionY, popupOffsetX, popupOffsetY, onClickOutside = () => { }, customPopup, popperHeightForVerticalPosition, lockPoistions, fullWidth = false, popupFullWidth: popupFullWidthRaw, } = $props();
|
|
7
|
+
const popupFullWidth = $derived(popupFullWidthRaw !== undefined ? popupFullWidthRaw : fullWidth);
|
|
7
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
9
|
let customPopupTyped = customPopup;
|
|
9
|
-
let popperContainerRef = $state();
|
|
10
10
|
let popperLocation = $state();
|
|
11
11
|
function capturePopperLocation() {
|
|
12
|
-
if (!
|
|
12
|
+
if (!ref) {
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
|
-
popperLocation =
|
|
15
|
+
popperLocation = ref.getBoundingClientRect();
|
|
16
16
|
}
|
|
17
17
|
$effect(() => {
|
|
18
|
-
if (!
|
|
18
|
+
if (!ref) {
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
21
|
capturePopperLocation();
|
|
@@ -33,11 +33,9 @@ $effect(() => {
|
|
|
33
33
|
{id}
|
|
34
34
|
use:clickOutside={onClickOutside}
|
|
35
35
|
>
|
|
36
|
-
|
|
37
|
-
{
|
|
38
|
-
|
|
39
|
-
{/if}
|
|
40
|
-
</div>
|
|
36
|
+
{#if children}
|
|
37
|
+
{@render children()}
|
|
38
|
+
{/if}
|
|
41
39
|
|
|
42
40
|
{#if customPopupTyped}
|
|
43
41
|
{@render customPopupTyped(popperLocation)}
|
|
@@ -53,6 +51,7 @@ $effect(() => {
|
|
|
53
51
|
{popupOffsetY}
|
|
54
52
|
{popperHeightForVerticalPosition}
|
|
55
53
|
{lockPoistions}
|
|
54
|
+
fullWidth={popupFullWidth}
|
|
56
55
|
class={popupClass}
|
|
57
56
|
>
|
|
58
57
|
{#if popupChildren}
|
|
@@ -70,8 +69,5 @@ $effect(() => {
|
|
|
70
69
|
.dodo-ui-Popper.fullWidth {
|
|
71
70
|
display: flex;
|
|
72
71
|
width: 100%;
|
|
73
|
-
|
|
74
|
-
.dodo-ui-Popper.fullWidth .PopperContainer {
|
|
75
|
-
display: block;
|
|
76
|
-
width: 100%;
|
|
72
|
+
flex-direction: column;
|
|
77
73
|
}</style>
|
|
@@ -16,6 +16,8 @@ export interface PopperProps {
|
|
|
16
16
|
open?: boolean;
|
|
17
17
|
/** Full width Popper? */
|
|
18
18
|
fullWidth?: boolean;
|
|
19
|
+
/** override Full width for Popup? */
|
|
20
|
+
popupFullWidth?: boolean;
|
|
19
21
|
/** PopperPopup ref */
|
|
20
22
|
popupRef?: HTMLDivElement;
|
|
21
23
|
/** PopperPopup contents goes here */
|
|
@@ -3,27 +3,42 @@ import { getPopupPosition } from './utils/getPopupPosition.js';
|
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
5
|
<script lang="ts">"use strict";
|
|
6
|
-
let { children, paperProps = {}, class: className = '', popupWidth: width, popupMaxHeight: maxHeight, popupPositionX: positionX = 'left', popupPositionY: positionY = 'bottom', popperLocation, ref = $bindable(), popupOffsetX: offsetX = 0, popupOffsetY: offsetY = 12, popperHeightForVerticalPosition = 100, lockPoistions = false, } = $props();
|
|
7
|
-
|
|
6
|
+
let { children, paperProps = {}, class: className = '', popupWidth: width, popupMaxHeight: maxHeight, popupPositionX: positionX = 'left', popupPositionY: positionY = 'bottom', popperLocation, ref = $bindable(), popupOffsetX: offsetX = 0, popupOffsetY: offsetY = 12, popperHeightForVerticalPosition = 100, lockPoistions = false, fullWidth = false, } = $props();
|
|
7
|
+
let popupLocation = $state();
|
|
8
|
+
const fullWidthInPixels = $derived(fullWidth && popperLocation?.width ? `${popperLocation?.width}px` : '');
|
|
9
|
+
const popperWidth = $derived(width || fullWidthInPixels);
|
|
8
10
|
const popupMaxHeight = $derived(maxHeight || '400px');
|
|
9
11
|
let left = $state(null);
|
|
10
12
|
let right = $state(null);
|
|
11
13
|
let top = $state(null);
|
|
12
14
|
let bottom = $state(null);
|
|
15
|
+
function capturePopupLocation() {
|
|
16
|
+
if (!ref) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
popupLocation = ref.getBoundingClientRect();
|
|
20
|
+
}
|
|
21
|
+
$effect(() => {
|
|
22
|
+
if (!ref) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
capturePopupLocation();
|
|
26
|
+
window.addEventListener('resize', capturePopupLocation);
|
|
27
|
+
return () => {
|
|
28
|
+
window.removeEventListener('resize', capturePopupLocation);
|
|
29
|
+
};
|
|
30
|
+
});
|
|
13
31
|
$effect(() => {
|
|
14
32
|
const values = getPopupPosition({
|
|
15
33
|
positionX,
|
|
16
34
|
positionY,
|
|
17
|
-
height: popperLocation?.height || 0,
|
|
18
|
-
width: popperLocation?.width || 0,
|
|
19
|
-
top: popperLocation?.top || 0,
|
|
20
|
-
bottom: popperLocation?.bottom || 0,
|
|
21
|
-
left: popperLocation?.left || 0,
|
|
22
|
-
right: popperLocation?.right || 0,
|
|
23
35
|
offsetX: offsetX,
|
|
24
36
|
offsetY: offsetY,
|
|
25
37
|
popperHeight: popperHeightForVerticalPosition,
|
|
26
38
|
lockPoistions,
|
|
39
|
+
popperLocation,
|
|
40
|
+
popupLocation,
|
|
41
|
+
fullWidth,
|
|
27
42
|
});
|
|
28
43
|
left = values.left;
|
|
29
44
|
right = values.right;
|
|
@@ -40,12 +55,11 @@ $effect(() => {
|
|
|
40
55
|
className,
|
|
41
56
|
].join(' ')}
|
|
42
57
|
bind:this={ref}
|
|
43
|
-
style={`width: ${popperWidth}
|
|
58
|
+
style={`${popperWidth ? `width: ${popperWidth};` : ''}
|
|
44
59
|
${left !== null ? `left: ${left}px;` : ''}
|
|
45
60
|
${right !== null ? `right: ${right}px;` : ''}
|
|
46
61
|
${top !== null ? `top: ${top}px;` : ''}
|
|
47
62
|
${bottom !== null ? `bottom: ${bottom}px;` : ''}
|
|
48
|
-
${positionX === 'center' ? `margin: auto;` : ''}
|
|
49
63
|
`}
|
|
50
64
|
>
|
|
51
65
|
<Paper shadow={3} {...paperProps}>
|
|
@@ -58,7 +72,7 @@ $effect(() => {
|
|
|
58
72
|
</div>
|
|
59
73
|
|
|
60
74
|
<style>.dodo-ui-PopperPopup {
|
|
61
|
-
position:
|
|
75
|
+
position: fixed;
|
|
62
76
|
z-index: var(--dodo-ui-z-index-4);
|
|
63
77
|
}
|
|
64
78
|
.dodo-ui-PopperPopup section {
|
|
@@ -28,6 +28,8 @@ export interface PopperPopupProps {
|
|
|
28
28
|
lockPoistions?: boolean;
|
|
29
29
|
/** Popper Height For Vertical Position, default 300 */
|
|
30
30
|
popperHeightForVerticalPosition?: number;
|
|
31
|
+
/** Full width Popper? */
|
|
32
|
+
fullWidth?: boolean;
|
|
31
33
|
}
|
|
32
34
|
declare const PopperPopup: import("svelte").Component<PopperPopupProps, {}, "ref">;
|
|
33
35
|
type PopperPopup = ReturnType<typeof PopperPopup>;
|
package/dist/stories/developer tools/components/Popper/PopperPopup/utils/getPopupPosition.d.ts
CHANGED
|
@@ -2,20 +2,22 @@ import type { PositionX, PositionY } from '../../../../../../types/position.js';
|
|
|
2
2
|
export interface GetPopupPositionProps {
|
|
3
3
|
positionX: PositionX;
|
|
4
4
|
positionY: PositionY;
|
|
5
|
-
height: number;
|
|
6
|
-
width: number;
|
|
7
|
-
top: number;
|
|
8
|
-
bottom: number;
|
|
9
|
-
left: number;
|
|
10
|
-
right: number;
|
|
11
5
|
offsetX?: number;
|
|
12
6
|
offsetY?: number;
|
|
13
7
|
popperHeight: number;
|
|
14
8
|
lockPoistions: boolean;
|
|
9
|
+
popperLocation?: DOMRect;
|
|
10
|
+
popupLocation?: DOMRect;
|
|
11
|
+
fullWidth?: boolean;
|
|
15
12
|
}
|
|
16
13
|
export declare function getPopupPosition(props: GetPopupPositionProps): {
|
|
17
|
-
left:
|
|
18
|
-
right:
|
|
14
|
+
left: null;
|
|
15
|
+
right: null;
|
|
16
|
+
top: null;
|
|
17
|
+
bottom: null;
|
|
18
|
+
} | {
|
|
19
|
+
left: number;
|
|
20
|
+
right: null;
|
|
19
21
|
top: number | null;
|
|
20
22
|
bottom: number | null;
|
|
21
23
|
};
|
package/dist/stories/developer tools/components/Popper/PopperPopup/utils/getPopupPosition.js
CHANGED
|
@@ -13,46 +13,63 @@ export function getPopupPosition(props) {
|
|
|
13
13
|
bottom,
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
16
|
+
const POPPER_LEFT = props.popperLocation?.left || 0;
|
|
17
|
+
const POPPER_TOP = props.popperLocation?.top || 0;
|
|
18
|
+
const POPPER_BOTTOM = props.popperLocation?.bottom || 0;
|
|
19
|
+
const POPPER_HEIGHT = props.popperLocation?.height || 0;
|
|
20
|
+
const POPPER_WIDTH = props.popperLocation?.width || 0;
|
|
19
21
|
const offsetX = props.offsetX ? props.offsetX : 0;
|
|
20
22
|
const offsetY = props.offsetY ? props.offsetY : 0;
|
|
21
|
-
const
|
|
23
|
+
const POPUP_WIDTH = props.popupLocation?.width || 0;
|
|
24
|
+
const WIDTH_DIFF = POPPER_WIDTH - POPUP_WIDTH;
|
|
25
|
+
const innerHeight = window.innerHeight;
|
|
26
|
+
const gapBottom = innerHeight - POPPER_BOTTOM;
|
|
22
27
|
let positionY = props.positionY;
|
|
28
|
+
// Adjust position if there is not enough space to draw it.
|
|
23
29
|
if (!props.lockPoistions) {
|
|
24
|
-
if (positionY === 'top' &&
|
|
30
|
+
if (positionY === 'top' && POPPER_TOP < POPPER_HEIGHT + offsetY) {
|
|
25
31
|
positionY = 'bottom';
|
|
26
32
|
}
|
|
27
|
-
else if (positionY === 'bottom' && gapBottom <
|
|
33
|
+
else if (positionY === 'bottom' && gapBottom < POPPER_HEIGHT + offsetY) {
|
|
28
34
|
positionY = 'top';
|
|
29
35
|
}
|
|
30
36
|
}
|
|
31
|
-
switch (positionX) {
|
|
32
|
-
case 'left':
|
|
33
|
-
left = offsetX;
|
|
34
|
-
right = null;
|
|
35
|
-
break;
|
|
36
|
-
case 'center':
|
|
37
|
-
left = 0;
|
|
38
|
-
right = 0;
|
|
39
|
-
break;
|
|
40
|
-
case 'right':
|
|
41
|
-
left = null;
|
|
42
|
-
right = offsetX;
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
37
|
switch (positionY) {
|
|
46
38
|
case 'top':
|
|
47
|
-
case 'middle':
|
|
48
39
|
top = null;
|
|
49
|
-
bottom =
|
|
40
|
+
bottom = POPPER_TOP + POPPER_HEIGHT + offsetY;
|
|
50
41
|
break;
|
|
51
42
|
case 'bottom':
|
|
52
|
-
top =
|
|
43
|
+
top = POPPER_TOP + POPPER_HEIGHT + offsetY;
|
|
53
44
|
bottom = null;
|
|
54
45
|
break;
|
|
55
46
|
}
|
|
47
|
+
if (props.fullWidth) {
|
|
48
|
+
// If Full Width
|
|
49
|
+
left = POPPER_LEFT;
|
|
50
|
+
right = null;
|
|
51
|
+
}
|
|
52
|
+
else if (WIDTH_DIFF < 0) {
|
|
53
|
+
// If Popup is bigger than the Popper Container
|
|
54
|
+
left = POPPER_LEFT;
|
|
55
|
+
right = null;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
switch (props.positionX) {
|
|
59
|
+
case 'left':
|
|
60
|
+
left = POPPER_LEFT + offsetX;
|
|
61
|
+
right = null;
|
|
62
|
+
break;
|
|
63
|
+
case 'center':
|
|
64
|
+
left = POPPER_LEFT + offsetX + WIDTH_DIFF / 2;
|
|
65
|
+
right = null;
|
|
66
|
+
break;
|
|
67
|
+
case 'right':
|
|
68
|
+
left = POPPER_LEFT + offsetX + WIDTH_DIFF;
|
|
69
|
+
right = null;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
56
73
|
return {
|
|
57
74
|
left,
|
|
58
75
|
right,
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export function drag(node) {
|
|
2
|
+
let dragging = false;
|
|
3
|
+
function getX(e) {
|
|
4
|
+
return 'touches' in e ? e.touches[0].clientX : e.clientX;
|
|
5
|
+
}
|
|
6
|
+
function handleStart(e) {
|
|
7
|
+
dragging = true;
|
|
8
|
+
const x = getX(e);
|
|
9
|
+
node.dispatchEvent(new CustomEvent('dragstart', { detail: { x } }));
|
|
10
|
+
window.addEventListener('mousemove', handleMove);
|
|
11
|
+
window.addEventListener('mouseup', handleEnd);
|
|
12
|
+
window.addEventListener('touchmove', handleMove);
|
|
13
|
+
window.addEventListener('touchend', handleEnd);
|
|
14
|
+
}
|
|
15
|
+
function handleMove(e) {
|
|
16
|
+
if (!dragging)
|
|
17
|
+
return;
|
|
18
|
+
const x = getX(e);
|
|
19
|
+
node.dispatchEvent(new CustomEvent('dragging', { detail: { x } }));
|
|
20
|
+
}
|
|
21
|
+
function handleEnd(e) {
|
|
22
|
+
if (!dragging)
|
|
23
|
+
return;
|
|
24
|
+
dragging = false;
|
|
25
|
+
const x = getX(e);
|
|
26
|
+
node.dispatchEvent(new CustomEvent('dragend', { detail: { x } }));
|
|
27
|
+
window.removeEventListener('mousemove', handleMove);
|
|
28
|
+
window.removeEventListener('mouseup', handleEnd);
|
|
29
|
+
window.removeEventListener('touchmove', handleMove);
|
|
30
|
+
window.removeEventListener('touchend', handleEnd);
|
|
31
|
+
}
|
|
32
|
+
node.addEventListener('mousedown', handleStart);
|
|
33
|
+
node.addEventListener('touchstart', handleStart, { passive: true });
|
|
34
|
+
return {
|
|
35
|
+
destroy() {
|
|
36
|
+
node.removeEventListener('mousedown', handleStart);
|
|
37
|
+
node.removeEventListener('touchstart', handleStart);
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
--dodo-ui-element-height-normal: 40px;
|
|
5
5
|
--dodo-ui-element-height-large: 50px;
|
|
6
6
|
|
|
7
|
+
/* Size Thin elements */
|
|
8
|
+
--dodo-ui-track-element-height-small: 6px;
|
|
9
|
+
--dodo-ui-track-element-height-normal: 8px;
|
|
10
|
+
--dodo-ui-track-element-height-large: 10px;
|
|
11
|
+
|
|
7
12
|
/* Roundness */
|
|
8
13
|
--dodo-ui-element-roundness-1: 0.4375em;
|
|
9
14
|
--dodo-ui-element-roundness-2: 0.8125em;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flightlesslabs/dodo-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "vite build && pnpm run prepack",
|
|
6
6
|
"preview": "vite preview",
|
|
@@ -51,18 +51,18 @@
|
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@chromatic-com/storybook": "4.0.0",
|
|
53
53
|
"@eslint/compat": "^1.3.0",
|
|
54
|
-
"@eslint/js": "^9.
|
|
54
|
+
"@eslint/js": "^9.29.0",
|
|
55
55
|
"@storybook/addon-svelte-csf": "5.0.3",
|
|
56
|
-
"@storybook/svelte": "^9.0.
|
|
57
|
-
"@storybook/sveltekit": "^9.0.
|
|
56
|
+
"@storybook/svelte": "^9.0.10",
|
|
57
|
+
"@storybook/sveltekit": "^9.0.10",
|
|
58
58
|
"@sveltejs/adapter-static": "^3.0.8",
|
|
59
|
-
"@sveltejs/kit": "^2.21.
|
|
59
|
+
"@sveltejs/kit": "^2.21.5",
|
|
60
60
|
"@sveltejs/package": "^2.3.11",
|
|
61
61
|
"@sveltejs/vite-plugin-svelte": "^5.1.0",
|
|
62
62
|
"@vitest/browser": "^3.2.3",
|
|
63
63
|
"@vitest/coverage-v8": "^3.2.3",
|
|
64
64
|
"@vueless/storybook-dark-mode": "^9.0.5",
|
|
65
|
-
"eslint": "^9.
|
|
65
|
+
"eslint": "^9.29.0",
|
|
66
66
|
"eslint-config-prettier": "^10.1.5",
|
|
67
67
|
"eslint-plugin-svelte": "^3.9.2",
|
|
68
68
|
"globals": "^16.2.0",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"prettier-plugin-svelte": "^3.4.0",
|
|
72
72
|
"publint": "^0.3.12",
|
|
73
73
|
"sass": "^1.89.2",
|
|
74
|
-
"storybook": "^9.0.
|
|
75
|
-
"svelte": "^5.34.
|
|
74
|
+
"storybook": "^9.0.10",
|
|
75
|
+
"svelte": "^5.34.3",
|
|
76
76
|
"svelte-check": "^4.2.1",
|
|
77
77
|
"svelte-preprocess": "^6.0.3",
|
|
78
78
|
"typescript": "^5.8.3",
|
|
@@ -89,8 +89,8 @@
|
|
|
89
89
|
},
|
|
90
90
|
"dependencies": {
|
|
91
91
|
"@iconify/svelte": "^5.0.0",
|
|
92
|
-
"@storybook/addon-docs": "^9.0.
|
|
93
|
-
"@storybook/addon-vitest": "^9.0.
|
|
92
|
+
"@storybook/addon-docs": "^9.0.10",
|
|
93
|
+
"@storybook/addon-vitest": "^9.0.10",
|
|
94
94
|
"dayjs": "^1.11.13"
|
|
95
95
|
}
|
|
96
96
|
}
|
package/src/lib/index.ts
CHANGED
|
@@ -122,6 +122,10 @@ export type {
|
|
|
122
122
|
DatePickerCalendarIconPosition,
|
|
123
123
|
} from '$lib/stories/components/Form/DatePicker/DatePicker.svelte';
|
|
124
124
|
|
|
125
|
+
/** Form: RangeSlider */
|
|
126
|
+
export { default as RangeSlider } from '$lib/stories/components/Form/RangeSlider/RangeSlider.svelte';
|
|
127
|
+
export type { RangeSliderProps } from '$lib/stories/components/Form/RangeSlider/RangeSlider.svelte';
|
|
128
|
+
|
|
125
129
|
/** Layout: Paper */
|
|
126
130
|
export { default as Paper } from '$lib/stories/components/Layout/Paper/Paper.svelte';
|
|
127
131
|
export type { PaperColor, PaperProps } from '$lib/stories/components/Layout/Paper/Paper.svelte';
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
#fff
|
|
42
42
|
);
|
|
43
43
|
|
|
44
|
-
--dodo-ui-Button-solid-#{$color-name}-bg: var(--dodo-color-#{$color-name}-
|
|
45
|
-
--dodo-ui-Button-solid-#{$color-name}-hover-bg: var(--dodo-color-#{$color-name}-
|
|
46
|
-
--dodo-ui-Button-solid-#{$color-name}-active-bg: var(--dodo-color-#{$color-name}-
|
|
44
|
+
--dodo-ui-Button-solid-#{$color-name}-bg: var(--dodo-color-#{$color-name}-400);
|
|
45
|
+
--dodo-ui-Button-solid-#{$color-name}-hover-bg: var(--dodo-color-#{$color-name}-300);
|
|
46
|
+
--dodo-ui-Button-solid-#{$color-name}-active-bg: var(--dodo-color-#{$color-name}-200);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/// Mixin: generate-dodo-ui-button-color
|
|
@@ -392,18 +392,6 @@
|
|
|
392
392
|
|
|
393
393
|
const calenderSize = calendarProps?.size || size;
|
|
394
394
|
|
|
395
|
-
let popupWidth = $state(
|
|
396
|
-
`calc(var(--dodo-ui-element-height-normal) * 7 + var(--dodo-ui-space) * 2)`,
|
|
397
|
-
);
|
|
398
|
-
|
|
399
|
-
if (calenderSize === 'normal') {
|
|
400
|
-
popupWidth = `calc(var(--dodo-ui-element-height-normal) * 7 + var(--dodo-ui-space) * 2)`;
|
|
401
|
-
} else if (calenderSize === 'small') {
|
|
402
|
-
popupWidth = `calc(var(--dodo-ui-element-height-small) * 7 + var(--dodo-ui-space) * 2)`;
|
|
403
|
-
} else if (calenderSize === 'large') {
|
|
404
|
-
popupWidth = `calc(var(--dodo-ui-element-height-large) * 7 + var(--dodo-ui-space) * 2)`;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
395
|
function closePopup() {
|
|
408
396
|
open = false;
|
|
409
397
|
|
|
@@ -509,7 +497,7 @@
|
|
|
509
497
|
<Popper
|
|
510
498
|
{open}
|
|
511
499
|
fullWidth
|
|
512
|
-
{
|
|
500
|
+
popupFullWidth={false}
|
|
513
501
|
{onClickOutside}
|
|
514
502
|
{...popperProps}
|
|
515
503
|
{popupPositionX}
|