@pathscale/ui 0.0.106 → 0.0.108
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/README.md +22 -53
- package/dist/components/toastcontainer/ToastStack.d.ts +17 -0
- package/dist/components/toastcontainer/index.d.ts +2 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +692 -39
- package/dist/motion/driver.d.ts +5 -0
- package/dist/motion/easing.d.ts +2 -0
- package/dist/motion/engine.d.ts +4 -0
- package/dist/motion/index.d.ts +11 -0
- package/dist/motion/popmotion.d.ts +6 -0
- package/dist/motion/presets.d.ts +10 -0
- package/dist/motion/reduced-motion.d.ts +1 -0
- package/dist/motion/route.d.ts +11 -0
- package/dist/motion/solid/MotionDiv.d.ts +13 -0
- package/dist/motion/solid/index.d.ts +2 -0
- package/dist/motion/system.d.ts +20 -0
- package/dist/motion/tokens.d.ts +6 -0
- package/dist/motion/types.d.ts +39 -0
- package/dist/stores/toastStore.d.ts +3 -0
- package/package.json +7 -1
package/README.md
CHANGED
|
@@ -3,68 +3,37 @@
|
|
|
3
3
|
Highly opinionated SolidJS component library — batteries and kitchen sink
|
|
4
4
|
included, but optimized and shiny.
|
|
5
5
|
|
|
6
|
-
##
|
|
7
|
-
|
|
8
|
-
To build this package, use the following command
|
|
6
|
+
## Install
|
|
9
7
|
|
|
10
8
|
```sh
|
|
11
|
-
bun
|
|
9
|
+
bun add @pathscale/ui
|
|
12
10
|
```
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
## Actions
|
|
17
|
-
|
|
18
|
-
- [x] Button
|
|
19
|
-
- [x] Dropdown
|
|
20
|
-
- [x] Modal
|
|
21
|
-
- [x] Swap
|
|
12
|
+
## Usage
|
|
22
13
|
|
|
23
|
-
|
|
14
|
+
```tsx
|
|
15
|
+
import { Button, Flex } from "@pathscale/ui";
|
|
24
16
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
- [x] Collapse
|
|
32
|
-
- [x] Countdown
|
|
33
|
-
- [x] Diff
|
|
34
|
-
- [x] Kbd
|
|
35
|
-
- [x] Stats
|
|
36
|
-
- [x] Table
|
|
37
|
-
- [x] Timeline
|
|
17
|
+
export const Example = () => (
|
|
18
|
+
<Flex direction="col" gap="sm">
|
|
19
|
+
<Button color="primary">Primary</Button>
|
|
20
|
+
</Flex>
|
|
21
|
+
);
|
|
22
|
+
```
|
|
38
23
|
|
|
39
|
-
##
|
|
24
|
+
## Motion
|
|
40
25
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
- [x] Link
|
|
44
|
-
- [x] Menu
|
|
45
|
-
- [x] Navbar
|
|
46
|
-
- [x] Pagination
|
|
47
|
-
- [x] Steps
|
|
48
|
-
- [ ] Tabs
|
|
26
|
+
Shared animation primitives live in `@pathscale/ui/motion`. For setup,
|
|
27
|
+
Popmotion driver enablement, and migration notes, see `docs/motion.md`.
|
|
49
28
|
|
|
50
|
-
##
|
|
29
|
+
## Development
|
|
51
30
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
- [x] Radial Progress
|
|
56
|
-
- [x] Skeleton
|
|
57
|
-
- [x] Tooltip
|
|
58
|
-
- [x] Toast
|
|
31
|
+
```sh
|
|
32
|
+
bun run build
|
|
33
|
+
```
|
|
59
34
|
|
|
60
|
-
|
|
35
|
+
Other useful scripts:
|
|
61
36
|
|
|
62
|
-
-
|
|
63
|
-
-
|
|
64
|
-
-
|
|
65
|
-
- [x] Radio
|
|
66
|
-
- [x] Range
|
|
67
|
-
- [x] Rating
|
|
68
|
-
- [x] Select
|
|
69
|
-
- [x] Textarea
|
|
70
|
-
- [x] Toggle
|
|
37
|
+
- `bun run dev`
|
|
38
|
+
- `bun run lint`
|
|
39
|
+
- `bun run format`
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Component, type JSX } from "solid-js";
|
|
2
|
+
import type { ToastProps } from "../toast/Toast";
|
|
3
|
+
import type { MotionPreset } from "../../motion";
|
|
4
|
+
import { type ToastItem } from "../../stores/toastStore";
|
|
5
|
+
export type ToastRenderer = (toast: ToastItem, dismiss: () => void) => JSX.Element;
|
|
6
|
+
export type ToastStackProps = ToastProps & {
|
|
7
|
+
motionPreset?: MotionPreset;
|
|
8
|
+
motionPresetName?: string;
|
|
9
|
+
reduceMotion?: boolean;
|
|
10
|
+
renderToast?: ToastRenderer;
|
|
11
|
+
expandOnClick?: boolean;
|
|
12
|
+
collapsedCount?: number;
|
|
13
|
+
collapsedOffset?: number;
|
|
14
|
+
collapsedScale?: number;
|
|
15
|
+
};
|
|
16
|
+
export declare const ToastStack: Component<ToastStackProps>;
|
|
17
|
+
export default ToastStack;
|
package/dist/index.d.ts
CHANGED
|
@@ -85,9 +85,11 @@ export type { RadioTabProps, TabProps, TabsProps } from "./components/tabs";
|
|
|
85
85
|
export { default as Textarea } from "./components/textarea";
|
|
86
86
|
export { Timeline, TimelineEnd, TimelineItem, TimelineMiddle, TimelineStart, } from "./components/timeline";
|
|
87
87
|
export { default as Toast } from "./components/toast";
|
|
88
|
-
export { ToastContainer } from "./components/toastcontainer";
|
|
88
|
+
export { ToastContainer, ToastStack } from "./components/toastcontainer";
|
|
89
|
+
export type { ToastRenderer, ToastStackProps, } from "./components/toastcontainer";
|
|
89
90
|
export { default as Toggle } from "./components/toggle";
|
|
90
91
|
export { default as Tooltip } from "./components/tooltip";
|
|
91
92
|
export { default as WindowMockup, type WindowMockupProps, } from "./components/windowmockup";
|
|
92
93
|
export * from "./stores";
|
|
94
|
+
export * from "./motion";
|
|
93
95
|
export { default } from "./components/connectionstatus";
|
package/dist/index.js
CHANGED
|
@@ -269,19 +269,19 @@ function twJoin() {
|
|
|
269
269
|
let resolvedValue;
|
|
270
270
|
let string = '';
|
|
271
271
|
while(index < arguments.length)if (argument = arguments[index++]) {
|
|
272
|
-
if (resolvedValue =
|
|
272
|
+
if (resolvedValue = bundle_mjs_toValue(argument)) {
|
|
273
273
|
string && (string += ' ');
|
|
274
274
|
string += resolvedValue;
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
277
|
return string;
|
|
278
278
|
}
|
|
279
|
-
const
|
|
279
|
+
const bundle_mjs_toValue = (mix)=>{
|
|
280
280
|
if ('string' == typeof mix) return mix;
|
|
281
281
|
let resolvedValue;
|
|
282
282
|
let string = '';
|
|
283
283
|
for(let k = 0; k < mix.length; k++)if (mix[k]) {
|
|
284
|
-
if (resolvedValue =
|
|
284
|
+
if (resolvedValue = bundle_mjs_toValue(mix[k])) {
|
|
285
285
|
string && (string += ' ');
|
|
286
286
|
string += resolvedValue;
|
|
287
287
|
}
|
|
@@ -12707,8 +12707,448 @@ const Toast = (props)=>{
|
|
|
12707
12707
|
})();
|
|
12708
12708
|
};
|
|
12709
12709
|
const toast_Toast = Toast;
|
|
12710
|
+
const prefersReducedMotion = ()=>globalThis.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches ?? false;
|
|
12711
|
+
const motionDurations = {
|
|
12712
|
+
route: 0.18,
|
|
12713
|
+
routeAuth: 0.35,
|
|
12714
|
+
fast: 0.2,
|
|
12715
|
+
base: 0.3,
|
|
12716
|
+
slow: 0.45
|
|
12717
|
+
};
|
|
12718
|
+
const motionEasings = {
|
|
12719
|
+
out: "ease-out",
|
|
12720
|
+
inOut: "ease-in-out"
|
|
12721
|
+
};
|
|
12722
|
+
const motionDistances = {
|
|
12723
|
+
sm: 6,
|
|
12724
|
+
md: 12,
|
|
12725
|
+
lg: 20,
|
|
12726
|
+
slideIn: 40
|
|
12727
|
+
};
|
|
12728
|
+
const defaultMotionTokens = {
|
|
12729
|
+
durations: {
|
|
12730
|
+
...motionDurations
|
|
12731
|
+
},
|
|
12732
|
+
easings: {
|
|
12733
|
+
...motionEasings
|
|
12734
|
+
},
|
|
12735
|
+
distances: {
|
|
12736
|
+
...motionDistances
|
|
12737
|
+
}
|
|
12738
|
+
};
|
|
12739
|
+
const mergeDefined = (base, overrides)=>{
|
|
12740
|
+
const next = {
|
|
12741
|
+
...base
|
|
12742
|
+
};
|
|
12743
|
+
if (!overrides) return next;
|
|
12744
|
+
for (const [key, value] of Object.entries(overrides))if (void 0 !== value) next[key] = value;
|
|
12745
|
+
return next;
|
|
12746
|
+
};
|
|
12747
|
+
const mergeMotionTokens = (base, overrides)=>({
|
|
12748
|
+
durations: mergeDefined(base.durations, overrides?.durations),
|
|
12749
|
+
easings: mergeDefined(base.easings, overrides?.easings),
|
|
12750
|
+
distances: mergeDefined(base.distances, overrides?.distances)
|
|
12751
|
+
});
|
|
12752
|
+
const createMotionPresets = (tokens)=>{
|
|
12753
|
+
const durations = tokens.durations;
|
|
12754
|
+
const easings = tokens.easings;
|
|
12755
|
+
const distances = tokens.distances;
|
|
12756
|
+
return {
|
|
12757
|
+
route: {
|
|
12758
|
+
initial: {
|
|
12759
|
+
opacity: 0
|
|
12760
|
+
},
|
|
12761
|
+
animate: {
|
|
12762
|
+
opacity: 1
|
|
12763
|
+
},
|
|
12764
|
+
exit: {
|
|
12765
|
+
opacity: 0
|
|
12766
|
+
},
|
|
12767
|
+
transition: {
|
|
12768
|
+
duration: durations.route,
|
|
12769
|
+
easing: easings.out
|
|
12770
|
+
}
|
|
12771
|
+
},
|
|
12772
|
+
routeAuth: {
|
|
12773
|
+
initial: {
|
|
12774
|
+
opacity: 0,
|
|
12775
|
+
x: distances.slideIn
|
|
12776
|
+
},
|
|
12777
|
+
animate: {
|
|
12778
|
+
opacity: 1,
|
|
12779
|
+
x: 0
|
|
12780
|
+
},
|
|
12781
|
+
exit: {
|
|
12782
|
+
opacity: 0,
|
|
12783
|
+
x: -distances.slideIn
|
|
12784
|
+
},
|
|
12785
|
+
transition: {
|
|
12786
|
+
duration: durations.routeAuth,
|
|
12787
|
+
easing: easings.inOut
|
|
12788
|
+
}
|
|
12789
|
+
},
|
|
12790
|
+
routeAuthBack: {
|
|
12791
|
+
initial: {
|
|
12792
|
+
opacity: 0,
|
|
12793
|
+
x: -distances.slideIn
|
|
12794
|
+
},
|
|
12795
|
+
animate: {
|
|
12796
|
+
opacity: 1,
|
|
12797
|
+
x: 0
|
|
12798
|
+
},
|
|
12799
|
+
exit: {
|
|
12800
|
+
opacity: 0,
|
|
12801
|
+
x: distances.slideIn
|
|
12802
|
+
},
|
|
12803
|
+
transition: {
|
|
12804
|
+
duration: durations.routeAuth,
|
|
12805
|
+
easing: easings.inOut
|
|
12806
|
+
}
|
|
12807
|
+
},
|
|
12808
|
+
authSwap: {
|
|
12809
|
+
initial: {
|
|
12810
|
+
opacity: 0.92
|
|
12811
|
+
},
|
|
12812
|
+
animate: {
|
|
12813
|
+
opacity: 1
|
|
12814
|
+
},
|
|
12815
|
+
exit: {
|
|
12816
|
+
opacity: 0.92
|
|
12817
|
+
},
|
|
12818
|
+
transition: {
|
|
12819
|
+
duration: durations.fast,
|
|
12820
|
+
easing: easings.out
|
|
12821
|
+
}
|
|
12822
|
+
},
|
|
12823
|
+
fade: {
|
|
12824
|
+
initial: {
|
|
12825
|
+
opacity: 0
|
|
12826
|
+
},
|
|
12827
|
+
animate: {
|
|
12828
|
+
opacity: 1
|
|
12829
|
+
},
|
|
12830
|
+
exit: {
|
|
12831
|
+
opacity: 0
|
|
12832
|
+
},
|
|
12833
|
+
transition: {
|
|
12834
|
+
duration: durations.base,
|
|
12835
|
+
easing: easings.out,
|
|
12836
|
+
delay: 0.08
|
|
12837
|
+
}
|
|
12838
|
+
},
|
|
12839
|
+
fadeUp: {
|
|
12840
|
+
initial: {
|
|
12841
|
+
opacity: 0,
|
|
12842
|
+
y: distances.sm
|
|
12843
|
+
},
|
|
12844
|
+
animate: {
|
|
12845
|
+
opacity: 1,
|
|
12846
|
+
y: 0
|
|
12847
|
+
},
|
|
12848
|
+
exit: {
|
|
12849
|
+
opacity: 0,
|
|
12850
|
+
y: -distances.sm
|
|
12851
|
+
},
|
|
12852
|
+
transition: {
|
|
12853
|
+
duration: durations.base,
|
|
12854
|
+
easing: easings.out,
|
|
12855
|
+
delay: 0.08
|
|
12856
|
+
}
|
|
12857
|
+
},
|
|
12858
|
+
scaleIn: {
|
|
12859
|
+
initial: {
|
|
12860
|
+
opacity: 0,
|
|
12861
|
+
scale: 0.96
|
|
12862
|
+
},
|
|
12863
|
+
animate: {
|
|
12864
|
+
opacity: 1,
|
|
12865
|
+
scale: 1
|
|
12866
|
+
},
|
|
12867
|
+
exit: {
|
|
12868
|
+
opacity: 0,
|
|
12869
|
+
scale: 0.96
|
|
12870
|
+
},
|
|
12871
|
+
transition: {
|
|
12872
|
+
duration: durations.fast,
|
|
12873
|
+
easing: easings.out,
|
|
12874
|
+
delay: 0.08
|
|
12875
|
+
}
|
|
12876
|
+
},
|
|
12877
|
+
toast: {
|
|
12878
|
+
initial: {
|
|
12879
|
+
opacity: 0,
|
|
12880
|
+
y: distances.sm
|
|
12881
|
+
},
|
|
12882
|
+
animate: {
|
|
12883
|
+
opacity: 1,
|
|
12884
|
+
y: 0
|
|
12885
|
+
},
|
|
12886
|
+
exit: {
|
|
12887
|
+
opacity: 0,
|
|
12888
|
+
y: -distances.sm
|
|
12889
|
+
},
|
|
12890
|
+
transition: {
|
|
12891
|
+
duration: durations.fast,
|
|
12892
|
+
easing: easings.out
|
|
12893
|
+
}
|
|
12894
|
+
},
|
|
12895
|
+
routeDashboard: {
|
|
12896
|
+
initial: {
|
|
12897
|
+
opacity: 0,
|
|
12898
|
+
y: distances.md,
|
|
12899
|
+
scale: 0.985
|
|
12900
|
+
},
|
|
12901
|
+
animate: {
|
|
12902
|
+
opacity: 1,
|
|
12903
|
+
y: 0,
|
|
12904
|
+
scale: 1
|
|
12905
|
+
},
|
|
12906
|
+
exit: {
|
|
12907
|
+
opacity: 0,
|
|
12908
|
+
y: -distances.sm,
|
|
12909
|
+
scale: 0.985
|
|
12910
|
+
},
|
|
12911
|
+
transition: {
|
|
12912
|
+
duration: durations.route,
|
|
12913
|
+
easing: easings.out
|
|
12914
|
+
}
|
|
12915
|
+
}
|
|
12916
|
+
};
|
|
12917
|
+
};
|
|
12918
|
+
const motionPresets = createMotionPresets(defaultMotionTokens);
|
|
12919
|
+
const routeTransition = motionPresets.route;
|
|
12920
|
+
const noMotion = {
|
|
12921
|
+
initial: {
|
|
12922
|
+
opacity: 1,
|
|
12923
|
+
y: 0,
|
|
12924
|
+
x: 0,
|
|
12925
|
+
scale: 1
|
|
12926
|
+
},
|
|
12927
|
+
animate: {
|
|
12928
|
+
opacity: 1,
|
|
12929
|
+
y: 0,
|
|
12930
|
+
x: 0,
|
|
12931
|
+
scale: 1
|
|
12932
|
+
},
|
|
12933
|
+
exit: {
|
|
12934
|
+
opacity: 1,
|
|
12935
|
+
y: 0,
|
|
12936
|
+
x: 0,
|
|
12937
|
+
scale: 1
|
|
12938
|
+
},
|
|
12939
|
+
transition: {
|
|
12940
|
+
duration: 0
|
|
12941
|
+
}
|
|
12942
|
+
};
|
|
12943
|
+
const presets_getPreset = (name)=>motionPresets[name];
|
|
12944
|
+
const presets_registerPreset = (name, preset)=>{
|
|
12945
|
+
motionPresets[name] = preset;
|
|
12946
|
+
};
|
|
12947
|
+
const presets_resolvePreset = (name, options)=>{
|
|
12948
|
+
const reduce = options?.reduceMotion ?? prefersReducedMotion();
|
|
12949
|
+
if (reduce) return noMotion;
|
|
12950
|
+
return motionPresets[name] ?? noMotion;
|
|
12951
|
+
};
|
|
12952
|
+
const immediateDriver = ({ to, onUpdate, onComplete })=>{
|
|
12953
|
+
onUpdate(to);
|
|
12954
|
+
onComplete?.();
|
|
12955
|
+
return {
|
|
12956
|
+
stop: ()=>{}
|
|
12957
|
+
};
|
|
12958
|
+
};
|
|
12959
|
+
let activeDriver = immediateDriver;
|
|
12960
|
+
const setMotionDriver = (driver)=>{
|
|
12961
|
+
activeDriver = driver;
|
|
12962
|
+
};
|
|
12963
|
+
const getMotionDriver = ()=>activeDriver;
|
|
12964
|
+
const easeOutCubic = (t)=>1 - Math.pow(1 - t, 3);
|
|
12965
|
+
const easeInCubic = (t)=>t * t * t;
|
|
12966
|
+
const easeInOutCubic = (t)=>t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
|
|
12967
|
+
const resolveEase = (easing)=>{
|
|
12968
|
+
if ("function" == typeof easing) return easing;
|
|
12969
|
+
switch(easing){
|
|
12970
|
+
case "ease-in":
|
|
12971
|
+
return easeInCubic;
|
|
12972
|
+
case "ease-in-out":
|
|
12973
|
+
return easeInOutCubic;
|
|
12974
|
+
case "linear":
|
|
12975
|
+
return (t)=>t;
|
|
12976
|
+
case "ease-out":
|
|
12977
|
+
default:
|
|
12978
|
+
return easeOutCubic;
|
|
12979
|
+
}
|
|
12980
|
+
};
|
|
12981
|
+
const resolveDuration = (transition)=>Math.max(0, (transition?.duration ?? 0) * 1000);
|
|
12982
|
+
const resolveDelay = (transition)=>Math.max(0, (transition?.delay ?? 0) * 1000);
|
|
12983
|
+
const readOpacity = (el)=>{
|
|
12984
|
+
const value = Number.parseFloat(getComputedStyle(el).opacity);
|
|
12985
|
+
return Number.isFinite(value) ? value : 1;
|
|
12986
|
+
};
|
|
12987
|
+
const runMotion = (el, from, to, transition, onComplete)=>{
|
|
12988
|
+
const duration = resolveDuration(transition);
|
|
12989
|
+
const delay = resolveDelay(transition);
|
|
12990
|
+
const ease = resolveEase(transition?.easing);
|
|
12991
|
+
const driver = getMotionDriver();
|
|
12992
|
+
const controls = [];
|
|
12993
|
+
const shouldTransform = void 0 !== from.x || void 0 !== from.y || void 0 !== from.scale || void 0 !== to.x || void 0 !== to.y || void 0 !== to.scale;
|
|
12994
|
+
const transformState = {
|
|
12995
|
+
x: from.x ?? 0,
|
|
12996
|
+
y: from.y ?? 0,
|
|
12997
|
+
scale: from.scale ?? 1
|
|
12998
|
+
};
|
|
12999
|
+
const applyTransform = ()=>{
|
|
13000
|
+
if (!shouldTransform) return;
|
|
13001
|
+
el.style.transform = `translate3d(${transformState.x}px, ${transformState.y}px, 0) scale(${transformState.scale})`;
|
|
13002
|
+
};
|
|
13003
|
+
if (void 0 !== from.opacity) el.style.opacity = String(from.opacity);
|
|
13004
|
+
applyTransform();
|
|
13005
|
+
const animationTargets = Object.keys(to);
|
|
13006
|
+
if (0 === animationTargets.length) {
|
|
13007
|
+
onComplete?.();
|
|
13008
|
+
return {
|
|
13009
|
+
stop: ()=>{}
|
|
13010
|
+
};
|
|
13011
|
+
}
|
|
13012
|
+
let remaining = animationTargets.length;
|
|
13013
|
+
const handleComplete = ()=>{
|
|
13014
|
+
remaining -= 1;
|
|
13015
|
+
if (remaining <= 0) onComplete?.();
|
|
13016
|
+
};
|
|
13017
|
+
const start = ()=>{
|
|
13018
|
+
animationTargets.forEach((key)=>{
|
|
13019
|
+
if ("opacity" === key) {
|
|
13020
|
+
const fromValue = from.opacity ?? (void 0 !== to.opacity ? readOpacity(el) : 1);
|
|
13021
|
+
const control = driver({
|
|
13022
|
+
from: fromValue,
|
|
13023
|
+
to: to.opacity ?? fromValue,
|
|
13024
|
+
duration,
|
|
13025
|
+
ease,
|
|
13026
|
+
onUpdate: (latest)=>{
|
|
13027
|
+
el.style.opacity = String(latest);
|
|
13028
|
+
},
|
|
13029
|
+
onComplete: handleComplete
|
|
13030
|
+
});
|
|
13031
|
+
controls.push(control);
|
|
13032
|
+
return;
|
|
13033
|
+
}
|
|
13034
|
+
const fromValue = "scale" === key ? from.scale ?? 1 : "x" === key ? from.x ?? 0 : from.y ?? 0;
|
|
13035
|
+
const toValue = to[key] ?? fromValue;
|
|
13036
|
+
const control = driver({
|
|
13037
|
+
from: fromValue,
|
|
13038
|
+
to: toValue,
|
|
13039
|
+
duration,
|
|
13040
|
+
ease,
|
|
13041
|
+
onUpdate: (latest)=>{
|
|
13042
|
+
if (!shouldTransform) return;
|
|
13043
|
+
if ("x" === key) transformState.x = latest;
|
|
13044
|
+
if ("y" === key) transformState.y = latest;
|
|
13045
|
+
if ("scale" === key) transformState.scale = latest;
|
|
13046
|
+
applyTransform();
|
|
13047
|
+
},
|
|
13048
|
+
onComplete: handleComplete
|
|
13049
|
+
});
|
|
13050
|
+
controls.push(control);
|
|
13051
|
+
});
|
|
13052
|
+
};
|
|
13053
|
+
let timeoutId = null;
|
|
13054
|
+
if (delay > 0) timeoutId = window.setTimeout(start, delay);
|
|
13055
|
+
else start();
|
|
13056
|
+
return {
|
|
13057
|
+
stop: ()=>{
|
|
13058
|
+
if (null !== timeoutId) clearTimeout(timeoutId);
|
|
13059
|
+
controls.forEach((control)=>control.stop());
|
|
13060
|
+
}
|
|
13061
|
+
};
|
|
13062
|
+
};
|
|
13063
|
+
var MotionDiv_tmpl$ = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.template)("<div>");
|
|
13064
|
+
const MotionDiv_MotionDiv = (props)=>{
|
|
13065
|
+
const [local, rest] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.splitProps)(props, [
|
|
13066
|
+
"initial",
|
|
13067
|
+
"animate",
|
|
13068
|
+
"exit",
|
|
13069
|
+
"transition",
|
|
13070
|
+
"isExiting",
|
|
13071
|
+
"onExitComplete",
|
|
13072
|
+
"animateKey",
|
|
13073
|
+
"children",
|
|
13074
|
+
"ref"
|
|
13075
|
+
]);
|
|
13076
|
+
const [elementRef, setElementRef] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)(void 0);
|
|
13077
|
+
let activeControl = null;
|
|
13078
|
+
let lastTrigger;
|
|
13079
|
+
let lastIsExiting = false;
|
|
13080
|
+
let hasAnimated = false;
|
|
13081
|
+
const stopActive = ()=>{
|
|
13082
|
+
activeControl?.stop();
|
|
13083
|
+
activeControl = null;
|
|
13084
|
+
};
|
|
13085
|
+
const runEnter = (target, from, to, transition)=>{
|
|
13086
|
+
if (!to) return;
|
|
13087
|
+
stopActive();
|
|
13088
|
+
activeControl = runMotion(target, from ?? {}, to ?? {}, transition);
|
|
13089
|
+
};
|
|
13090
|
+
const runExit = (target, from, to, transition, onComplete)=>{
|
|
13091
|
+
if (!to) return void onComplete?.();
|
|
13092
|
+
stopActive();
|
|
13093
|
+
activeControl = runMotion(target, from ?? {}, to ?? {}, transition, onComplete);
|
|
13094
|
+
};
|
|
13095
|
+
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createEffect)(()=>{
|
|
13096
|
+
const target = elementRef();
|
|
13097
|
+
if (!target) return;
|
|
13098
|
+
const isExiting = Boolean(local.isExiting);
|
|
13099
|
+
const trigger = local.animateKey;
|
|
13100
|
+
const initial = local.initial;
|
|
13101
|
+
const animate = local.animate;
|
|
13102
|
+
const exit = local.exit;
|
|
13103
|
+
const transition = local.transition;
|
|
13104
|
+
const onComplete = local.onExitComplete;
|
|
13105
|
+
if (isExiting) {
|
|
13106
|
+
if (!lastIsExiting) {
|
|
13107
|
+
lastIsExiting = true;
|
|
13108
|
+
hasAnimated = false;
|
|
13109
|
+
runExit(target, animate ?? initial, exit, transition, onComplete);
|
|
13110
|
+
}
|
|
13111
|
+
return;
|
|
13112
|
+
}
|
|
13113
|
+
lastIsExiting = false;
|
|
13114
|
+
if (!hasAnimated || trigger !== lastTrigger) {
|
|
13115
|
+
lastTrigger = trigger;
|
|
13116
|
+
hasAnimated = true;
|
|
13117
|
+
runEnter(target, initial, animate, transition);
|
|
13118
|
+
}
|
|
13119
|
+
});
|
|
13120
|
+
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.onCleanup)(()=>{
|
|
13121
|
+
stopActive();
|
|
13122
|
+
});
|
|
13123
|
+
return (()=>{
|
|
13124
|
+
var _el$ = MotionDiv_tmpl$();
|
|
13125
|
+
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.use)((el)=>{
|
|
13126
|
+
setElementRef(el);
|
|
13127
|
+
if ("function" == typeof local.ref) local.ref(el);
|
|
13128
|
+
}, _el$);
|
|
13129
|
+
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.spread)(_el$, rest, false, true);
|
|
13130
|
+
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.insert)(_el$, ()=>local.children);
|
|
13131
|
+
return _el$;
|
|
13132
|
+
})();
|
|
13133
|
+
};
|
|
13134
|
+
const MotionDiv = MotionDiv_MotionDiv;
|
|
12710
13135
|
const [toasts, setToasts] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)([]);
|
|
12711
13136
|
let toastCounter = 0;
|
|
13137
|
+
const toastTimers = new Map();
|
|
13138
|
+
const clearToastTimer = (id)=>{
|
|
13139
|
+
const timer = toastTimers.get(id);
|
|
13140
|
+
if (!timer) return;
|
|
13141
|
+
clearTimeout(timer);
|
|
13142
|
+
toastTimers.delete(id);
|
|
13143
|
+
};
|
|
13144
|
+
const scheduleDismiss = (id, duration)=>{
|
|
13145
|
+
if (duration <= 0) return;
|
|
13146
|
+
clearToastTimer(id);
|
|
13147
|
+
const timer = setTimeout(()=>{
|
|
13148
|
+
toastStore.dismissToast(id);
|
|
13149
|
+
}, duration);
|
|
13150
|
+
toastTimers.set(id, timer);
|
|
13151
|
+
};
|
|
12712
13152
|
const toastStore = {
|
|
12713
13153
|
toasts,
|
|
12714
13154
|
addToast: (message, type = "info", duration = 8000)=>{
|
|
@@ -12717,21 +13157,30 @@ const toastStore = {
|
|
|
12717
13157
|
id,
|
|
12718
13158
|
message,
|
|
12719
13159
|
type,
|
|
12720
|
-
timestamp: Date.now()
|
|
13160
|
+
timestamp: Date.now(),
|
|
13161
|
+
duration
|
|
12721
13162
|
};
|
|
12722
13163
|
setToasts((prev)=>[
|
|
12723
13164
|
...prev,
|
|
12724
13165
|
toast
|
|
12725
13166
|
]);
|
|
12726
|
-
|
|
12727
|
-
toastStore.removeToast(id);
|
|
12728
|
-
}, duration);
|
|
13167
|
+
scheduleDismiss(id, duration);
|
|
12729
13168
|
return id;
|
|
12730
13169
|
},
|
|
13170
|
+
dismissToast: (id)=>{
|
|
13171
|
+
clearToastTimer(id);
|
|
13172
|
+
setToasts((prev)=>prev.map((toast)=>toast.id !== id || toast.isExiting ? toast : {
|
|
13173
|
+
...toast,
|
|
13174
|
+
isExiting: true
|
|
13175
|
+
}));
|
|
13176
|
+
},
|
|
12731
13177
|
removeToast: (id)=>{
|
|
13178
|
+
clearToastTimer(id);
|
|
12732
13179
|
setToasts((prev)=>prev.filter((toast)=>toast.id !== id));
|
|
12733
13180
|
},
|
|
12734
13181
|
clearAll: ()=>{
|
|
13182
|
+
toastTimers.forEach((timer)=>clearTimeout(timer));
|
|
13183
|
+
toastTimers.clear();
|
|
12735
13184
|
setToasts([]);
|
|
12736
13185
|
},
|
|
12737
13186
|
showError: (message)=>toastStore.addToast(message, "error", 10000),
|
|
@@ -12739,42 +13188,166 @@ const toastStore = {
|
|
|
12739
13188
|
showWarning: (message)=>toastStore.addToast(message, "warning", 8000),
|
|
12740
13189
|
showInfo: (message)=>toastStore.addToast(message, "info", 6000)
|
|
12741
13190
|
};
|
|
12742
|
-
var
|
|
12743
|
-
const
|
|
13191
|
+
var ToastStack_tmpl$ = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.template)("<span class=flex-1>"), ToastStack_tmpl$2 = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.template)("<div>");
|
|
13192
|
+
const defaultRenderToast = (toast, dismiss)=>(0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.createComponent)(alert_Alert, {
|
|
13193
|
+
get status () {
|
|
13194
|
+
return toast.type;
|
|
13195
|
+
},
|
|
13196
|
+
class: "flex justify-between items-center gap-4",
|
|
13197
|
+
style: {
|
|
13198
|
+
"min-width": "20rem",
|
|
13199
|
+
"max-width": "32rem"
|
|
13200
|
+
},
|
|
12744
13201
|
get children () {
|
|
12745
|
-
return
|
|
13202
|
+
return [
|
|
13203
|
+
(()=>{
|
|
13204
|
+
var _el$ = ToastStack_tmpl$();
|
|
13205
|
+
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.insert)(_el$, ()=>toast.message);
|
|
13206
|
+
return _el$;
|
|
13207
|
+
})(),
|
|
13208
|
+
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.createComponent)(button_Button, {
|
|
13209
|
+
size: "sm",
|
|
13210
|
+
color: "ghost",
|
|
13211
|
+
onClick: (event)=>{
|
|
13212
|
+
event.stopPropagation();
|
|
13213
|
+
dismiss();
|
|
13214
|
+
},
|
|
13215
|
+
class: "ml-2 opacity-70 hover:opacity-100",
|
|
13216
|
+
"aria-label": "Dismiss notification",
|
|
13217
|
+
children: "x"
|
|
13218
|
+
})
|
|
13219
|
+
];
|
|
13220
|
+
}
|
|
13221
|
+
});
|
|
13222
|
+
const ToastStack_ToastStack = (props)=>{
|
|
13223
|
+
const [local, rest] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.splitProps)(props, [
|
|
13224
|
+
"motionPreset",
|
|
13225
|
+
"motionPresetName",
|
|
13226
|
+
"reduceMotion",
|
|
13227
|
+
"renderToast",
|
|
13228
|
+
"max",
|
|
13229
|
+
"expandOnClick",
|
|
13230
|
+
"collapsedCount",
|
|
13231
|
+
"collapsedOffset",
|
|
13232
|
+
"collapsedScale"
|
|
13233
|
+
]);
|
|
13234
|
+
const [expanded, setExpanded] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)(false);
|
|
13235
|
+
const resolvedPreset = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createMemo)(()=>{
|
|
13236
|
+
if (local.motionPreset) return local.motionPreset;
|
|
13237
|
+
const name = local.motionPresetName ?? "toast";
|
|
13238
|
+
return presets_resolvePreset(name, {
|
|
13239
|
+
reduceMotion: local.reduceMotion
|
|
13240
|
+
});
|
|
13241
|
+
});
|
|
13242
|
+
const visibleToasts = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createMemo)(()=>{
|
|
13243
|
+
const list = toastStore.toasts();
|
|
13244
|
+
if (local.max && local.max > 0) return list.slice(-local.max);
|
|
13245
|
+
return list;
|
|
13246
|
+
});
|
|
13247
|
+
const allowCollapse = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createMemo)(()=>{
|
|
13248
|
+
if (false === local.expandOnClick) return false;
|
|
13249
|
+
return visibleToasts().length > 1;
|
|
13250
|
+
});
|
|
13251
|
+
const isExpanded = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createMemo)(()=>{
|
|
13252
|
+
if (!allowCollapse()) return true;
|
|
13253
|
+
return expanded();
|
|
13254
|
+
});
|
|
13255
|
+
const collapsedCount = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createMemo)(()=>local.collapsedCount ?? 3);
|
|
13256
|
+
const collapsedOffset = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createMemo)(()=>local.collapsedOffset ?? 10);
|
|
13257
|
+
const collapsedScale = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createMemo)(()=>local.collapsedScale ?? 0.02);
|
|
13258
|
+
const stackToasts = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createMemo)(()=>{
|
|
13259
|
+
const list = visibleToasts();
|
|
13260
|
+
if (isExpanded()) return list;
|
|
13261
|
+
const count = collapsedCount();
|
|
13262
|
+
if (count <= 0) return list;
|
|
13263
|
+
return list.slice(-count);
|
|
13264
|
+
});
|
|
13265
|
+
const renderToast = ()=>local.renderToast ?? defaultRenderToast;
|
|
13266
|
+
return (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.createComponent)(toast_Toast, (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.mergeProps)(rest, {
|
|
13267
|
+
get children () {
|
|
13268
|
+
var _el$2 = ToastStack_tmpl$2();
|
|
13269
|
+
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.insert)(_el$2, (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.createComponent)(__WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.For, {
|
|
12746
13270
|
get each () {
|
|
12747
|
-
return
|
|
13271
|
+
return stackToasts();
|
|
12748
13272
|
},
|
|
12749
|
-
children: (toast
|
|
12750
|
-
|
|
12751
|
-
|
|
12752
|
-
|
|
12753
|
-
|
|
12754
|
-
|
|
12755
|
-
|
|
12756
|
-
|
|
12757
|
-
}
|
|
12758
|
-
|
|
12759
|
-
|
|
12760
|
-
|
|
12761
|
-
|
|
12762
|
-
|
|
12763
|
-
|
|
12764
|
-
|
|
12765
|
-
|
|
12766
|
-
|
|
12767
|
-
|
|
12768
|
-
|
|
12769
|
-
|
|
12770
|
-
|
|
12771
|
-
|
|
12772
|
-
|
|
12773
|
-
|
|
12774
|
-
|
|
13273
|
+
children: (toast, index)=>{
|
|
13274
|
+
const isTop = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createMemo)(()=>index() === stackToasts().length - 1);
|
|
13275
|
+
const stackIndex = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createMemo)(()=>stackToasts().length - 1 - index());
|
|
13276
|
+
const onToggle = ()=>{
|
|
13277
|
+
if (!allowCollapse() || !isTop()) return;
|
|
13278
|
+
setExpanded((prev)=>!prev);
|
|
13279
|
+
};
|
|
13280
|
+
const stackStyle = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createMemo)(()=>{
|
|
13281
|
+
if (isExpanded()) return {};
|
|
13282
|
+
const offset = stackIndex() * collapsedOffset();
|
|
13283
|
+
const scale = 1 - stackIndex() * collapsedScale();
|
|
13284
|
+
return {
|
|
13285
|
+
position: "absolute",
|
|
13286
|
+
right: "0",
|
|
13287
|
+
bottom: `${offset}px`,
|
|
13288
|
+
transform: `scale(${scale})`,
|
|
13289
|
+
"transform-origin": "right bottom",
|
|
13290
|
+
"z-index": String(100 + index()),
|
|
13291
|
+
transition: "transform 160ms ease-out"
|
|
13292
|
+
};
|
|
13293
|
+
});
|
|
13294
|
+
return (()=>{
|
|
13295
|
+
var _el$3 = ToastStack_tmpl$2();
|
|
13296
|
+
_el$3.$$click = onToggle;
|
|
13297
|
+
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.insert)(_el$3, (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.createComponent)(MotionDiv, {
|
|
13298
|
+
get initial () {
|
|
13299
|
+
return resolvedPreset().initial;
|
|
13300
|
+
},
|
|
13301
|
+
get animate () {
|
|
13302
|
+
return resolvedPreset().animate;
|
|
13303
|
+
},
|
|
13304
|
+
get exit () {
|
|
13305
|
+
return resolvedPreset().exit;
|
|
13306
|
+
},
|
|
13307
|
+
get transition () {
|
|
13308
|
+
return resolvedPreset().transition;
|
|
13309
|
+
},
|
|
13310
|
+
get isExiting () {
|
|
13311
|
+
return toast.isExiting;
|
|
13312
|
+
},
|
|
13313
|
+
onExitComplete: ()=>toastStore.removeToast(toast.id),
|
|
13314
|
+
get children () {
|
|
13315
|
+
return renderToast()(toast, ()=>toastStore.dismissToast(toast.id));
|
|
13316
|
+
}
|
|
13317
|
+
}));
|
|
13318
|
+
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.effect)((_p$)=>{
|
|
13319
|
+
var _v$3 = isTop() && !isExpanded() ? "cursor-pointer" : void 0, _v$4 = stackStyle();
|
|
13320
|
+
_v$3 !== _p$.e && (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.className)(_el$3, _p$.e = _v$3);
|
|
13321
|
+
_p$.t = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.style)(_el$3, _v$4, _p$.t);
|
|
13322
|
+
return _p$;
|
|
13323
|
+
}, {
|
|
13324
|
+
e: void 0,
|
|
13325
|
+
t: void 0
|
|
13326
|
+
});
|
|
13327
|
+
return _el$3;
|
|
13328
|
+
})();
|
|
13329
|
+
}
|
|
13330
|
+
}));
|
|
13331
|
+
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.effect)((_p$)=>{
|
|
13332
|
+
var _v$ = isExpanded() ? "flex flex-col gap-2" : "relative", _v$2 = isExpanded() ? void 0 : {
|
|
13333
|
+
"min-height": "3rem"
|
|
13334
|
+
};
|
|
13335
|
+
_v$ !== _p$.e && (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.className)(_el$2, _p$.e = _v$);
|
|
13336
|
+
_p$.t = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.style)(_el$2, _v$2, _p$.t);
|
|
13337
|
+
return _p$;
|
|
13338
|
+
}, {
|
|
13339
|
+
e: void 0,
|
|
13340
|
+
t: void 0
|
|
12775
13341
|
});
|
|
13342
|
+
return _el$2;
|
|
12776
13343
|
}
|
|
12777
|
-
});
|
|
13344
|
+
}));
|
|
13345
|
+
};
|
|
13346
|
+
const ToastStack = ToastStack_ToastStack;
|
|
13347
|
+
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.delegateEvents)([
|
|
13348
|
+
"click"
|
|
13349
|
+
]);
|
|
13350
|
+
const ToastContainer = ()=>(0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.createComponent)(ToastStack, {});
|
|
12778
13351
|
var Toggle_tmpl$ = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.template)("<input>");
|
|
12779
13352
|
const Toggle = (props)=>{
|
|
12780
13353
|
const [local, others] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.splitProps)(props, [
|
|
@@ -12923,4 +13496,84 @@ const WindowMockup = (props)=>{
|
|
|
12923
13496
|
})();
|
|
12924
13497
|
};
|
|
12925
13498
|
const windowmockup_WindowMockup = WindowMockup;
|
|
12926
|
-
|
|
13499
|
+
const createPopmotionDriver = (animate)=>(options)=>animate(options);
|
|
13500
|
+
const enablePopmotion = (animate)=>{
|
|
13501
|
+
setMotionDriver(createPopmotionDriver(animate));
|
|
13502
|
+
};
|
|
13503
|
+
const createMotionSystem = (config)=>{
|
|
13504
|
+
let tokens = mergeMotionTokens(defaultMotionTokens, config?.tokens);
|
|
13505
|
+
let customPresets = {
|
|
13506
|
+
...config?.presets ?? {}
|
|
13507
|
+
};
|
|
13508
|
+
let basePresets = createMotionPresets(tokens);
|
|
13509
|
+
let presets = {
|
|
13510
|
+
...basePresets,
|
|
13511
|
+
...customPresets
|
|
13512
|
+
};
|
|
13513
|
+
const reduceMotion = config?.reduceMotion ?? prefersReducedMotion;
|
|
13514
|
+
let noMotionPreset = config?.noMotionPreset ?? noMotion;
|
|
13515
|
+
const rebuildPresets = ()=>{
|
|
13516
|
+
basePresets = createMotionPresets(tokens);
|
|
13517
|
+
presets = {
|
|
13518
|
+
...basePresets,
|
|
13519
|
+
...customPresets
|
|
13520
|
+
};
|
|
13521
|
+
};
|
|
13522
|
+
const getTokens = ()=>tokens;
|
|
13523
|
+
const getPresets = ()=>presets;
|
|
13524
|
+
const getPreset = (name)=>presets[name];
|
|
13525
|
+
const registerPreset = (name, preset)=>{
|
|
13526
|
+
customPresets = {
|
|
13527
|
+
...customPresets,
|
|
13528
|
+
[name]: preset
|
|
13529
|
+
};
|
|
13530
|
+
presets = {
|
|
13531
|
+
...basePresets,
|
|
13532
|
+
...customPresets
|
|
13533
|
+
};
|
|
13534
|
+
};
|
|
13535
|
+
const overrideTokens = (overrides)=>{
|
|
13536
|
+
tokens = mergeMotionTokens(tokens, overrides);
|
|
13537
|
+
rebuildPresets();
|
|
13538
|
+
return tokens;
|
|
13539
|
+
};
|
|
13540
|
+
const resolvePreset = (name, options)=>{
|
|
13541
|
+
const reduce = options?.reduceMotion ?? reduceMotion();
|
|
13542
|
+
if (reduce) return noMotionPreset;
|
|
13543
|
+
return presets[name] ?? noMotionPreset;
|
|
13544
|
+
};
|
|
13545
|
+
const setNoMotionPreset = (preset)=>{
|
|
13546
|
+
noMotionPreset = preset;
|
|
13547
|
+
};
|
|
13548
|
+
return {
|
|
13549
|
+
getTokens,
|
|
13550
|
+
getPresets,
|
|
13551
|
+
getPreset,
|
|
13552
|
+
registerPreset,
|
|
13553
|
+
overrideTokens,
|
|
13554
|
+
resolvePreset,
|
|
13555
|
+
setNoMotionPreset
|
|
13556
|
+
};
|
|
13557
|
+
};
|
|
13558
|
+
const createRouteTransitionResolver = (options)=>{
|
|
13559
|
+
const resolvePreset = options.resolvePreset ?? ((name)=>motionPresets[name]);
|
|
13560
|
+
const reduceMotion = options.reduceMotion ?? prefersReducedMotion;
|
|
13561
|
+
const fallback = options.fallback ?? routeTransition;
|
|
13562
|
+
const reduceMotionPreset = options.reduceMotionPreset ?? noMotion;
|
|
13563
|
+
return (from, to)=>{
|
|
13564
|
+
if (reduceMotion()) return reduceMotionPreset;
|
|
13565
|
+
for (const rule of options.rules){
|
|
13566
|
+
const result = rule(from, to);
|
|
13567
|
+
if (result) {
|
|
13568
|
+
if ("string" == typeof result) {
|
|
13569
|
+
const resolved = resolvePreset(result);
|
|
13570
|
+
if (resolved) return resolved;
|
|
13571
|
+
continue;
|
|
13572
|
+
}
|
|
13573
|
+
return result;
|
|
13574
|
+
}
|
|
13575
|
+
}
|
|
13576
|
+
return fallback ?? noMotion;
|
|
13577
|
+
};
|
|
13578
|
+
};
|
|
13579
|
+
export { accordion_Accordion as Accordion, alert_Alert as Alert, artboard_Artboard as Artboard, avatar as Avatar, background_Background as Background, Badge, bottom_sheet_BottomSheet as BottomSheet, Breadcrumbs, breadcrumbs_BreadcrumbsItem as BreadcrumbsItem, browsermockup_BrowserMockup as BrowserMockup, button_Button as Button, Calendar, card_Card as Card, carousel_Carousel as Carousel, chatbubble_ChatBubble as ChatBubble, checkbox_Checkbox as Checkbox, codemockup_CodeMockup as CodeMockup, CodeMockupLine, collapse_Collapse as Collapse, CollapseContent, CollapseDetails, CollapseTitle, connectionstatus_ConnectionStatus as ConnectionStatus, CopyButton, countdown_Countdown as Countdown, diff_Diff as Diff, divider as Divider, dock as Dock, Drawer, dropdown as Dropdown, EnhancedTable, FileInput, flex_Flex as Flex, footer_Footer as Footer, form_Form as Form, Grid, hero_Hero as Hero, icon_Icon as Icon, indicator_Indicator as Indicator, input as Input, join_Join as Join, kbd_Kbd as Kbd, link_Link as Link, loading_Loading as Loading, mask as Mask, menu_Menu as Menu, modal_Modal as Modal, MotionDiv, navbar_Navbar as Navbar, pagination_Pagination as Pagination, phonemockup_PhoneMockup as PhoneMockup, Progress, props_table_PropsTable as PropsTable, radialprogress_RadialProgress as RadialProgress, radio_Radio as Radio, range_Range as Range, Rating, select_Select as Select, showcase_ShowcaseBlock as ShowcaseBlock, showcase_section_ShowcaseSection as ShowcaseSection, sidenav_Sidenav as Sidenav, sidenav_SidenavButton as SidenavButton, sidenav_SidenavGroup as SidenavGroup, sidenav_SidenavItem as SidenavItem, sidenav_SidenavLink as SidenavLink, sidenav_SidenavMenu as SidenavMenu, skeleton_Skeleton as Skeleton, Stack, stat_card_StatCard as StatCard, stats_Stats as Stats, status_Status as Status, steps as Steps, streaming_table_StreamingTable as StreamingTable, Summary, SvgBackground, Swap, table_Table as Table, tabs_Tabs as Tabs, textarea_Textarea as Textarea, Timeline, timeline_TimelineEnd as TimelineEnd, timeline_TimelineItem as TimelineItem, timeline_TimelineMiddle as TimelineMiddle, timeline_TimelineStart as TimelineStart, toast_Toast as Toast, ToastContainer, ToastStack_ToastStack as ToastStack, toggle_Toggle as Toggle, tooltip_Tooltip as Tooltip, windowmockup_WindowMockup as WindowMockup, createMotionPresets, createMotionSystem, createPopmotionDriver, createRouteTransitionResolver, createStreamingTableStore, connectionstatus_ConnectionStatus as default, defaultMotionTokens, enablePopmotion, getMotionDriver, presets_getPreset as getPreset, immediateDriver, mergeMotionTokens, motionDistances, motionDurations, motionEasings, motionPresets, noMotion, prefersReducedMotion, presets_registerPreset as registerPreset, resolveEase, presets_resolvePreset as resolvePreset, routeTransition, runMotion, setMotionDriver, toastStore, useDesktop, useFormValidation };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type { MotionDriver, MotionDriverOptions, MotionEasing, MotionPreset, MotionState, MotionTransition, MotionTokenOverrides, MotionTokens, } from "./types";
|
|
2
|
+
export { resolveEase } from "./easing";
|
|
3
|
+
export { getMotionDriver, setMotionDriver, immediateDriver } from "./driver";
|
|
4
|
+
export { runMotion } from "./engine";
|
|
5
|
+
export { prefersReducedMotion } from "./reduced-motion";
|
|
6
|
+
export { defaultMotionTokens, mergeMotionTokens, motionDurations, motionDistances, motionEasings, } from "./tokens";
|
|
7
|
+
export { getPreset, createMotionPresets, motionPresets, noMotion, registerPreset, resolvePreset, routeTransition, } from "./presets";
|
|
8
|
+
export { MotionDiv, type MotionDivProps } from "./solid";
|
|
9
|
+
export { createPopmotionDriver, enablePopmotion, type PopmotionAnimate, } from "./popmotion";
|
|
10
|
+
export { createMotionSystem, type MotionSystemConfig } from "./system";
|
|
11
|
+
export { createRouteTransitionResolver, type RouteTransitionRule, type RouteTransitionRuleResult, type RouteTransitionResolverOptions, } from "./route";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { MotionDriver, MotionDriverOptions } from "./types";
|
|
2
|
+
export type PopmotionAnimate = (options: MotionDriverOptions) => {
|
|
3
|
+
stop: () => void;
|
|
4
|
+
};
|
|
5
|
+
export declare const createPopmotionDriver: (animate: PopmotionAnimate) => MotionDriver;
|
|
6
|
+
export declare const enablePopmotion: (animate: PopmotionAnimate) => void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MotionPreset, MotionTokens } from "./types";
|
|
2
|
+
export declare const createMotionPresets: (tokens: MotionTokens) => Record<string, MotionPreset>;
|
|
3
|
+
export declare const motionPresets: Record<string, MotionPreset>;
|
|
4
|
+
export declare const routeTransition: MotionPreset;
|
|
5
|
+
export declare const noMotion: MotionPreset;
|
|
6
|
+
export declare const getPreset: (name: string) => MotionPreset;
|
|
7
|
+
export declare const registerPreset: (name: string, preset: MotionPreset) => void;
|
|
8
|
+
export declare const resolvePreset: (name: string, options?: {
|
|
9
|
+
reduceMotion?: boolean;
|
|
10
|
+
}) => MotionPreset;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const prefersReducedMotion: () => boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { MotionPreset } from "./types";
|
|
2
|
+
export type RouteTransitionRuleResult = MotionPreset | string | null | undefined;
|
|
3
|
+
export type RouteTransitionRule = (from: string, to: string) => RouteTransitionRuleResult;
|
|
4
|
+
export type RouteTransitionResolverOptions = {
|
|
5
|
+
rules: RouteTransitionRule[];
|
|
6
|
+
fallback?: MotionPreset;
|
|
7
|
+
resolvePreset?: (name: string) => MotionPreset | undefined;
|
|
8
|
+
reduceMotion?: () => boolean;
|
|
9
|
+
reduceMotionPreset?: MotionPreset;
|
|
10
|
+
};
|
|
11
|
+
export declare const createRouteTransitionResolver: (options: RouteTransitionResolverOptions) => (from: string, to: string) => MotionPreset;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Component, type JSX } from "solid-js";
|
|
2
|
+
import type { MotionState, MotionTransition } from "../types";
|
|
3
|
+
export interface MotionDivProps extends JSX.HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
initial?: MotionState;
|
|
5
|
+
animate?: MotionState;
|
|
6
|
+
exit?: MotionState;
|
|
7
|
+
transition?: MotionTransition;
|
|
8
|
+
isExiting?: boolean;
|
|
9
|
+
onExitComplete?: () => void;
|
|
10
|
+
animateKey?: unknown;
|
|
11
|
+
}
|
|
12
|
+
export declare const MotionDiv: Component<MotionDivProps>;
|
|
13
|
+
export default MotionDiv;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { MotionPreset, MotionTokenOverrides, MotionTokens } from "./types";
|
|
2
|
+
export type MotionSystemConfig = {
|
|
3
|
+
tokens?: MotionTokenOverrides;
|
|
4
|
+
presets?: Record<string, MotionPreset>;
|
|
5
|
+
reduceMotion?: () => boolean;
|
|
6
|
+
noMotionPreset?: MotionPreset;
|
|
7
|
+
};
|
|
8
|
+
export declare const createMotionSystem: (config?: MotionSystemConfig) => {
|
|
9
|
+
getTokens: () => MotionTokens;
|
|
10
|
+
getPresets: () => {
|
|
11
|
+
[x: string]: MotionPreset;
|
|
12
|
+
};
|
|
13
|
+
getPreset: (name: string) => MotionPreset;
|
|
14
|
+
registerPreset: (name: string, preset: MotionPreset) => void;
|
|
15
|
+
overrideTokens: (overrides: MotionTokenOverrides) => MotionTokens;
|
|
16
|
+
resolvePreset: (name: string, options?: {
|
|
17
|
+
reduceMotion?: boolean;
|
|
18
|
+
}) => MotionPreset;
|
|
19
|
+
setNoMotionPreset: (preset: MotionPreset) => void;
|
|
20
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { MotionEasing, MotionTokens, MotionTokenOverrides } from "./types";
|
|
2
|
+
export declare const motionDurations: Record<string, number>;
|
|
3
|
+
export declare const motionEasings: Record<string, MotionEasing>;
|
|
4
|
+
export declare const motionDistances: Record<string, number>;
|
|
5
|
+
export declare const defaultMotionTokens: MotionTokens;
|
|
6
|
+
export declare const mergeMotionTokens: (base: MotionTokens, overrides?: MotionTokenOverrides) => MotionTokens;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export type MotionState = {
|
|
2
|
+
opacity?: number;
|
|
3
|
+
x?: number;
|
|
4
|
+
y?: number;
|
|
5
|
+
scale?: number;
|
|
6
|
+
};
|
|
7
|
+
export type MotionEasing = "ease-in" | "ease-out" | "ease-in-out" | "linear" | ((t: number) => number);
|
|
8
|
+
export type MotionTransition = {
|
|
9
|
+
duration?: number;
|
|
10
|
+
easing?: MotionEasing;
|
|
11
|
+
delay?: number;
|
|
12
|
+
};
|
|
13
|
+
export type MotionPreset = {
|
|
14
|
+
initial: MotionState;
|
|
15
|
+
animate: MotionState;
|
|
16
|
+
exit: MotionState;
|
|
17
|
+
transition?: MotionTransition;
|
|
18
|
+
};
|
|
19
|
+
export type MotionTokens = {
|
|
20
|
+
durations: Record<string, number>;
|
|
21
|
+
easings: Record<string, MotionEasing>;
|
|
22
|
+
distances: Record<string, number>;
|
|
23
|
+
};
|
|
24
|
+
export type MotionTokenOverrides = {
|
|
25
|
+
durations?: Partial<Record<string, number>>;
|
|
26
|
+
easings?: Partial<Record<string, MotionEasing>>;
|
|
27
|
+
distances?: Partial<Record<string, number>>;
|
|
28
|
+
};
|
|
29
|
+
export type MotionDriverOptions = {
|
|
30
|
+
from: number;
|
|
31
|
+
to: number;
|
|
32
|
+
duration: number;
|
|
33
|
+
ease: (t: number) => number;
|
|
34
|
+
onUpdate: (value: number) => void;
|
|
35
|
+
onComplete?: () => void;
|
|
36
|
+
};
|
|
37
|
+
export type MotionDriver = (options: MotionDriverOptions) => {
|
|
38
|
+
stop: () => void;
|
|
39
|
+
};
|
|
@@ -4,10 +4,13 @@ export interface ToastItem {
|
|
|
4
4
|
message: string;
|
|
5
5
|
type: ToastType;
|
|
6
6
|
timestamp: number;
|
|
7
|
+
duration: number;
|
|
8
|
+
isExiting?: boolean;
|
|
7
9
|
}
|
|
8
10
|
export declare const toastStore: {
|
|
9
11
|
toasts: import("solid-js").Accessor<ToastItem[]>;
|
|
10
12
|
addToast: (message: string, type?: ToastType, duration?: number) => string;
|
|
13
|
+
dismissToast: (id: string) => void;
|
|
11
14
|
removeToast: (id: string) => void;
|
|
12
15
|
clearAll: () => void;
|
|
13
16
|
showError: (message: string) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pathscale/ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.108",
|
|
4
4
|
"author": "pathscale",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -64,8 +64,14 @@
|
|
|
64
64
|
"@felte/validator-zod": "^1.0.0",
|
|
65
65
|
"@tanstack/solid-table": "^8.0.0",
|
|
66
66
|
"solid-js": "^1.9",
|
|
67
|
+
"popmotion": "^11.0.5",
|
|
67
68
|
"zod": "^3.22.0"
|
|
68
69
|
},
|
|
70
|
+
"peerDependenciesMeta": {
|
|
71
|
+
"popmotion": {
|
|
72
|
+
"optional": true
|
|
73
|
+
}
|
|
74
|
+
},
|
|
69
75
|
"scripts": {
|
|
70
76
|
"build": "rslib build && bun scripts/copy-css.js",
|
|
71
77
|
"build:watch": "rslib build --watch",
|