ranui 0.1.10-alpha.9 → 0.2.0-alpha.1
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 +397 -0
- package/README.zh-CN.md +216 -37
- package/dist/assets/image/failImage.d.ts +2 -0
- package/dist/bin/generate-component-api.d.ts +1 -0
- package/dist/bin/generate-style-docs.d.ts +1 -0
- package/dist/build/config.bundle.d.ts +2 -0
- package/dist/build/config.d.ts +3 -0
- package/dist/build/config.es.d.ts +2 -0
- package/dist/build/config.umd.d.ts +1 -0
- package/dist/builder.d.ts +11 -0
- package/dist/builder.js +39 -0
- package/dist/button-BstLjXNe.js +117 -0
- package/dist/button.js +3 -5
- package/dist/card-DQUJoDUQ.js +60 -0
- package/dist/card.js +5 -0
- package/dist/checkbox-iHZQb-yQ.js +94 -0
- package/dist/checkbox.js +3 -5
- package/dist/colorpicker-CGh8pRqo.js +315 -0
- package/dist/colorpicker.js +3 -9
- package/dist/components/button/index.d.ts +44 -0
- package/dist/components/card/index.d.ts +21 -0
- package/dist/components/checkbox/index.d.ts +35 -0
- package/dist/components/colorpicker/index.d.ts +99 -0
- package/dist/components/dropdown/index.d.ts +30 -0
- package/dist/components/form/index.d.ts +15 -0
- package/dist/components/icon/index.d.ts +58 -0
- package/dist/components/image/index.d.ts +31 -0
- package/dist/components/input/index.d.ts +222 -0
- package/dist/components/link/index.d.ts +21 -0
- package/dist/components/loading/index.d.ts +76 -0
- package/dist/components/math/index.d.ts +16 -0
- package/dist/components/message/container.d.ts +8 -0
- package/dist/components/message/index.d.ts +32 -0
- package/dist/components/modal/index.d.ts +100 -0
- package/dist/components/player/core/constants.d.ts +5 -0
- package/dist/components/player/core/controller.d.ts +33 -0
- package/dist/components/player/core/events.d.ts +10 -0
- package/dist/components/player/core/fullscreen.d.ts +5 -0
- package/dist/components/player/core/levels.d.ts +20 -0
- package/dist/components/player/core/media.d.ts +50 -0
- package/dist/components/player/core/playback.d.ts +14 -0
- package/dist/components/player/core/progress.d.ts +2 -0
- package/dist/components/player/core/state.d.ts +27 -0
- package/dist/components/player/core/view.d.ts +38 -0
- package/dist/components/player/index.d.ts +276 -0
- package/dist/components/popover/content/index.d.ts +12 -0
- package/dist/components/popover/index.d.ts +93 -0
- package/dist/components/progress/index.d.ts +40 -0
- package/dist/components/radar/index.d.ts +52 -0
- package/dist/components/route/index.d.ts +26 -0
- package/dist/components/router/index.d.ts +24 -0
- package/dist/components/scratch/index.d.ts +19 -0
- package/dist/components/section/index.d.ts +23 -0
- package/dist/components/select/dropdown-item/index.d.ts +21 -0
- package/dist/components/select/index.d.ts +150 -0
- package/dist/components/select/option/index.d.ts +19 -0
- package/dist/components/skeleton/index.d.ts +13 -0
- package/dist/components/tab/index.d.ts +58 -0
- package/dist/components/tabpane/index.d.ts +33 -0
- package/dist/demo/i18n.d.ts +4 -0
- package/dist/demo/index.d.ts +3 -0
- package/dist/demo/register-icons.d.ts +1 -0
- package/dist/dropdown-RqHMRhFE.js +76 -0
- package/dist/dropdown.js +6 -0
- package/dist/events-C59wGdni.js +30 -0
- package/dist/factory-BdsO0dEW.js +165 -0
- package/dist/form-05Lxxl3D.js +44 -0
- package/dist/form.js +5 -0
- package/dist/icon-Blm7AbyY.js +167 -0
- package/dist/icon.js +4 -4
- package/dist/{index-KS2nvVcO.js → image-DKm6z7YQ.js} +60 -71
- package/dist/image.js +3 -2
- package/dist/index.cjs +35 -0
- package/dist/index.d.ts +277 -114
- package/dist/index.iife.js +306 -0
- package/dist/index.js +78 -38
- package/dist/input-Dskw1bAl.js +186 -0
- package/dist/input.js +2 -3
- package/dist/katex-es-BTpuCxxV.cjs +261 -0
- package/dist/katex-es-CKRwcaiU.js +23682 -0
- package/dist/link-BW-gvrpN.js +77 -0
- package/dist/link.js +6 -0
- package/dist/loading-C4QUpm70.js +206 -0
- package/dist/loading.js +4 -6
- package/dist/math-Dv4nXSoI.js +52 -0
- package/dist/math.js +2 -4
- package/dist/message-De5e1txT.js +137 -0
- package/dist/message.js +3 -4
- package/dist/mocks-CMGoftIc.js +179 -0
- package/dist/modal-DruDj3AB.js +350 -0
- package/dist/modal.js +3 -2
- package/dist/player-CqTAmg_E.js +13534 -0
- package/dist/player.js +3 -6
- package/dist/playwright.config.d.ts +2 -0
- package/dist/plugins/load-svg.d.ts +9 -0
- package/dist/popover-BY32HNMl.js +206 -0
- package/dist/popover.js +3 -5
- package/dist/progress-gZo0knzu.js +123 -0
- package/dist/progress.js +3 -5
- package/dist/radar-19P5Mtld.js +181 -0
- package/dist/radar.js +3 -4
- package/dist/ranui.css +1 -0
- package/dist/route-BY_E6-2C.js +88 -0
- package/dist/route.js +6 -0
- package/dist/router-BDcv4F-2.js +79 -0
- package/dist/router.js +6 -0
- package/dist/scratch-Dbd9G6Q6.js +60 -0
- package/dist/scratch.js +4 -0
- package/dist/section-CNTvgdQ-.js +63 -0
- package/dist/section.js +5 -0
- package/dist/select-BVdUtQX5.js +454 -0
- package/dist/select.js +3 -8
- package/dist/signal-XHfNsQNW.js +57 -0
- package/dist/skeleton-BAdJ6vyA.js +32 -0
- package/dist/skeleton.js +3 -2
- package/dist/ssg.js +21 -0
- package/dist/ssr-DSGwPtEd.js +34 -0
- package/dist/ssr-stream.d.ts +1 -0
- package/dist/ssr-stream.js +87 -0
- package/dist/ssr.d.ts +1 -0
- package/dist/ssr.js +7 -0
- package/dist/style.d.ts +1 -0
- package/dist/style.js +0 -0
- package/dist/tab-DH2owP2V.js +184 -0
- package/dist/tab.js +3 -4
- package/dist/tabpane-B_M-Jokw.js +87 -0
- package/dist/tabpane.js +3 -2
- package/dist/test/e2e/button.spec.d.ts +1 -0
- package/dist/test/e2e/checkbox.spec.d.ts +1 -0
- package/dist/test/e2e/helpers.d.ts +13 -0
- package/dist/test/e2e/icon.spec.d.ts +1 -0
- package/dist/test/e2e/image.spec.d.ts +1 -0
- package/dist/test/e2e/input.spec.d.ts +1 -0
- package/dist/test/e2e/loading.spec.d.ts +1 -0
- package/dist/test/e2e/message.spec.d.ts +1 -0
- package/dist/test/e2e/modal.spec.d.ts +1 -0
- package/dist/test/e2e/popover.spec.d.ts +1 -0
- package/dist/test/e2e/progress.spec.d.ts +1 -0
- package/dist/test/e2e/radar.spec.d.ts +1 -0
- package/dist/test/e2e/select.spec.d.ts +1 -0
- package/dist/test/e2e/skeleton.spec.d.ts +1 -0
- package/dist/test/e2e/tab.spec.d.ts +1 -0
- package/dist/test/e2e/visual/colorpicker.spec.d.ts +1 -0
- package/dist/test/e2e/visual/components.spec.d.ts +1 -0
- package/dist/test/e2e/visual/player.spec.d.ts +1 -0
- package/dist/test/integration/composition.test.d.ts +23 -0
- package/dist/test/setup.d.ts +0 -0
- package/dist/test/ssr/builder.core.ssr.test.d.ts +1 -0
- package/dist/test/ssr/builder.factory.ssr.test.d.ts +1 -0
- package/dist/test/ssr/builder.mocks.test.d.ts +1 -0
- package/dist/test/ssr/components/button.test.d.ts +1 -0
- package/dist/test/ssr/css-vars.test.d.ts +1 -0
- package/dist/test/ssr/registry.test.d.ts +1 -0
- package/dist/test/ssr/router.ssg.test.d.ts +2 -0
- package/dist/test/ssr/snapshots/button.test.d.ts +1 -0
- package/dist/test/ssr/stream.test.d.ts +2 -0
- package/dist/test/ssr/theme.tokens.ssr.test.d.ts +1 -0
- package/dist/test/unit/builder.core.browser.test.d.ts +1 -0
- package/dist/test/unit/builder.escape.test.d.ts +1 -0
- package/dist/test/unit/builder.selectors.test.d.ts +1 -0
- package/dist/test/unit/button.contract.test.d.ts +1 -0
- package/dist/test/unit/card.contract.test.d.ts +1 -0
- package/dist/test/unit/checkbox.contract.test.d.ts +1 -0
- package/dist/test/unit/colorpicker.color.utils.test.d.ts +1 -0
- package/dist/test/unit/colorpicker.contract.test.d.ts +1 -0
- package/dist/test/unit/colorpicker.methods.test.d.ts +1 -0
- package/dist/test/unit/component.helpers.test.d.ts +1 -0
- package/dist/test/unit/dropdown-item.contract.test.d.ts +1 -0
- package/dist/test/unit/dropdown.contract.test.d.ts +1 -0
- package/dist/test/unit/form.contract.test.d.ts +1 -0
- package/dist/test/unit/helpers/component.d.ts +3 -0
- package/dist/test/unit/helpers/dom.d.ts +2 -0
- package/dist/test/unit/icon.contract.test.d.ts +1 -0
- package/dist/test/unit/image.contract.test.d.ts +1 -0
- package/dist/test/unit/input.contract.test.d.ts +1 -0
- package/dist/test/unit/link.contract.test.d.ts +1 -0
- package/dist/test/unit/loading.contract.test.d.ts +1 -0
- package/dist/test/unit/math.contract.test.d.ts +1 -0
- package/dist/test/unit/message.component.test.d.ts +1 -0
- package/dist/test/unit/message.container.test.d.ts +1 -0
- package/dist/test/unit/modal.contract.test.d.ts +1 -0
- package/dist/test/unit/option.contract.test.d.ts +1 -0
- package/dist/test/unit/package-exports.source.test.d.ts +1 -0
- package/dist/test/unit/player-controls.test.d.ts +1 -0
- package/dist/test/unit/player-core.test.d.ts +1 -0
- package/dist/test/unit/player-event-handlers.test.d.ts +1 -0
- package/dist/test/unit/player-events.test.d.ts +1 -0
- package/dist/test/unit/player-fullscreen.test.d.ts +1 -0
- package/dist/test/unit/player-interactions.test.d.ts +1 -0
- package/dist/test/unit/player-levels.test.d.ts +1 -0
- package/dist/test/unit/player-media.test.d.ts +1 -0
- package/dist/test/unit/player-playback.test.d.ts +1 -0
- package/dist/test/unit/player.contract.test.d.ts +1 -0
- package/dist/test/unit/popover-accessibility.test.d.ts +1 -0
- package/dist/test/unit/popover.contract.test.d.ts +2 -0
- package/dist/test/unit/progress.contract.test.d.ts +1 -0
- package/dist/test/unit/radar.contract.test.d.ts +1 -0
- package/dist/test/unit/route.contract.test.d.ts +1 -0
- package/dist/test/unit/router.contract.test.d.ts +2 -0
- package/dist/test/unit/scratch.contract.test.d.ts +1 -0
- package/dist/test/unit/select-accessibility.test.d.ts +1 -0
- package/dist/test/unit/select-option.contract.test.d.ts +1 -0
- package/dist/test/unit/select.contract.test.d.ts +1 -0
- package/dist/test/unit/skeleton.contract.test.d.ts +1 -0
- package/dist/test/unit/ssr.test.d.ts +1 -0
- package/dist/test/unit/tab.contract.test.d.ts +2 -0
- package/dist/test/unit/theme.semantic-tokens.test.d.ts +1 -0
- package/dist/test/unit/theme.skin-tokens.test.d.ts +1 -0
- package/dist/test/unit/utils.dom.test.d.ts +1 -0
- package/dist/test/unit/utils.error.test.d.ts +1 -0
- package/dist/test/unit/utils.i18n.test.d.ts +1 -0
- package/dist/test/unit/utils.image.test.d.ts +1 -0
- package/dist/test/unit/utils.math.test.d.ts +1 -0
- package/dist/test/unit/utils.router.test.d.ts +1 -0
- package/dist/test/unit/utils.signal.test.d.ts +1 -0
- package/dist/test/unit/utils.ssr-stream.test.d.ts +1 -0
- package/dist/test/unit/utils.style.test.d.ts +1 -0
- package/dist/test/unit/utils.theme.test.d.ts +1 -0
- package/dist/test/unit/utils.tween.test.d.ts +1 -0
- package/dist/tsconfig.json +8 -8
- package/dist/typings.d.ts +163 -114
- package/dist/utils/builder/core.d.ts +70 -0
- package/dist/utils/builder/env.d.ts +1 -0
- package/dist/utils/builder/escape.d.ts +2 -0
- package/dist/utils/builder/events.d.ts +55 -0
- package/dist/utils/builder/factory.d.ts +18 -0
- package/dist/utils/builder/index.d.ts +9 -0
- package/dist/utils/builder/mocks.d.ts +62 -0
- package/dist/utils/builder/selectors.d.ts +4 -0
- package/dist/utils/builder/signal.d.ts +87 -0
- package/dist/utils/color.d.ts +52 -0
- package/dist/utils/component.d.ts +16 -0
- package/dist/utils/dom.d.ts +39 -0
- package/dist/utils/error.d.ts +6 -0
- package/dist/utils/i18n/index.d.ts +53 -0
- package/dist/utils/i18n.js +88 -0
- package/dist/utils/image.d.ts +39 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/math.d.ts +26 -0
- package/dist/utils/router/index.d.ts +128 -0
- package/dist/utils/router.js +197 -0
- package/dist/utils/ssg.d.ts +49 -0
- package/dist/utils/ssr-registry.d.ts +8 -0
- package/dist/utils/ssr-stream.d.ts +23 -0
- package/dist/utils/ssr.d.ts +17 -0
- package/dist/utils/style.d.ts +12 -0
- package/dist/utils/theme.d.ts +9 -0
- package/dist/utils/tween.d.ts +21 -0
- package/dist/utils/video.d.ts +40 -0
- package/dist/utils-D4pPF77E.js +689 -0
- package/dist/vite.config.d.ts +6 -0
- package/dist/vitest.config.d.ts +2 -0
- package/dist/vitest.config.ssr.d.ts +2 -0
- package/docs/COMPONENTS.md +324 -0
- package/docs/DESIGN.md +198 -0
- package/docs/style-tokens-public.md +880 -0
- package/package.json +137 -78
- package/typings.d.ts +163 -114
- package/dist/_commonjs-dynamic-modules-DLbDWi6a.js +0 -12
- package/dist/add-user-BN1JlY7e.js +0 -4
- package/dist/arrow-down-B_hCY3Wt.js +0 -662
- package/dist/book-nTEFXU2x.js +0 -4
- package/dist/check-circle-fill-B_pd8ZSs.js +0 -4
- package/dist/check-circle-szyAJiap.js +0 -4
- package/dist/close-CFnkhudp.js +0 -4
- package/dist/close-circle-CwmuN2C6.js +0 -4
- package/dist/close-circle-fill-jSqPPw9i.js +0 -4
- package/dist/colz-DJZvo_8B.js +0 -232
- package/dist/docx-CHkPTdGU.js +0 -3665
- package/dist/drop-4j4abxje.js +0 -36
- package/dist/eye-D_mEt17f.js +0 -4
- package/dist/eye-close-BVr3NJtg.js +0 -4
- package/dist/home-BUQ4USMk.js +0 -4
- package/dist/iconShadowless.js +0 -6
- package/dist/index-15M0olqa.js +0 -204
- package/dist/index-1v568_nq.js +0 -140
- package/dist/index-B897keW5.js +0 -279
- package/dist/index-BZR0HaP2.js +0 -40
- package/dist/index-B_GuEcTd.js +0 -9575
- package/dist/index-Bc2Bcl8D.js +0 -63701
- package/dist/index-C4Sv0T51.js +0 -495
- package/dist/index-C6RcMHoH.js +0 -187
- package/dist/index-C9z10IgG.js +0 -103
- package/dist/index-CFjEuvBW.js +0 -308
- package/dist/index-CGEx9VOA.js +0 -17106
- package/dist/index-CGYfjKUV.js +0 -72
- package/dist/index-CQTJoWhb.js +0 -19
- package/dist/index-CiWwvEMM.js +0 -511
- package/dist/index-CkM9ENTf.js +0 -496
- package/dist/index-CtVOgBDk.js +0 -659
- package/dist/index-D4qUro5V.js +0 -279
- package/dist/index-D4y9c1Dj.js +0 -310
- package/dist/index-DAxs7Dd2.js +0 -119
- package/dist/index-DC5EA657.js +0 -91
- package/dist/index-DJZmDHz-.js +0 -146
- package/dist/index-D_CA5VDZ.js +0 -158
- package/dist/index-WfFw4LJT.js +0 -490
- package/dist/index-mhFL9MJp.js +0 -320
- package/dist/info-circle-COnL5bTJ.js +0 -4
- package/dist/info-circle-fill-CFeVMdci.js +0 -4
- package/dist/inputShadowless.js +0 -6
- package/dist/jszip.min-Dhs3nUkD.js +0 -2346
- package/dist/katex-es-B5r5vt3m.js +0 -14628
- package/dist/loading-Dcc5RApI.js +0 -4
- package/dist/loading-scene-BMc2wqKm.js +0 -4
- package/dist/lock-Cr7BnmWN.js +0 -4
- package/dist/message-D36_Zo2l.js +0 -4
- package/dist/pdf-Cx0VWKFo.js +0 -118
- package/dist/power-off-lQRbiBak.js +0 -4
- package/dist/preview-CJbz9GjO.js +0 -4
- package/dist/preview.js +0 -7
- package/dist/selectShadowless.js +0 -564
- package/dist/setting-DemlgzVC.js +0 -4
- package/dist/shadowless.js +0 -8
- package/dist/sprite-CH2zLtZy.js +0 -141
- package/dist/style.css +0 -1
- package/dist/team-tl4NJXPC.js +0 -4
- package/dist/umd/index.umd.cjs +0 -60
- package/dist/umd/shadowless/shadowless.umd.cjs +0 -1
- package/dist/umd/shadowless/style.css +0 -1
- package/dist/umd/style.css +0 -1
- package/dist/unlock-CeU74z9n.js +0 -4
- package/dist/user-B-eVXwuk.js +0 -4
- package/dist/warning-circle-DDUgEDIv.js +0 -4
- package/dist/warning-circle-fill-lODUKz0i.js +0 -4
- package/readme.md +0 -195
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { c as v, d as x, l as m, p as h, s as P, u as y, x as l } from "./utils-D4pPF77E.js";
|
|
2
|
+
import { t as w } from "./events-C59wGdni.js";
|
|
3
|
+
import { i as S, r as p } from "./signal-XHfNsQNW.js";
|
|
4
|
+
import { _ as u, h as A, i as n } from "./factory-BdsO0dEW.js";
|
|
5
|
+
import { a as $, n as _ } from "./ssr-DSGwPtEd.js";
|
|
6
|
+
import "./input-Dskw1bAl.js";
|
|
7
|
+
import "./select-BVdUtQX5.js";
|
|
8
|
+
import "./popover-BY32HNMl.js";
|
|
9
|
+
var D = (e) => {
|
|
10
|
+
const { r: t, g: i, b: r } = I(e);
|
|
11
|
+
return f(t, i, r);
|
|
12
|
+
}, I = (e) => (e[0] === "#" && (e = e.substr(1)), e.length === 3 ? {
|
|
13
|
+
r: parseInt(e[0] + e[0], 16),
|
|
14
|
+
g: parseInt(e[1] + e[1], 16),
|
|
15
|
+
b: parseInt(e[2] + e[2], 16)
|
|
16
|
+
} : {
|
|
17
|
+
r: parseInt(e.substr(0, 2), 16),
|
|
18
|
+
g: parseInt(e.substr(2, 2), 16),
|
|
19
|
+
b: parseInt(e.substr(4, 2), 16)
|
|
20
|
+
}), f = (e, t, i) => {
|
|
21
|
+
let r;
|
|
22
|
+
const o = Math.max(e, t, i), a = o - Math.min(e, t, i);
|
|
23
|
+
a === 0 ? r = 0 : e === o ? r = (t - i) / a % 6 : t === o ? r = (i - e) / a + 2 : r = (e - t) / a + 4, r = Math.round(r * 60), r < 0 && (r += 360);
|
|
24
|
+
const s = Math.round((o === 0 ? 0 : a / o) * 100), c = Math.round(o / 255 * 100);
|
|
25
|
+
return {
|
|
26
|
+
h: r,
|
|
27
|
+
s,
|
|
28
|
+
v: c
|
|
29
|
+
};
|
|
30
|
+
}, b = (e, t, i) => {
|
|
31
|
+
t = t / 100, i = i / 100;
|
|
32
|
+
let r = [];
|
|
33
|
+
const o = i * t, a = e / 60, s = o * (1 - Math.abs(a % 2 - 1)), c = i - o;
|
|
34
|
+
return a >= 0 && a < 1 ? r = [
|
|
35
|
+
o,
|
|
36
|
+
s,
|
|
37
|
+
0
|
|
38
|
+
] : a >= 1 && a < 2 ? r = [
|
|
39
|
+
s,
|
|
40
|
+
o,
|
|
41
|
+
0
|
|
42
|
+
] : a >= 2 && a < 3 ? r = [
|
|
43
|
+
0,
|
|
44
|
+
o,
|
|
45
|
+
s
|
|
46
|
+
] : e >= 3 && a < 4 ? r = [
|
|
47
|
+
0,
|
|
48
|
+
s,
|
|
49
|
+
o
|
|
50
|
+
] : e >= 4 && a < 5 ? r = [
|
|
51
|
+
s,
|
|
52
|
+
0,
|
|
53
|
+
o
|
|
54
|
+
] : e >= 5 && a <= 6 ? r = [
|
|
55
|
+
o,
|
|
56
|
+
0,
|
|
57
|
+
s
|
|
58
|
+
] : r = [
|
|
59
|
+
0,
|
|
60
|
+
0,
|
|
61
|
+
0
|
|
62
|
+
], {
|
|
63
|
+
r: Math.round(255 * (r[0] + c)),
|
|
64
|
+
g: Math.round(255 * (r[1] + c)),
|
|
65
|
+
b: Math.round(255 * (r[2] + c))
|
|
66
|
+
};
|
|
67
|
+
}, k = (e) => {
|
|
68
|
+
const t = e.toString(16);
|
|
69
|
+
return t.length === 1 ? "0" + t : t;
|
|
70
|
+
}, g = (e, t, i) => "#" + [
|
|
71
|
+
k(e),
|
|
72
|
+
k(t),
|
|
73
|
+
k(i)
|
|
74
|
+
].join(""), C = /^#([\da-f]{6}|[\da-f]{3})$/i, E = /^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/, R = /^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),(\d{1,3}(\.\d+)?)\)$/, V = ".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}.ran-colorpicker{box-sizing:border-box;min-width:32px;height:32px;border-radius:var(--ran-colorpicker-border-radius, var(--ran-radius-md, 8px));border:var(--ran-colorpicker-border, 1px solid var(--ran-color-border, #d9d9d9));cursor:pointer;display:inline-flex;align-items:center;justify-content:center;transition:var(--ran-colorpicker-transition, border-color .2s, box-shadow .2s);background:var(--ran-colorpicker-background, var(--ran-color-bg-elevated, #ffffff));padding:3px}.ran-colorpicker:hover{border-color:var(--ran-colorpicker-border-hover, var(--ran-color-border-hover, var(--ran-gray-500)))}.ran-colorpicker-block{position:relative;border-radius:var(--ran-colorpicker-block-border-radius, var(--ran-radius-sm, 4px));width:24px;height:24px;box-shadow:inset 0 0 0 1px var(--ran-gray-alpha-200, rgba(0, 0, 0, .09));background-image:conic-gradient(var(--ran-gray-alpha-100, rgba(0, 0, 0, .06)) 0 25%,transparent 0 50%,var(--ran-gray-alpha-100, rgba(0, 0, 0, .06)) 0 75%,transparent 0);background-size:50% 50%}.ran-colorpicker-inner{width:100%;height:100%;border-radius:inherit}.ran-colorpicker-block[disabled]{cursor:var(--ran-colorpicker-disabled-cursor, not-allowed);opacity:var(--ran-colorpicker-disabled-opacity, .5)}", H = ".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}.ran-color-picker-inner{box-sizing:border-box}.ran-color-picker-inner-content{box-sizing:border-box;display:flex;flex-direction:column;gap:12px;width:224px;padding:12px;font-family:var(--ran-font-family, inherit)}.ran-color-picker-inner-content *,.ran-color-picker-inner-content *:before,.ran-color-picker-inner-content *:after{box-sizing:border-box}.ran-color-picker-palette{position:relative;width:100%;height:160px;border-radius:var(--ran-radius-sm, 6px);overflow:hidden;cursor:crosshair;box-shadow:inset 0 0 0 1px var(--ran-gray-alpha-200, rgba(0, 0, 0, .09));touch-action:none}.ran-color-picker-saturation{position:absolute;inset:0;border-radius:inherit;background-image:linear-gradient(to top,#000,#0000),linear-gradient(to right,#fff,#fff0)}.ran-color-picker-palette-dot{position:absolute;top:0;left:0;z-index:2;width:14px;height:14px;transform:translate(-50%,-50%);border-radius:50%;border:2px solid #fff;box-shadow:0 0 0 1px #0003,0 1px 3px #00000059;pointer-events:none}.ran-color-picker-controls{display:flex;align-items:center;gap:12px}.ran-color-picker-preview{position:relative;flex:none;width:28px;height:28px;border-radius:50%;overflow:hidden;box-shadow:inset 0 0 0 1px var(--ran-gray-alpha-200, rgba(0, 0, 0, .09));background-image:conic-gradient(var(--ran-gray-alpha-100, rgba(0, 0, 0, .06)) 0 25%,transparent 0 50%,var(--ran-gray-alpha-100, rgba(0, 0, 0, .06)) 0 75%,transparent 0);background-size:12px 12px}.ran-color-picker-preview-inner{position:absolute;inset:0;border-radius:inherit}.ran-color-picker-sliders{flex:1;min-width:0;display:flex;flex-direction:column;gap:12px}.ran-color-picker-slider{position:relative;height:10px;border-radius:999px;cursor:pointer;box-shadow:inset 0 0 0 1px var(--ran-gray-alpha-200, rgba(0, 0, 0, .09));touch-action:none}.ran-color-picker-slider-hue{background:linear-gradient(to right,red,#ff0,#0f0,#0ff,#00f,#f0f,red)}.ran-color-picker-slider-alpha{background-image:conic-gradient(var(--ran-gray-alpha-100, rgba(0, 0, 0, .06)) 0 25%,transparent 0 50%,var(--ran-gray-alpha-100, rgba(0, 0, 0, .06)) 0 75%,transparent 0);background-size:8px 8px}.ran-color-picker-slider-alpha-track{position:absolute;inset:0;border-radius:inherit}.ran-color-picker-slider-thumb{position:absolute;top:50%;left:0;z-index:1;width:14px;height:14px;transform:translate(-50%,-50%);border-radius:50%;border:2px solid #fff;box-shadow:0 0 0 1px #0003,0 1px 3px #00000059;pointer-events:none}.ran-color-picker-input-container{display:flex;align-items:center;gap:8px}.ran-color-picker-format{flex:none;width:68px}.ran-color-picker-value{flex:1;min-width:0}", d = 360, F = class extends _ {
|
|
75
|
+
colorpicker;
|
|
76
|
+
colorpickerInner;
|
|
77
|
+
context;
|
|
78
|
+
_shadowDom;
|
|
79
|
+
_events = new w();
|
|
80
|
+
_effectDisposers = [];
|
|
81
|
+
popoverBlock;
|
|
82
|
+
popoverContent;
|
|
83
|
+
colorPickerInner;
|
|
84
|
+
colorPickerPalette;
|
|
85
|
+
colorPickerSaturation;
|
|
86
|
+
colorPickerPaletteDot;
|
|
87
|
+
colorPickerHueSlider;
|
|
88
|
+
colorPickerHueThumb;
|
|
89
|
+
colorPickerAlphaSlider;
|
|
90
|
+
colorPickerAlphaTrack;
|
|
91
|
+
colorPickerAlphaThumb;
|
|
92
|
+
colorPickerPreviewInner;
|
|
93
|
+
colorPickerValueInput;
|
|
94
|
+
colorPickerFormatSelect;
|
|
95
|
+
colorPickerPaletteSelect;
|
|
96
|
+
_activeSlider = null;
|
|
97
|
+
_format = "HEX";
|
|
98
|
+
_editingInput = !1;
|
|
99
|
+
static get observedAttributes() {
|
|
100
|
+
return [
|
|
101
|
+
"disabled",
|
|
102
|
+
"value",
|
|
103
|
+
"sheet"
|
|
104
|
+
];
|
|
105
|
+
}
|
|
106
|
+
constructor() {
|
|
107
|
+
super(), this._shadowDom = v(this, V);
|
|
108
|
+
const e = P(this._shadowDom, "r-popover", () => {
|
|
109
|
+
const t = n().class("ran-colorpicker-inner").part("swatch").build(), i = n().class("ran-colorpicker-block").part("block").children(t).build(), r = u("r-content").class("ran-content").build();
|
|
110
|
+
return u("r-popover").class("ran-popover").attr("trigger", "click").children(i, r).build();
|
|
111
|
+
});
|
|
112
|
+
this.popoverBlock = e, this.popoverContent = e.querySelector("r-content"), this.colorpicker = e.querySelector(".ran-colorpicker-block"), this.colorpickerInner = e.querySelector(".ran-colorpicker-inner"), this.colorpicker.setAttribute("role", "button"), this.colorpicker.setAttribute("tabindex", "0"), this.colorpicker.setAttribute("aria-haspopup", "dialog"), this.colorpicker.setAttribute("aria-label", "Choose color"), this.colorPickerPaletteSelect = !1, this.createContext();
|
|
113
|
+
}
|
|
114
|
+
get value() {
|
|
115
|
+
return this.context?.value.getter() || "";
|
|
116
|
+
}
|
|
117
|
+
set value(e) {
|
|
118
|
+
this.setAttribute("value", e);
|
|
119
|
+
}
|
|
120
|
+
get sheet() {
|
|
121
|
+
return m(this, "sheet");
|
|
122
|
+
}
|
|
123
|
+
set sheet(e) {
|
|
124
|
+
y(this, "sheet", e);
|
|
125
|
+
}
|
|
126
|
+
get disabled() {
|
|
127
|
+
return h(this);
|
|
128
|
+
}
|
|
129
|
+
set disabled(e) {
|
|
130
|
+
e === !1 || e === void 0 || e === null ? this.removeAttribute("disabled") : this.setAttribute("disabled", "");
|
|
131
|
+
}
|
|
132
|
+
handlerExternalCss = () => {
|
|
133
|
+
x(this, this._shadowDom, "sheet", null, this.sheet);
|
|
134
|
+
};
|
|
135
|
+
syncDisabledState = () => {
|
|
136
|
+
const e = h(this);
|
|
137
|
+
this.context?.disabled.setter(e), e ? (this.setAttribute("aria-disabled", "true"), this.colorpicker?.setAttribute("disabled", "")) : (this.removeAttribute("aria-disabled"), this.colorpicker?.removeAttribute("disabled")), this.colorpicker?.setAttribute("aria-disabled", e ? "true" : "false"), this.colorpicker?.setAttribute("tabindex", e ? "-1" : "0");
|
|
138
|
+
};
|
|
139
|
+
blockWhenDisabled = (e) => {
|
|
140
|
+
h(this) && (e.stopImmediatePropagation(), e.preventDefault());
|
|
141
|
+
};
|
|
142
|
+
createContext = () => {
|
|
143
|
+
const e = (t) => {
|
|
144
|
+
const [i, r] = S(t);
|
|
145
|
+
return {
|
|
146
|
+
getter: i,
|
|
147
|
+
setter: r
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
this.context = {
|
|
151
|
+
value: e(""),
|
|
152
|
+
disabled: e(!1),
|
|
153
|
+
hue: e(0),
|
|
154
|
+
saturation: e(0),
|
|
155
|
+
lightness: e(100),
|
|
156
|
+
transparency: e(100)
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
currentRgba = () => {
|
|
160
|
+
const { hue: e, saturation: t, lightness: i, transparency: r } = this.context, { r: o, g: a, b: s } = b(e.getter(), t.getter(), i.getter());
|
|
161
|
+
return {
|
|
162
|
+
r: o,
|
|
163
|
+
g: a,
|
|
164
|
+
b: s,
|
|
165
|
+
a: r.getter() / 100
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
currentValue = () => {
|
|
169
|
+
const { r: e, g: t, b: i, a: r } = this.currentRgba();
|
|
170
|
+
return r < 1 ? `rgba(${e}, ${t}, ${i}, ${Number(r.toFixed(2))})` : g(e, t, i);
|
|
171
|
+
};
|
|
172
|
+
currentDisplay = () => {
|
|
173
|
+
const { r: e, g: t, b: i, a: r } = this.currentRgba();
|
|
174
|
+
return this._format === "RGB" ? r < 1 ? `rgba(${e}, ${t}, ${i}, ${Number(r.toFixed(2))})` : `rgb(${e}, ${t}, ${i})` : g(e, t, i);
|
|
175
|
+
};
|
|
176
|
+
updateColorValue = (e) => {
|
|
177
|
+
if (e === this.context?.value.getter()) return;
|
|
178
|
+
const t = e.replace(/\s+/g, ""), i = C.exec(e), r = R.exec(t), o = E.exec(t);
|
|
179
|
+
if (i) {
|
|
180
|
+
const { h: a, s, v: c } = D(i[0]);
|
|
181
|
+
this.context.hue.setter(a), this.context.saturation.setter(s), this.context.lightness.setter(c), this.context.transparency.setter(100);
|
|
182
|
+
} else if (r) {
|
|
183
|
+
const { h: a, s, v: c } = f(Number(r[1]), Number(r[2]), Number(r[3]));
|
|
184
|
+
this.context.hue.setter(a), this.context.saturation.setter(s), this.context.lightness.setter(c), this.context.transparency.setter(Number(r[4]) * 100);
|
|
185
|
+
} else if (o) {
|
|
186
|
+
const { h: a, s, v: c } = f(Number(o[1]), Number(o[2]), Number(o[3]));
|
|
187
|
+
this.context.hue.setter(a), this.context.saturation.setter(s), this.context.lightness.setter(c), this.context.transparency.setter(100);
|
|
188
|
+
} else return;
|
|
189
|
+
this.setAttribute("value", e), this.context?.value.setter(e);
|
|
190
|
+
};
|
|
191
|
+
emitChange = () => {
|
|
192
|
+
const e = this.currentValue(), { r: t, g: i, b: r, a: o } = this.currentRgba();
|
|
193
|
+
this.context?.value.setter(e), this.setAttribute("value", e), this.dispatchEvent(new CustomEvent("change", {
|
|
194
|
+
detail: {
|
|
195
|
+
value: e,
|
|
196
|
+
hex: g(t, i, r),
|
|
197
|
+
rgb: `rgb(${t}, ${i}, ${r})`,
|
|
198
|
+
rgba: `rgba(${t}, ${i}, ${r}, ${Number(o.toFixed(2))})`,
|
|
199
|
+
alpha: Number(o.toFixed(2))
|
|
200
|
+
},
|
|
201
|
+
bubbles: !0,
|
|
202
|
+
composed: !0
|
|
203
|
+
}));
|
|
204
|
+
};
|
|
205
|
+
palettePointerDown = (e) => {
|
|
206
|
+
e.preventDefault(), this.colorPickerPaletteSelect = !0, this.updatePaletteFromEvent(e);
|
|
207
|
+
};
|
|
208
|
+
updatePaletteFromEvent = (e) => {
|
|
209
|
+
if (!this.colorPickerPalette) return;
|
|
210
|
+
const { left: t, top: i, width: r, height: o } = this.colorPickerPalette.getBoundingClientRect();
|
|
211
|
+
if (!r || !o) return;
|
|
212
|
+
const a = l(e.clientX - t, 0, r), s = l(e.clientY - i, 0, o);
|
|
213
|
+
this.context.saturation.setter(a / r * 100), this.context.lightness.setter((1 - s / o) * 100), this.emitChange();
|
|
214
|
+
};
|
|
215
|
+
sliderPointerDown = (e) => (t) => {
|
|
216
|
+
t.preventDefault(), this._activeSlider = e, this.updateSliderFromEvent(e, t);
|
|
217
|
+
};
|
|
218
|
+
updateSliderFromEvent = (e, t) => {
|
|
219
|
+
const i = e === "hue" ? this.colorPickerHueSlider : this.colorPickerAlphaSlider;
|
|
220
|
+
if (!i) return;
|
|
221
|
+
const { left: r, width: o } = i.getBoundingClientRect();
|
|
222
|
+
if (!o) return;
|
|
223
|
+
const a = l(t.clientX - r, 0, o) / o;
|
|
224
|
+
e === "hue" ? this.context.hue.setter(a * d) : this.context.transparency.setter(a * 100), this.emitChange();
|
|
225
|
+
};
|
|
226
|
+
onPointerMove = (e) => {
|
|
227
|
+
const t = e;
|
|
228
|
+
this.colorPickerPaletteSelect ? this.updatePaletteFromEvent(t) : this._activeSlider && this.updateSliderFromEvent(this._activeSlider, t);
|
|
229
|
+
};
|
|
230
|
+
initSliderA11y = (e, t, i) => {
|
|
231
|
+
e.setAttribute("role", "slider"), e.setAttribute("tabindex", "0"), e.setAttribute("aria-label", t), e.setAttribute("aria-orientation", "horizontal"), e.setAttribute("aria-valuemin", "0"), e.setAttribute("aria-valuemax", String(i));
|
|
232
|
+
};
|
|
233
|
+
sliderKeydown = (e) => (t) => {
|
|
234
|
+
const i = e === "hue" ? d : 100, r = e === "hue" ? this.context.hue : this.context.transparency, o = t.shiftKey ? 10 : 1, a = r.getter();
|
|
235
|
+
let s = a;
|
|
236
|
+
switch (t.key) {
|
|
237
|
+
case "ArrowRight":
|
|
238
|
+
case "ArrowUp":
|
|
239
|
+
s = a + o;
|
|
240
|
+
break;
|
|
241
|
+
case "ArrowLeft":
|
|
242
|
+
case "ArrowDown":
|
|
243
|
+
s = a - o;
|
|
244
|
+
break;
|
|
245
|
+
case "Home":
|
|
246
|
+
s = 0;
|
|
247
|
+
break;
|
|
248
|
+
case "End":
|
|
249
|
+
s = i;
|
|
250
|
+
break;
|
|
251
|
+
default:
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
t.preventDefault(), r.setter(l(s, 0, i)), this.emitChange();
|
|
255
|
+
};
|
|
256
|
+
onPointerUp = () => {
|
|
257
|
+
this.colorPickerPaletteSelect = !1, this._activeSlider = null;
|
|
258
|
+
};
|
|
259
|
+
onSwatchKeydown = (e) => {
|
|
260
|
+
h(this) || (e.key === "Enter" || e.key === " " || e.key === "Spacebar") && (e.preventDefault(), this.colorpicker?.click());
|
|
261
|
+
};
|
|
262
|
+
onValueInput = (e) => {
|
|
263
|
+
const t = e.target, i = e.detail?.value ?? t?.value;
|
|
264
|
+
typeof i == "string" && (this._editingInput = !0, this.updateColorValue(i.trim()), this._editingInput = !1, this.emitChange());
|
|
265
|
+
};
|
|
266
|
+
onFormatChange = (e) => {
|
|
267
|
+
const t = e.detail?.value;
|
|
268
|
+
this._format = t === "RGB" ? "RGB" : "HEX", this.syncValueInput();
|
|
269
|
+
};
|
|
270
|
+
syncValueInput = () => {
|
|
271
|
+
this._editingInput || !this.colorPickerValueInput || (this.colorPickerValueInput.value = this.currentDisplay());
|
|
272
|
+
};
|
|
273
|
+
setupEffects = () => {
|
|
274
|
+
this._effectDisposers.push(p(() => {
|
|
275
|
+
const { r: e, g: t, b: i } = b(this.context.hue.getter(), 100, 100);
|
|
276
|
+
this.colorPickerSaturation?.style.setProperty("background-color", `rgb(${e}, ${t}, ${i})`);
|
|
277
|
+
}), p(() => {
|
|
278
|
+
const e = l(this.context.saturation.getter(), 0, 100), t = l(this.context.lightness.getter(), 0, 100);
|
|
279
|
+
this.colorPickerPaletteDot?.style.setProperty("left", `${e}%`), this.colorPickerPaletteDot?.style.setProperty("top", `${100 - t}%`);
|
|
280
|
+
}), p(() => {
|
|
281
|
+
const e = this.context.hue.getter(), { r: t, g: i, b: r } = b(e, 100, 100);
|
|
282
|
+
this.colorPickerHueThumb?.style.setProperty("left", `${e / d * 100}%`), this.colorPickerHueThumb?.style.setProperty("background", `rgb(${t}, ${i}, ${r})`), this.colorPickerHueSlider?.setAttribute("aria-valuenow", String(Math.round(e)));
|
|
283
|
+
}), p(() => {
|
|
284
|
+
const { r: e, g: t, b: i, a: r } = this.currentRgba(), o = `rgb(${e}, ${t}, ${i})`, a = `rgba(${e}, ${t}, ${i}, ${Number(r.toFixed(3))})`;
|
|
285
|
+
this.colorPickerAlphaTrack?.style.setProperty("background", `linear-gradient(to right, rgba(${e}, ${t}, ${i}, 0), ${o})`), this.colorPickerAlphaThumb?.style.setProperty("left", `${r * 100}%`), this.colorPickerAlphaThumb?.style.setProperty("background", a), this.colorPickerPreviewInner?.style.setProperty("background", a), this.colorpickerInner?.style.setProperty("background", a), this.colorPickerAlphaSlider?.setAttribute("aria-valuenow", String(Math.round(r * 100))), this.colorPickerAlphaSlider?.setAttribute("aria-valuetext", `${Math.round(r * 100)}%`), this.syncValueInput();
|
|
286
|
+
}));
|
|
287
|
+
};
|
|
288
|
+
disposeEffects = () => {
|
|
289
|
+
for (const e of this._effectDisposers) e();
|
|
290
|
+
this._effectDisposers = [];
|
|
291
|
+
};
|
|
292
|
+
openColorPicker = () => {
|
|
293
|
+
if (h(this) || this.colorPickerInner) return;
|
|
294
|
+
this.colorPickerSaturation = n().class("ran-color-picker-saturation").build(), this.colorPickerPaletteDot = n().class("ran-color-picker-palette-dot").build(), this.colorPickerPalette = n().class("ran-color-picker-palette").on("mousedown", this.palettePointerDown).children(this.colorPickerSaturation, this.colorPickerPaletteDot).build(), this.colorPickerPreviewInner = n().class("ran-color-picker-preview-inner").build();
|
|
295
|
+
const e = n().class("ran-color-picker-preview").children(this.colorPickerPreviewInner).build();
|
|
296
|
+
this.colorPickerHueThumb = n().class("ran-color-picker-slider-thumb").build(), this.colorPickerHueSlider = n().class("ran-color-picker-slider ran-color-picker-slider-hue").on("mousedown", this.sliderPointerDown("hue")).on("keydown", this.sliderKeydown("hue")).children(this.colorPickerHueThumb).build(), this.initSliderA11y(this.colorPickerHueSlider, "Hue", d), this.colorPickerAlphaTrack = n().class("ran-color-picker-slider-alpha-track").build(), this.colorPickerAlphaThumb = n().class("ran-color-picker-slider-thumb").build(), this.colorPickerAlphaSlider = n().class("ran-color-picker-slider ran-color-picker-slider-alpha").on("mousedown", this.sliderPointerDown("alpha")).on("keydown", this.sliderKeydown("alpha")).children(this.colorPickerAlphaTrack, this.colorPickerAlphaThumb).build(), this.initSliderA11y(this.colorPickerAlphaSlider, "Alpha opacity", 100);
|
|
297
|
+
const t = n().class("ran-color-picker-sliders").children(this.colorPickerHueSlider, this.colorPickerAlphaSlider).build(), i = n().class("ran-color-picker-controls").children(e, t).build();
|
|
298
|
+
this.colorPickerFormatSelect = u("r-select").class("ran-color-picker-format").attr("value", this._format).attr("defaultValue", this._format).attr("trigger", "click").children(...["HEX", "RGB"].map((a) => u("r-option").attr("value", a).text(a).build())).on("change", this.onFormatChange).build(), this.colorPickerValueInput = u("r-input").class("ran-color-picker-value").on("change", this.onValueInput).build();
|
|
299
|
+
const r = n().class("ran-color-picker-input-container").children(this.colorPickerFormatSelect, this.colorPickerValueInput).build(), o = n().class("ran-color-picker-inner-content").children(this.colorPickerPalette, i, r).build();
|
|
300
|
+
this.colorPickerInner = n().class("ran-color-picker-inner").children(A().text(H).build(), o).build(), this.popoverContent.appendChild(this.colorPickerInner), this.setupEffects(), this.syncValueInput();
|
|
301
|
+
};
|
|
302
|
+
connectedCallback() {
|
|
303
|
+
this.handlerExternalCss(), this.setAttribute("class", "ran-colorpicker"), this._events.on(this, "click", this.blockWhenDisabled, { capture: !0 }), this._events.on(this, "keydown", this.blockWhenDisabled, { capture: !0 }), this._events.on(this.popoverBlock, "click", this.openColorPicker), this._events.on(this.colorpicker, "keydown", this.onSwatchKeydown), this._events.on(document, "mousemove", this.onPointerMove), this._events.on(document, "mouseup", this.onPointerUp), this.syncDisabledState(), this.value && this.updateColorValue(this.value);
|
|
304
|
+
}
|
|
305
|
+
disconnectedCallback() {
|
|
306
|
+
this._events.abort(), this.disposeEffects();
|
|
307
|
+
}
|
|
308
|
+
attributeChangedCallback(e, t, i) {
|
|
309
|
+
t !== i && (e === "value" && this.updateColorValue(i), e === "disabled" && this.syncDisabledState(), e === "sheet" && this.handlerExternalCss());
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
$("r-colorpicker", F);
|
|
313
|
+
export {
|
|
314
|
+
F as t
|
|
315
|
+
};
|
package/dist/colorpicker.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import "./index-DC5EA657.js";
|
|
3
|
-
import { C, a } from "./index-CiWwvEMM.js";
|
|
4
|
-
import "./index-D4y9c1Dj.js";
|
|
5
|
-
import "./index-WfFw4LJT.js";
|
|
6
|
-
import "./selectShadowless.js";
|
|
7
|
-
import "./index-15M0olqa.js";
|
|
1
|
+
import { t as r } from "./colorpicker-CGh8pRqo.js";
|
|
8
2
|
export {
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
r as ColorPicker,
|
|
4
|
+
r as default
|
|
11
5
|
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { RanElement } from '@/utils/index';
|
|
2
|
+
import { EventManager } from '@/utils/builder';
|
|
3
|
+
export declare class Button extends RanElement {
|
|
4
|
+
_btn: HTMLDivElement;
|
|
5
|
+
_btnContent: HTMLDivElement;
|
|
6
|
+
_iconElement?: HTMLElement;
|
|
7
|
+
_slot: HTMLSlotElement;
|
|
8
|
+
_shadowDom: ShadowRoot;
|
|
9
|
+
_events: EventManager;
|
|
10
|
+
debounceTimeId?: NodeJS.Timeout;
|
|
11
|
+
static get observedAttributes(): string[];
|
|
12
|
+
constructor();
|
|
13
|
+
get sheet(): string;
|
|
14
|
+
set sheet(value: string);
|
|
15
|
+
get disabled(): boolean | string;
|
|
16
|
+
set disabled(value: boolean | string | undefined | null);
|
|
17
|
+
get iconSize(): string;
|
|
18
|
+
set iconSize(value: string | undefined | null);
|
|
19
|
+
get icon(): string;
|
|
20
|
+
set icon(value: string | null);
|
|
21
|
+
get effect(): string;
|
|
22
|
+
set effect(value: string | null);
|
|
23
|
+
/** Visual variant: `''` (default) | `'primary'` | `'warning'` | `'text'`. Drives the `:host([type=...])` styles. */
|
|
24
|
+
get type(): string;
|
|
25
|
+
set type(value: string | null);
|
|
26
|
+
/**
|
|
27
|
+
* @description: 设置 button 的 icon
|
|
28
|
+
*/
|
|
29
|
+
setIcon: () => void;
|
|
30
|
+
mousedown: (event: MouseEvent) => void;
|
|
31
|
+
mouseup: () => void;
|
|
32
|
+
keydown: (event: KeyboardEvent) => void;
|
|
33
|
+
debounceMouseEvent: () => void;
|
|
34
|
+
handlerExternalCss: () => void;
|
|
35
|
+
syncA11yState: () => void;
|
|
36
|
+
connectedCallback(): void;
|
|
37
|
+
/**
|
|
38
|
+
* @description: FIX: 修正拼写错误 disconnectCallback -> disconnectedCallback
|
|
39
|
+
* 确保组件销毁时正确移除事件监听,彻底杜绝内存泄漏。
|
|
40
|
+
*/
|
|
41
|
+
disconnectedCallback(): void;
|
|
42
|
+
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
43
|
+
}
|
|
44
|
+
export default Button;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RanElement } from '@/utils/index';
|
|
2
|
+
export declare class Card extends RanElement {
|
|
3
|
+
_shadowDom: ShadowRoot;
|
|
4
|
+
_titleEl: HTMLElement;
|
|
5
|
+
_descriptionEl: HTMLElement;
|
|
6
|
+
_headerEl: HTMLElement;
|
|
7
|
+
_footerEl: HTMLElement;
|
|
8
|
+
static get observedAttributes(): string[];
|
|
9
|
+
constructor();
|
|
10
|
+
get title(): string;
|
|
11
|
+
set title(value: string);
|
|
12
|
+
get description(): string;
|
|
13
|
+
set description(value: string);
|
|
14
|
+
get sheet(): string;
|
|
15
|
+
set sheet(value: string);
|
|
16
|
+
private _syncTitle;
|
|
17
|
+
private _syncDescription;
|
|
18
|
+
connectedCallback(): void;
|
|
19
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
20
|
+
}
|
|
21
|
+
export default Card;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { RanElement } from '@/utils/index';
|
|
2
|
+
import { EventManager } from '@/utils/builder';
|
|
3
|
+
export interface Context {
|
|
4
|
+
checked: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare class Checkbox extends RanElement {
|
|
7
|
+
static formAssociated: boolean;
|
|
8
|
+
_events: EventManager;
|
|
9
|
+
_internals?: ElementInternals;
|
|
10
|
+
checkInput: HTMLInputElement;
|
|
11
|
+
checkInner: HTMLSpanElement;
|
|
12
|
+
context: Context;
|
|
13
|
+
container: HTMLElement;
|
|
14
|
+
_shadowDom: ShadowRoot;
|
|
15
|
+
static get observedAttributes(): string[];
|
|
16
|
+
constructor();
|
|
17
|
+
get disabled(): boolean;
|
|
18
|
+
set disabled(value: boolean | string);
|
|
19
|
+
get value(): string;
|
|
20
|
+
set value(value: string);
|
|
21
|
+
get checked(): boolean;
|
|
22
|
+
set checked(value: boolean | string);
|
|
23
|
+
get sheet(): string;
|
|
24
|
+
set sheet(value: string);
|
|
25
|
+
handlerExternalCss: () => void;
|
|
26
|
+
updateChecked: () => void;
|
|
27
|
+
syncA11yAndForm: () => void;
|
|
28
|
+
update: () => void;
|
|
29
|
+
onChange: () => void;
|
|
30
|
+
onKeydown: (event: KeyboardEvent) => void;
|
|
31
|
+
connectedCallback(): void;
|
|
32
|
+
disconnectedCallback(): void;
|
|
33
|
+
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
34
|
+
}
|
|
35
|
+
export default Checkbox;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { RanElement } from '@/utils/index';
|
|
2
|
+
import { EventManager } from '@/utils/builder';
|
|
3
|
+
import '@/components/popover';
|
|
4
|
+
import '@/components/input';
|
|
5
|
+
import '@/components/select';
|
|
6
|
+
export interface Context {
|
|
7
|
+
disabled: Signal<boolean>;
|
|
8
|
+
value: Signal<string>;
|
|
9
|
+
hue: Signal<number>;
|
|
10
|
+
saturation: Signal<number>;
|
|
11
|
+
lightness: Signal<number>;
|
|
12
|
+
transparency: Signal<number>;
|
|
13
|
+
}
|
|
14
|
+
export interface RGBA {
|
|
15
|
+
r: number;
|
|
16
|
+
g: number;
|
|
17
|
+
b: number;
|
|
18
|
+
a: number;
|
|
19
|
+
}
|
|
20
|
+
export interface Signal<T> {
|
|
21
|
+
getter: () => T;
|
|
22
|
+
setter: (newValue: T | ((prev: T) => T)) => void;
|
|
23
|
+
}
|
|
24
|
+
type ColorFormat = 'HEX' | 'RGB';
|
|
25
|
+
export declare class ColorPicker extends RanElement {
|
|
26
|
+
colorpicker: HTMLDivElement;
|
|
27
|
+
colorpickerInner: HTMLDivElement;
|
|
28
|
+
context: Context;
|
|
29
|
+
_shadowDom: ShadowRoot;
|
|
30
|
+
_events: EventManager;
|
|
31
|
+
_effectDisposers: Array<() => void>;
|
|
32
|
+
popoverBlock: HTMLElement;
|
|
33
|
+
popoverContent: HTMLElement;
|
|
34
|
+
colorPickerInner?: HTMLDivElement;
|
|
35
|
+
colorPickerPalette?: HTMLElement;
|
|
36
|
+
colorPickerSaturation?: HTMLElement;
|
|
37
|
+
colorPickerPaletteDot?: HTMLElement;
|
|
38
|
+
colorPickerHueSlider?: HTMLElement;
|
|
39
|
+
colorPickerHueThumb?: HTMLElement;
|
|
40
|
+
colorPickerAlphaSlider?: HTMLElement;
|
|
41
|
+
colorPickerAlphaTrack?: HTMLElement;
|
|
42
|
+
colorPickerAlphaThumb?: HTMLElement;
|
|
43
|
+
colorPickerPreviewInner?: HTMLElement;
|
|
44
|
+
colorPickerValueInput?: HTMLElement;
|
|
45
|
+
colorPickerFormatSelect?: HTMLElement;
|
|
46
|
+
colorPickerPaletteSelect: boolean;
|
|
47
|
+
_activeSlider: 'hue' | 'alpha' | null;
|
|
48
|
+
_format: ColorFormat;
|
|
49
|
+
_editingInput: boolean;
|
|
50
|
+
static get observedAttributes(): string[];
|
|
51
|
+
constructor();
|
|
52
|
+
get value(): string;
|
|
53
|
+
set value(value: string);
|
|
54
|
+
get sheet(): string;
|
|
55
|
+
set sheet(value: string);
|
|
56
|
+
get disabled(): boolean;
|
|
57
|
+
set disabled(value: boolean | string | undefined | null);
|
|
58
|
+
handlerExternalCss: () => void;
|
|
59
|
+
/**
|
|
60
|
+
* Reflect the `disabled` attribute into the internal state, ARIA, and the
|
|
61
|
+
* swatch's visual/interaction state. When disabled the swatch is removed from
|
|
62
|
+
* the tab order and marked `aria-disabled`; opening is blocked by
|
|
63
|
+
* `blockWhenDisabled` (a capture-phase guard wired in connectedCallback).
|
|
64
|
+
*/
|
|
65
|
+
syncDisabledState: () => void;
|
|
66
|
+
/** Capture-phase guard: swallow clicks/keydowns on the swatch while disabled. */
|
|
67
|
+
blockWhenDisabled: (e: Event) => void;
|
|
68
|
+
createContext: () => void;
|
|
69
|
+
currentRgba: () => RGBA;
|
|
70
|
+
/** Canonical string used for the `value` attribute and `change` events. */
|
|
71
|
+
currentValue: () => string;
|
|
72
|
+
/** String shown in the value input, depending on the selected format. */
|
|
73
|
+
currentDisplay: () => string;
|
|
74
|
+
updateColorValue: (value: string) => void;
|
|
75
|
+
/** Sync the `value` attribute to the live color and emit a `change` event. */
|
|
76
|
+
emitChange: () => void;
|
|
77
|
+
palettePointerDown: (e: MouseEvent) => void;
|
|
78
|
+
updatePaletteFromEvent: (e: MouseEvent) => void;
|
|
79
|
+
sliderPointerDown: (kind: "hue" | "alpha") => (e: MouseEvent) => void;
|
|
80
|
+
updateSliderFromEvent: (kind: "hue" | "alpha", e: MouseEvent) => void;
|
|
81
|
+
onPointerMove: (e: Event) => void;
|
|
82
|
+
/** Make a slider a focusable, described `role="slider"`; valuenow is kept live in setupEffects. */
|
|
83
|
+
initSliderA11y: (el: HTMLElement, label: string, max: number) => void;
|
|
84
|
+
/** Arrow keys adjust the hue/alpha slider (Shift = coarse step, Home/End = ends). */
|
|
85
|
+
sliderKeydown: (kind: "hue" | "alpha") => (e: KeyboardEvent) => void;
|
|
86
|
+
onPointerUp: () => void;
|
|
87
|
+
/** Open the picker from the keyboard: Enter/Space act like a click on the swatch. */
|
|
88
|
+
onSwatchKeydown: (e: KeyboardEvent) => void;
|
|
89
|
+
onValueInput: (e: Event) => void;
|
|
90
|
+
onFormatChange: (e: Event) => void;
|
|
91
|
+
syncValueInput: () => void;
|
|
92
|
+
setupEffects: () => void;
|
|
93
|
+
disposeEffects: () => void;
|
|
94
|
+
openColorPicker: () => void;
|
|
95
|
+
connectedCallback(): void;
|
|
96
|
+
disconnectedCallback(): void;
|
|
97
|
+
attributeChangedCallback(name: string, old: string, next: string): void;
|
|
98
|
+
}
|
|
99
|
+
export default ColorPicker;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { RanElement } from '@/utils/index';
|
|
2
|
+
export declare enum ARROW_TYPE {
|
|
3
|
+
TOP = "top",
|
|
4
|
+
BOTTOM = "bottom",
|
|
5
|
+
LEFT = "left",
|
|
6
|
+
RIGHT = "right"
|
|
7
|
+
}
|
|
8
|
+
export declare class Dropdown extends RanElement {
|
|
9
|
+
dropdown: HTMLElement;
|
|
10
|
+
_slot: HTMLSlotElement;
|
|
11
|
+
_shadowDom: ShadowRoot;
|
|
12
|
+
arrowIcon?: HTMLElement;
|
|
13
|
+
container: HTMLElement;
|
|
14
|
+
static get observedAttributes(): string[];
|
|
15
|
+
constructor();
|
|
16
|
+
get transit(): string;
|
|
17
|
+
set transit(value: string);
|
|
18
|
+
get arrow(): string;
|
|
19
|
+
set arrow(value: string);
|
|
20
|
+
get sheet(): string;
|
|
21
|
+
set sheet(value: string);
|
|
22
|
+
handlerExternalCss: () => void;
|
|
23
|
+
handlerTransit: () => void;
|
|
24
|
+
handlerArrow: () => void;
|
|
25
|
+
stopPropagation: (e: Event) => void;
|
|
26
|
+
connectedCallback(): void;
|
|
27
|
+
disconnectedCallback(): void;
|
|
28
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
29
|
+
}
|
|
30
|
+
export default Dropdown;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RanElement } from '@/utils/index';
|
|
2
|
+
export declare class Form extends RanElement {
|
|
3
|
+
_form: HTMLFormElement;
|
|
4
|
+
_shadowDom: ShadowRoot;
|
|
5
|
+
static get observedAttributes(): string[];
|
|
6
|
+
constructor();
|
|
7
|
+
get value(): string | null;
|
|
8
|
+
set value(value: string | null);
|
|
9
|
+
get sheet(): string;
|
|
10
|
+
set sheet(value: string);
|
|
11
|
+
handlerExternalCss: () => void;
|
|
12
|
+
connectedCallback(): void;
|
|
13
|
+
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
14
|
+
}
|
|
15
|
+
export default Form;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { RanElement } from '@/utils/index';
|
|
2
|
+
import { EventManager } from '@/utils/builder';
|
|
3
|
+
/** Register one icon. Consumer controls what gets bundled by what it imports. */
|
|
4
|
+
export declare const registerIcon: (name: string, source: unknown) => void;
|
|
5
|
+
/** Batch register icons. */
|
|
6
|
+
export declare const registerIcons: (icons: Record<string, unknown>) => void;
|
|
7
|
+
export declare class Icon extends RanElement {
|
|
8
|
+
private readonly isDev;
|
|
9
|
+
_events: EventManager;
|
|
10
|
+
static get observedAttributes(): string[];
|
|
11
|
+
_icon?: SVGElement;
|
|
12
|
+
_div: HTMLElement;
|
|
13
|
+
_shadowDom: ShadowRoot;
|
|
14
|
+
_onIconRegistered: (event: Event) => void;
|
|
15
|
+
constructor();
|
|
16
|
+
get name(): string;
|
|
17
|
+
set name(value: string);
|
|
18
|
+
get size(): string;
|
|
19
|
+
set size(value: string);
|
|
20
|
+
get color(): string;
|
|
21
|
+
set color(value: string);
|
|
22
|
+
get spin(): boolean;
|
|
23
|
+
set spin(value: boolean);
|
|
24
|
+
get decorative(): boolean;
|
|
25
|
+
set decorative(value: boolean);
|
|
26
|
+
get ariaLabel(): string;
|
|
27
|
+
set ariaLabel(value: string);
|
|
28
|
+
get sheet(): string;
|
|
29
|
+
set sheet(value: string);
|
|
30
|
+
handlerExternalCss: () => void;
|
|
31
|
+
syncA11y: () => void;
|
|
32
|
+
/**
|
|
33
|
+
* @description: 设置 icon 的 svg
|
|
34
|
+
* @return {*}
|
|
35
|
+
*/
|
|
36
|
+
setIcon: () => void;
|
|
37
|
+
isSvgText: (value: string) => boolean;
|
|
38
|
+
parseSvg: (svgContent: string) => SVGElement | undefined;
|
|
39
|
+
renderSvg: (svgContent: string, iconName: string) => void;
|
|
40
|
+
/**
|
|
41
|
+
* @description: 设置 icon 的大小
|
|
42
|
+
* @return {*}
|
|
43
|
+
*/
|
|
44
|
+
setSize: () => void;
|
|
45
|
+
/**
|
|
46
|
+
* @description: 设置 icon 的颜色
|
|
47
|
+
* @return {*}
|
|
48
|
+
*/
|
|
49
|
+
setColor: () => void;
|
|
50
|
+
/**
|
|
51
|
+
* @description: 设置 icon 是否旋转
|
|
52
|
+
* @return {*}
|
|
53
|
+
*/
|
|
54
|
+
setSpin: () => void;
|
|
55
|
+
connectedCallback(): void;
|
|
56
|
+
disconnectedCallback(): void;
|
|
57
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
58
|
+
}
|