@hamster-note/components 0.2.1-beta.3 → 0.4.0-beta.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/README.md +341 -73
- package/dist/Icon-BuZRZcjv.js +1143 -0
- package/dist/button-mmBNcoG1.js +45 -0
- package/dist/button.js +1 -1
- package/dist/components/button/Button.d.ts +5 -3
- package/dist/components/dialog/Dialog.d.ts +3 -1
- package/dist/components/drawer/Drawer.d.ts +3 -1
- package/dist/components/icon/icon-names.d.ts +1 -15
- package/dist/components/menu/Menu.d.ts +11 -19
- package/dist/components/menu/Menu.placement.test.d.ts +1 -0
- package/dist/components/menu/MenuSubmenu.d.ts +13 -0
- package/dist/components/menu/MenuSurface.d.ts +12 -0
- package/dist/components/menu/menu-tree-context.d.ts +9 -0
- package/dist/components/popover/use-anchor-position.d.ts +16 -1
- package/dist/components/popover/use-anchor-position.test.d.ts +1 -0
- package/dist/components/theme/theme-context.d.ts +10 -0
- package/dist/components/theme/theme.d.ts +1 -87
- package/dist/{confirm-3eBmopl8.js → confirm-DKgVMWkR.js} +4 -5
- package/dist/confirm.js +1 -1
- package/dist/dialog-DI_yumUn.js +102 -0
- package/dist/dialog.js +1 -1
- package/dist/drawer-Cpe3Yf3K.js +120 -0
- package/dist/drawer.js +1 -1
- package/dist/hamster-note-components.css +1 -1
- package/dist/icon-u7jiIYal.js +5 -0
- package/dist/icon.js +2 -1
- package/dist/index.js +10 -9
- package/dist/menu-B4WwCQyw.js +179 -0
- package/dist/menu.js +1 -1
- package/dist/{popover-baLHE3lf.js → popover-D00SlGpL.js} +1 -1
- package/dist/popover.js +1 -1
- package/dist/shared/icon-names.d.ts +15 -0
- package/dist/shared/icons.d.ts +1216 -0
- package/dist/shared/theme.d.ts +87 -0
- package/dist/shared/tokens.d.ts +67 -0
- package/dist/test/fields-and-cards.test.d.ts +1 -0
- package/dist/test/imperative-apis.test.d.ts +1 -0
- package/dist/test/modals.test.d.ts +1 -0
- package/dist/test/primitives.test.d.ts +1 -0
- package/dist/test/setup.d.ts +0 -0
- package/dist/test/shared-data.test.d.ts +1 -0
- package/dist/test/theme-and-popover.test.d.ts +1 -0
- package/dist/{theme-C0p_hpKk.js → theme-DNK-xd31.js} +30 -22
- package/dist/theme-context-CdWvVVP8.js +8 -0
- package/dist/theme.js +1 -1
- package/dist/use-anchor-position-D3QBcIet.js +166 -0
- package/dist-native/badge.d.ts +10 -0
- package/dist-native/badge.js +7 -0
- package/dist-native/button.d.ts +16 -0
- package/dist-native/button.js +7 -0
- package/dist-native/chunk-6RD26X3W.js +78 -0
- package/dist-native/chunk-6SR5ZHDD.js +13 -0
- package/dist-native/chunk-6VYUVVCP.js +27 -0
- package/dist-native/chunk-7LN4VNRB.js +124 -0
- package/dist-native/chunk-CF76TWL4.js +85 -0
- package/dist-native/chunk-ENTYQ6M4.js +256 -0
- package/dist-native/chunk-GSG6CXIE.js +1688 -0
- package/dist-native/chunk-JHT74YG3.js +186 -0
- package/dist-native/chunk-KPDK62A5.js +106 -0
- package/dist-native/chunk-PLFX4RVR.js +134 -0
- package/dist-native/chunk-QUGLAOXA.js +49 -0
- package/dist-native/chunk-S2EUKEYI.js +35 -0
- package/dist-native/chunk-VTE5RPMO.js +38 -0
- package/dist-native/chunk-YJ4H3ZBQ.js +145 -0
- package/dist-native/chunk-ZTQATW6Y.js +127 -0
- package/dist-native/confirm.d.ts +24 -0
- package/dist-native/confirm.js +14 -0
- package/dist-native/dialog.d.ts +8 -0
- package/dist-native/dialog.js +10 -0
- package/dist-native/drawer.d.ts +13 -0
- package/dist-native/drawer.js +10 -0
- package/dist-native/focus-C0k0lLui.d.ts +9 -0
- package/dist-native/icon.d.ts +28 -0
- package/dist-native/icon.js +9 -0
- package/dist-native/index.d.ts +20 -0
- package/dist-native/index.js +84 -0
- package/dist-native/kbd.d.ts +9 -0
- package/dist-native/kbd.js +7 -0
- package/dist-native/loading.d.ts +19 -0
- package/dist-native/loading.js +11 -0
- package/dist-native/menu.d.ts +31 -0
- package/dist-native/menu.js +17 -0
- package/dist-native/modal-panel-BOpp1oRC.d.ts +23 -0
- package/dist-native/note-card.d.ts +13 -0
- package/dist-native/note-card.js +7 -0
- package/dist-native/popover.d.ts +34 -0
- package/dist-native/popover.js +8 -0
- package/dist-native/position-CkPoZ5AD.d.ts +3 -0
- package/dist-native/text-field.d.ts +13 -0
- package/dist-native/text-field.js +7 -0
- package/dist-native/theme.d.ts +120 -0
- package/dist-native/theme.js +16 -0
- package/dist-native/tokens-DHoNd-yT.d.ts +41 -0
- package/package.json +151 -6
- package/dist/button-DRz0VTkf.js +0 -18
- package/dist/dialog-B4xS5zlK.js +0 -53
- package/dist/drawer-DoeuGAHD.js +0 -60
- package/dist/icon-DNZLJUqH.js +0 -517
- package/dist/menu-Dj-Dje_l.js +0 -153
- package/dist/use-anchor-position-DWle8yoL.js +0 -87
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { useLayoutEffect as e, useRef as t, useState as n } from "react";
|
|
2
|
-
//#region src/components/popover/use-anchor-position.ts
|
|
3
|
-
var r = {
|
|
4
|
-
position: "fixed",
|
|
5
|
-
top: 0,
|
|
6
|
-
left: 0,
|
|
7
|
-
visibility: "hidden"
|
|
8
|
-
}, i = {
|
|
9
|
-
top: "bottom",
|
|
10
|
-
bottom: "top",
|
|
11
|
-
left: "right",
|
|
12
|
-
right: "left"
|
|
13
|
-
};
|
|
14
|
-
function a(e) {
|
|
15
|
-
let [t, n] = e.split("-");
|
|
16
|
-
return {
|
|
17
|
-
side: t,
|
|
18
|
-
align: n
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
function o(e, t, n, r, o, s, c) {
|
|
22
|
-
let l = window.innerWidth, u = window.innerHeight, { side: d, align: f } = a(r), p = (r) => {
|
|
23
|
-
switch (r) {
|
|
24
|
-
case "bottom": return e.bottom + o + n > u - c;
|
|
25
|
-
case "top": return e.top - o - n < c;
|
|
26
|
-
case "right": return e.right + o + t > l - c;
|
|
27
|
-
case "left": return e.left - o - t < c;
|
|
28
|
-
}
|
|
29
|
-
}, m = d;
|
|
30
|
-
if (p(d)) {
|
|
31
|
-
let e = i[d];
|
|
32
|
-
p(e) || (m = e);
|
|
33
|
-
}
|
|
34
|
-
let h = 0, g = 0;
|
|
35
|
-
switch (m) {
|
|
36
|
-
case "bottom":
|
|
37
|
-
h = e.bottom + o;
|
|
38
|
-
break;
|
|
39
|
-
case "top":
|
|
40
|
-
h = e.top - o - n;
|
|
41
|
-
break;
|
|
42
|
-
case "right":
|
|
43
|
-
g = e.right + o;
|
|
44
|
-
break;
|
|
45
|
-
case "left":
|
|
46
|
-
g = e.left - o - t;
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
return m === "top" || m === "bottom" ? (g = f === "start" ? e.left : e.right - t, g += s) : (h = f === "start" ? e.top : e.bottom - n, h += s), g = Math.min(Math.max(g, c), Math.max(c, l - t - c)), h = Math.min(Math.max(h, c), Math.max(c, u - n - c)), {
|
|
50
|
-
left: g,
|
|
51
|
-
top: h
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
function s({ anchor: i, placement: a = "bottom-start", offset: s = 6, crossOffset: c = 0, viewportMargin: l = 8 }) {
|
|
55
|
-
let u = t(null), [d, f] = n(r);
|
|
56
|
-
return e(() => {
|
|
57
|
-
if (i === null) return;
|
|
58
|
-
let e = () => {
|
|
59
|
-
let e = u.current;
|
|
60
|
-
if (e === null) return;
|
|
61
|
-
let { left: t, top: n } = o(i.getBoundingClientRect(), e.offsetWidth, e.offsetHeight, a, s, c, l);
|
|
62
|
-
f({
|
|
63
|
-
position: "fixed",
|
|
64
|
-
left: t,
|
|
65
|
-
top: n
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
|
-
e(), window.addEventListener("resize", e), window.addEventListener("scroll", e, !0);
|
|
69
|
-
let t = typeof ResizeObserver > "u" ? null : new ResizeObserver(() => {
|
|
70
|
-
e();
|
|
71
|
-
});
|
|
72
|
-
return t?.observe(i), u.current !== null && t?.observe(u.current), () => {
|
|
73
|
-
window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0), t?.disconnect();
|
|
74
|
-
};
|
|
75
|
-
}, [
|
|
76
|
-
i,
|
|
77
|
-
a,
|
|
78
|
-
s,
|
|
79
|
-
c,
|
|
80
|
-
l
|
|
81
|
-
]), {
|
|
82
|
-
floatingRef: u,
|
|
83
|
-
style: d
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
//#endregion
|
|
87
|
-
export { s as t };
|