ranui 0.1.10-alpha.9 → 0.2.0-alpha.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 +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-DukaD6uL.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-Ch67dWa_.js +302 -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 +88 -0
- package/dist/components/dropdown/index.d.ts +32 -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 +25 -0
- package/dist/components/input/index.d.ts +229 -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 +39 -0
- package/dist/components/player/index.d.ts +277 -0
- package/dist/components/popover/content/index.d.ts +12 -0
- package/dist/components/popover/index.d.ts +95 -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 +135 -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-C5362qTy.js +82 -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-DmoEnao5.js +165 -0
- package/dist/icon.js +4 -4
- package/dist/{index-KS2nvVcO.js → image-6GayFDqX.js} +58 -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-DoraIb3x.js +198 -0
- package/dist/input.js +2 -3
- package/dist/katex-es-Bpesphgp.js +23682 -0
- package/dist/katex-es-Cnq5Pk8K.cjs +261 -0
- package/dist/link-BW-gvrpN.js +77 -0
- package/dist/link.js +6 -0
- package/dist/loading-Mko22ncl.js +206 -0
- package/dist/loading.js +4 -6
- package/dist/math-B5PpSnFR.js +52 -0
- package/dist/math.js +2 -4
- package/dist/message-CQENvkoi.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-CvfmwWUa.js +13536 -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-BCvHwLZb.js +213 -0
- package/dist/popover.js +3 -5
- package/dist/progress-BWkNf2J5.js +123 -0
- package/dist/progress.js +3 -5
- package/dist/radar-CWsawt2g.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-BmhCUTLb.js +433 -0
- package/dist/select.js +3 -8
- package/dist/signal-XHfNsQNW.js +57 -0
- package/dist/skeleton-DPv9nFhL.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-C9swK-hm.js +185 -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 +326 -0
- package/docs/DESIGN.md +182 -0
- package/docs/style-tokens-public.md +880 -0
- package/package.json +136 -77
- 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
package/dist/index-CGYfjKUV.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { c as create } from "./arrow-down-B_hCY3Wt.js";
|
|
5
|
-
import { H as HTMLElementSSR, c as createCustomError } from "./index-DC5EA657.js";
|
|
6
|
-
const f7170ee498e0dd32cbdcb63fba8f75cc = ".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}:host{position:var(--ran-math-position, relative)}.ran-math{display:var(--ran-math-display, flex);justify-content:var(--ran-math-justify-content, space-around);align-items:var(--ran-math-align-items, center)}.katex-html{display:var(--ran-math-katex-display, none)}";
|
|
7
|
-
class Math2 extends HTMLElementSSR() {
|
|
8
|
-
constructor() {
|
|
9
|
-
super();
|
|
10
|
-
__publicField(this, "contain");
|
|
11
|
-
this.contain = create("div").setAttribute("class", "ran-math").element;
|
|
12
|
-
const shadowRoot = this.attachShadow({ mode: "closed" });
|
|
13
|
-
const F7170EE498E0DD32CBDCB63FBA8F75CC = document.createElement("style");
|
|
14
|
-
F7170EE498E0DD32CBDCB63FBA8F75CC.textContent = f7170ee498e0dd32cbdcb63fba8f75cc;
|
|
15
|
-
shadowRoot.appendChild(F7170EE498E0DD32CBDCB63FBA8F75CC);
|
|
16
|
-
shadowRoot.appendChild(this.contain);
|
|
17
|
-
}
|
|
18
|
-
static get observedAttributes() {
|
|
19
|
-
return ["latex"];
|
|
20
|
-
}
|
|
21
|
-
get latex() {
|
|
22
|
-
const latex = this.getAttribute("latex") || "";
|
|
23
|
-
return decodeURIComponent(latex);
|
|
24
|
-
}
|
|
25
|
-
set latex(value) {
|
|
26
|
-
this.setAttribute("latex", value || "");
|
|
27
|
-
}
|
|
28
|
-
render() {
|
|
29
|
-
if (!this.latex) return;
|
|
30
|
-
import("./katex-es-B5r5vt3m.js").then((katex) => {
|
|
31
|
-
this.contain.innerHTML = "";
|
|
32
|
-
const span = create("span").setTextContent(`$$${this.latex}$$`).element;
|
|
33
|
-
this.contain.appendChild(span);
|
|
34
|
-
if (!katex) return;
|
|
35
|
-
katex.renderMathInElement(this.contain);
|
|
36
|
-
}).catch(function(err) {
|
|
37
|
-
console.warn(`ranui math component warning: ${err.message}
|
|
38
|
-
${err}`);
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
connectedCallback() {
|
|
42
|
-
this.render();
|
|
43
|
-
}
|
|
44
|
-
disconnectCallback() {
|
|
45
|
-
}
|
|
46
|
-
attributeChangedCallback(k, o, n) {
|
|
47
|
-
if (o !== n) {
|
|
48
|
-
if (k === "latex") {
|
|
49
|
-
this.render();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
async function Custom() {
|
|
55
|
-
if (typeof document !== "undefined" && !customElements.get("r-math")) {
|
|
56
|
-
customElements.define("r-math", Math2);
|
|
57
|
-
return Math2;
|
|
58
|
-
} else {
|
|
59
|
-
return createCustomError("document is undefined or r-math is exist");
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
const index = Custom();
|
|
63
|
-
const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
64
|
-
__proto__: null,
|
|
65
|
-
Math: Math2,
|
|
66
|
-
default: index
|
|
67
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
68
|
-
export {
|
|
69
|
-
Math2 as M,
|
|
70
|
-
index as a,
|
|
71
|
-
index$1 as i
|
|
72
|
-
};
|
package/dist/index-CQTJoWhb.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
function Custom() {
|
|
2
|
-
if (typeof window !== "undefined" && !customElements.get("r-modal")) {
|
|
3
|
-
class CustomModal extends HTMLElement {
|
|
4
|
-
constructor() {
|
|
5
|
-
super();
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
customElements.define("r-modal", CustomModal);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
const index = Custom();
|
|
12
|
-
const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
13
|
-
__proto__: null,
|
|
14
|
-
default: index
|
|
15
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
16
|
-
export {
|
|
17
|
-
index as a,
|
|
18
|
-
index$1 as i
|
|
19
|
-
};
|
package/dist/index-CiWwvEMM.js
DELETED
|
@@ -1,511 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { e as range } from "./arrow-down-B_hCY3Wt.js";
|
|
5
|
-
import { H as HTMLElementSSR, a as createSignal, c as createCustomError } from "./index-DC5EA657.js";
|
|
6
|
-
import "./index-D4y9c1Dj.js";
|
|
7
|
-
import "./index-WfFw4LJT.js";
|
|
8
|
-
import "./selectShadowless.js";
|
|
9
|
-
import "./index-15M0olqa.js";
|
|
10
|
-
const hex2hsv = (hex) => {
|
|
11
|
-
const { r, g, b } = hex2rgb(hex);
|
|
12
|
-
return rgb2hsv(r, g, b);
|
|
13
|
-
};
|
|
14
|
-
const hex2rgb = (hex) => {
|
|
15
|
-
if (hex[0] === "#") hex = hex.substr(1);
|
|
16
|
-
if (hex.length === 3) {
|
|
17
|
-
return {
|
|
18
|
-
r: parseInt(hex[0] + hex[0], 16),
|
|
19
|
-
g: parseInt(hex[1] + hex[1], 16),
|
|
20
|
-
b: parseInt(hex[2] + hex[2], 16)
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
return {
|
|
24
|
-
r: parseInt(hex.substr(0, 2), 16),
|
|
25
|
-
g: parseInt(hex.substr(2, 2), 16),
|
|
26
|
-
b: parseInt(hex.substr(4, 2), 16)
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
const rgb2hsv = (r, g, b) => {
|
|
30
|
-
let h;
|
|
31
|
-
const max = Math.max(r, g, b);
|
|
32
|
-
const min = Math.min(r, g, b);
|
|
33
|
-
const delta = max - min;
|
|
34
|
-
if (delta === 0) {
|
|
35
|
-
h = 0;
|
|
36
|
-
} else if (r === max) {
|
|
37
|
-
h = (g - b) / delta % 6;
|
|
38
|
-
} else if (g === max) {
|
|
39
|
-
h = (b - r) / delta + 2;
|
|
40
|
-
} else {
|
|
41
|
-
h = (r - g) / delta + 4;
|
|
42
|
-
}
|
|
43
|
-
h = Math.round(h * 60);
|
|
44
|
-
if (h < 0) h += 360;
|
|
45
|
-
const s = Math.round((max === 0 ? 0 : delta / max) * 100);
|
|
46
|
-
const v = Math.round(max / 255 * 100);
|
|
47
|
-
return { h, s, v };
|
|
48
|
-
};
|
|
49
|
-
const hsv2rgb = (h, s, v) => {
|
|
50
|
-
s = s / 100;
|
|
51
|
-
v = v / 100;
|
|
52
|
-
let rgb = [];
|
|
53
|
-
const c = v * s;
|
|
54
|
-
const hh = h / 60;
|
|
55
|
-
const x = c * (1 - Math.abs(hh % 2 - 1));
|
|
56
|
-
const m = v - c;
|
|
57
|
-
if (hh >= 0 && hh < 1) {
|
|
58
|
-
rgb = [c, x, 0];
|
|
59
|
-
} else if (hh >= 1 && hh < 2) {
|
|
60
|
-
rgb = [x, c, 0];
|
|
61
|
-
} else if (hh >= 2 && hh < 3) {
|
|
62
|
-
rgb = [0, c, x];
|
|
63
|
-
} else if (h >= 3 && hh < 4) {
|
|
64
|
-
rgb = [0, x, c];
|
|
65
|
-
} else if (h >= 4 && hh < 5) {
|
|
66
|
-
rgb = [x, 0, c];
|
|
67
|
-
} else if (h >= 5 && hh <= 6) {
|
|
68
|
-
rgb = [c, 0, x];
|
|
69
|
-
} else {
|
|
70
|
-
rgb = [0, 0, 0];
|
|
71
|
-
}
|
|
72
|
-
return {
|
|
73
|
-
r: Math.round(255 * (rgb[0] + m)),
|
|
74
|
-
g: Math.round(255 * (rgb[1] + m)),
|
|
75
|
-
b: Math.round(255 * (rgb[2] + m))
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
const HEX_COLOR_REGEX = /^#([\da-f]{6}|[\da-f]{3})$/i;
|
|
79
|
-
const RGB_REGEX = /^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/;
|
|
80
|
-
const RGBA_REGEX = /^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),(\d{1,3}(\.\d+)?)\)$/;
|
|
81
|
-
const BOT_WIDTH = 8;
|
|
82
|
-
const HUE = 360;
|
|
83
|
-
class ColorPicker extends HTMLElementSSR() {
|
|
84
|
-
constructor() {
|
|
85
|
-
super();
|
|
86
|
-
__publicField(this, "colorpicker");
|
|
87
|
-
__publicField(this, "colorpickerInner");
|
|
88
|
-
__publicField(this, "context");
|
|
89
|
-
__publicField(this, "popoverBlock");
|
|
90
|
-
__publicField(this, "popoverContent");
|
|
91
|
-
__publicField(this, "colorPickerInner");
|
|
92
|
-
__publicField(this, "colorPickerInnerContent");
|
|
93
|
-
__publicField(this, "colorPickerPanel");
|
|
94
|
-
__publicField(this, "colorPickerInputContainer");
|
|
95
|
-
__publicField(this, "colorPickerPanelDot");
|
|
96
|
-
__publicField(this, "colorPickerPanelSliderContainer");
|
|
97
|
-
__publicField(this, "colorPickerPanelSliderGroup");
|
|
98
|
-
__publicField(this, "colorPickerPanelSliderHue");
|
|
99
|
-
__publicField(this, "colorPickerPanelSliderAlpha");
|
|
100
|
-
__publicField(this, "colorPickerColorBlockInner");
|
|
101
|
-
__publicField(this, "colorPickerColorBlock");
|
|
102
|
-
__publicField(this, "colorPickerInnerContentSelect");
|
|
103
|
-
__publicField(this, "colorPickerPanelPalette");
|
|
104
|
-
__publicField(this, "colorPickerPanelSaturation");
|
|
105
|
-
__publicField(this, "colorPickerInputContainerSelect");
|
|
106
|
-
__publicField(this, "colorPickerInputContainerInputColor");
|
|
107
|
-
__publicField(this, "colorPickerInputContainerInputNumber");
|
|
108
|
-
__publicField(this, "colorPickerInputContainerSelectItem");
|
|
109
|
-
__publicField(this, "colorPickerPaletteSelect");
|
|
110
|
-
__publicField(this, "colorPickerPanelDotInner");
|
|
111
|
-
__publicField(this, "createContext", () => {
|
|
112
|
-
this.context = {
|
|
113
|
-
value: this.createColorValueSignal(),
|
|
114
|
-
disabled: this.createColorDisabled(),
|
|
115
|
-
hue: this.createColorHue(),
|
|
116
|
-
saturation: this.createColorSaturation(),
|
|
117
|
-
lightness: this.createColorLightness(),
|
|
118
|
-
transparency: this.createColorTransparency()
|
|
119
|
-
};
|
|
120
|
-
});
|
|
121
|
-
/**
|
|
122
|
-
* @description: 0 - 360 色相 hue
|
|
123
|
-
* @param {*} Signal
|
|
124
|
-
* @return {*}
|
|
125
|
-
*/
|
|
126
|
-
__publicField(this, "createColorHue", () => {
|
|
127
|
-
const [getter, setter] = createSignal(0, {
|
|
128
|
-
subscriber: [
|
|
129
|
-
this.updateColorPickerPanelSaturationBackground,
|
|
130
|
-
this.updateColorPickerPanelSliderHueProgressPercent,
|
|
131
|
-
this.updateColorPickerPanelSliderAlphaProgressWrap,
|
|
132
|
-
this.updateColorPickerPanelSliderAlphaProgressDot,
|
|
133
|
-
this.updateColorPickerColorBlockInnerBackground,
|
|
134
|
-
this.updateColorPickerPanelSliderHueProgressDot
|
|
135
|
-
]
|
|
136
|
-
});
|
|
137
|
-
return { getter, setter };
|
|
138
|
-
});
|
|
139
|
-
/**
|
|
140
|
-
* @description: 0 - 100 饱和度 x
|
|
141
|
-
* @param {*} Signal
|
|
142
|
-
* @return {*}
|
|
143
|
-
*/
|
|
144
|
-
__publicField(this, "createColorSaturation", () => {
|
|
145
|
-
const [getter, setter] = createSignal(100, {
|
|
146
|
-
subscriber: [
|
|
147
|
-
this.updateColorPickerPanelSliderAlphaProgressWrap,
|
|
148
|
-
this.updateColorPickerPanelSliderAlphaProgressDot,
|
|
149
|
-
this.updateColorPickerColorBlockInnerBackground
|
|
150
|
-
]
|
|
151
|
-
});
|
|
152
|
-
return { getter, setter };
|
|
153
|
-
});
|
|
154
|
-
/**
|
|
155
|
-
* @description: 0 - 100 亮度 y
|
|
156
|
-
* @param {*} Signal
|
|
157
|
-
* @return {*}
|
|
158
|
-
*/
|
|
159
|
-
__publicField(this, "createColorLightness", () => {
|
|
160
|
-
const [getter, setter] = createSignal(100, {
|
|
161
|
-
subscriber: [
|
|
162
|
-
this.updateColorPickerPanelSliderAlphaProgressWrap,
|
|
163
|
-
this.updateColorPickerPanelSliderAlphaProgressDot,
|
|
164
|
-
this.updateColorPickerColorBlockInnerBackground
|
|
165
|
-
]
|
|
166
|
-
});
|
|
167
|
-
return { getter, setter };
|
|
168
|
-
});
|
|
169
|
-
/**
|
|
170
|
-
* @description: 0 - 100 透明度
|
|
171
|
-
* @param {*} Signal
|
|
172
|
-
* @return {*}
|
|
173
|
-
*/
|
|
174
|
-
__publicField(this, "createColorTransparency", () => {
|
|
175
|
-
const [getter, setter] = createSignal(80, {
|
|
176
|
-
subscriber: [
|
|
177
|
-
this.updateColorPickerPanelSliderAlphaProgressPercent,
|
|
178
|
-
this.updateColorPickerColorBlockInnerBackground,
|
|
179
|
-
this.updateColorPickerPanelSliderAlphaProgressDot
|
|
180
|
-
]
|
|
181
|
-
});
|
|
182
|
-
return { getter, setter };
|
|
183
|
-
});
|
|
184
|
-
__publicField(this, "createColorDisabled", () => {
|
|
185
|
-
const [getter, setter] = createSignal(true, { subscriber: [] });
|
|
186
|
-
return { getter, setter };
|
|
187
|
-
});
|
|
188
|
-
__publicField(this, "createColorValueSignal", () => {
|
|
189
|
-
const [getter, setter] = createSignal("", {
|
|
190
|
-
subscriber: [this.updateColorValue]
|
|
191
|
-
});
|
|
192
|
-
return { getter, setter };
|
|
193
|
-
});
|
|
194
|
-
__publicField(this, "generateHue2rgb", () => {
|
|
195
|
-
const { hue } = this.context;
|
|
196
|
-
const { r, g, b } = hsv2rgb(hue.getter(), 100, 100);
|
|
197
|
-
return `rgb(${r}, ${g}, ${b})`;
|
|
198
|
-
});
|
|
199
|
-
__publicField(this, "generateHsv2Rgb", () => {
|
|
200
|
-
const { r, g, b } = this.generateHsv2Rgba();
|
|
201
|
-
return `rgb(${r}, ${g}, ${b})`;
|
|
202
|
-
});
|
|
203
|
-
__publicField(this, "generateHsv2Rgba", () => {
|
|
204
|
-
const { hue, saturation, lightness, transparency } = this.context;
|
|
205
|
-
const { r, g, b } = hsv2rgb(hue.getter(), saturation.getter(), lightness.getter());
|
|
206
|
-
return { r, g, b, a: transparency.getter() / 100 };
|
|
207
|
-
});
|
|
208
|
-
__publicField(this, "generateHsv2RgbaValue", () => {
|
|
209
|
-
const { r, g, b, a } = this.generateHsv2Rgba();
|
|
210
|
-
return `rgb(${r}, ${g}, ${b}, ${a})`;
|
|
211
|
-
});
|
|
212
|
-
__publicField(this, "generateColorPickerProgress", () => {
|
|
213
|
-
const { r, g, b } = this.generateHsv2Rgba();
|
|
214
|
-
return `linear-gradient(to right, rgba(255, 0, 4, 0), rgba(${r}, ${g}, ${b}, 1))`;
|
|
215
|
-
});
|
|
216
|
-
__publicField(this, "updateColorValue", (value) => {
|
|
217
|
-
var _a, _b;
|
|
218
|
-
if (value !== ((_a = this.context) == null ? void 0 : _a.value.getter())) {
|
|
219
|
-
const hex = HEX_COLOR_REGEX.exec(value);
|
|
220
|
-
const rga = RGB_REGEX.exec(value.replace(/\s+/g, ""));
|
|
221
|
-
const rgba = RGBA_REGEX.exec(value.replace(/\s+/g, ""));
|
|
222
|
-
if (hex) {
|
|
223
|
-
const { h, s, v } = hex2hsv(hex[0]);
|
|
224
|
-
this.context.hue.setter(h);
|
|
225
|
-
this.context.saturation.setter(s);
|
|
226
|
-
this.context.lightness.setter(v);
|
|
227
|
-
this.context.transparency.setter(100);
|
|
228
|
-
} else if (rgba) {
|
|
229
|
-
const { h, s, v } = rgb2hsv(Number(rgba[1]), Number(rgba[2]), Number(rgba[3]));
|
|
230
|
-
this.context.hue.setter(h);
|
|
231
|
-
this.context.saturation.setter(s);
|
|
232
|
-
this.context.lightness.setter(v);
|
|
233
|
-
this.context.transparency.setter(Number(rgba[4]));
|
|
234
|
-
} else if (rga) {
|
|
235
|
-
const { h, s, v } = rgb2hsv(Number(rga[1]), Number(rga[2]), Number(rga[3]));
|
|
236
|
-
this.context.hue.setter(h);
|
|
237
|
-
this.context.saturation.setter(s);
|
|
238
|
-
this.context.lightness.setter(v);
|
|
239
|
-
this.context.transparency.setter(100);
|
|
240
|
-
} else {
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
this.setAttribute("value", value);
|
|
244
|
-
this.colorpickerInner.style.setProperty("background", value);
|
|
245
|
-
(_b = this.context) == null ? void 0 : _b.value.setter(value);
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
__publicField(this, "updateColorPickerPanelSliderHueProgressPercent", (hue) => {
|
|
249
|
-
var _a;
|
|
250
|
-
(_a = this.colorPickerPanelSliderHue) == null ? void 0 : _a.setAttribute("percent", `${hue / 360}`);
|
|
251
|
-
});
|
|
252
|
-
__publicField(this, "updateColorPickerPanelSliderAlphaProgressPercent", (alpha) => {
|
|
253
|
-
var _a;
|
|
254
|
-
(_a = this.colorPickerPanelSliderAlpha) == null ? void 0 : _a.setAttribute("percent", `${alpha / 100}`);
|
|
255
|
-
});
|
|
256
|
-
__publicField(this, "updateColorPickerPanelSliderAlphaProgressWrap", () => {
|
|
257
|
-
var _a;
|
|
258
|
-
(_a = this.colorPickerPanelSliderAlpha) == null ? void 0 : _a.style.setProperty(
|
|
259
|
-
"--ran-progress-wrap-background",
|
|
260
|
-
this.generateColorPickerProgress()
|
|
261
|
-
);
|
|
262
|
-
});
|
|
263
|
-
__publicField(this, "updateColorPickerPanelSliderAlphaProgressDot", () => {
|
|
264
|
-
var _a;
|
|
265
|
-
(_a = this.colorPickerPanelSliderAlpha) == null ? void 0 : _a.style.setProperty("--ran-progress-dot-background", this.generateHsv2RgbaValue());
|
|
266
|
-
});
|
|
267
|
-
__publicField(this, "updateColorPickerPanelSliderHueProgressDot", () => {
|
|
268
|
-
var _a;
|
|
269
|
-
(_a = this.colorPickerPanelSliderHue) == null ? void 0 : _a.style.setProperty("--ran-progress-dot-background", this.generateHue2rgb());
|
|
270
|
-
});
|
|
271
|
-
__publicField(this, "updateColorPickerColorBlockInnerBackground", () => {
|
|
272
|
-
var _a;
|
|
273
|
-
(_a = this.colorPickerColorBlockInner) == null ? void 0 : _a.style.setProperty("background", this.generateHsv2RgbaValue());
|
|
274
|
-
});
|
|
275
|
-
__publicField(this, "updateColorPickerPanelSaturationBackground", () => {
|
|
276
|
-
var _a;
|
|
277
|
-
(_a = this.colorPickerPanelSaturation) == null ? void 0 : _a.style.setProperty("background-color", this.generateHue2rgb());
|
|
278
|
-
});
|
|
279
|
-
__publicField(this, "clickStop", (e) => {
|
|
280
|
-
e.stopPropagation();
|
|
281
|
-
e.preventDefault();
|
|
282
|
-
});
|
|
283
|
-
__publicField(this, "changeColorPalettePositionByContext", () => {
|
|
284
|
-
window.requestAnimationFrame(() => {
|
|
285
|
-
var _a, _b, _c, _d, _e;
|
|
286
|
-
this.updateColorValue(this.value);
|
|
287
|
-
if (!this.colorPickerPanelPalette) return;
|
|
288
|
-
if (!((_a = this.context) == null ? void 0 : _a.lightness.getter) || !((_b = this.context) == null ? void 0 : _b.saturation.getter)) return;
|
|
289
|
-
const { width, height } = ((_c = this.colorPickerPanelPalette) == null ? void 0 : _c.getBoundingClientRect()) || {};
|
|
290
|
-
const limitY = height - this.context.lightness.getter() / 100 * height;
|
|
291
|
-
const limitX = this.context.saturation.getter() / 100 * width;
|
|
292
|
-
(_d = this.colorPickerPanelDot) == null ? void 0 : _d.style.setProperty("top", `${limitY - BOT_WIDTH}px`);
|
|
293
|
-
(_e = this.colorPickerPanelDot) == null ? void 0 : _e.style.setProperty("left", `${limitX - BOT_WIDTH}px`);
|
|
294
|
-
});
|
|
295
|
-
});
|
|
296
|
-
__publicField(this, "changeColorPalettePosition", (offsetX, offsetY) => {
|
|
297
|
-
var _a, _b, _c;
|
|
298
|
-
if (!this.colorPickerPanelPalette) return;
|
|
299
|
-
if (!((_a = this.context) == null ? void 0 : _a.lightness.getter) || !((_b = this.context) == null ? void 0 : _b.saturation.getter)) return;
|
|
300
|
-
const { width, height } = ((_c = this.colorPickerPanelPalette) == null ? void 0 : _c.getBoundingClientRect()) || {};
|
|
301
|
-
const limitY = height - range(offsetY, 0, height);
|
|
302
|
-
const limitX = range(offsetX, 0, width);
|
|
303
|
-
this.context.saturation.setter(limitX / width * 100);
|
|
304
|
-
this.context.lightness.setter(limitY / height * 100);
|
|
305
|
-
window.requestAnimationFrame(() => {
|
|
306
|
-
var _a2, _b2;
|
|
307
|
-
(_a2 = this.colorPickerPanelDot) == null ? void 0 : _a2.style.setProperty("top", `${offsetY - BOT_WIDTH}px`);
|
|
308
|
-
(_b2 = this.colorPickerPanelDot) == null ? void 0 : _b2.style.setProperty("left", `${offsetX - BOT_WIDTH}px`);
|
|
309
|
-
});
|
|
310
|
-
});
|
|
311
|
-
__publicField(this, "clickColorPalette", (e) => {
|
|
312
|
-
const { offsetX, offsetY } = e;
|
|
313
|
-
this.changeColorPalettePosition(offsetX, offsetY);
|
|
314
|
-
});
|
|
315
|
-
__publicField(this, "createColorPickerProgress", () => {
|
|
316
|
-
this.colorPickerPanelSliderContainer = document.createElement("div");
|
|
317
|
-
this.colorPickerPanelSliderContainer.setAttribute("class", "ran-color-picker-slider-container");
|
|
318
|
-
this.colorPickerPanelSliderGroup = document.createElement("div");
|
|
319
|
-
this.colorPickerPanelSliderGroup.setAttribute("class", "ran-color-picker-slider-container-group");
|
|
320
|
-
this.colorPickerPanelSliderHue = document.createElement("r-progress");
|
|
321
|
-
this.updateColorPickerPanelSliderHueProgressDot();
|
|
322
|
-
this.colorPickerPanelSliderHue.style.setProperty(
|
|
323
|
-
"--ran-progress-wrap-background",
|
|
324
|
-
"linear-gradient(to right, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000)"
|
|
325
|
-
);
|
|
326
|
-
this.colorPickerPanelSliderHue.setAttribute("percent", `${this.context.hue.getter() / 360}`);
|
|
327
|
-
this.colorPickerPanelSliderHue.addEventListener("change", this.changeColorPickerHue);
|
|
328
|
-
this.colorPickerPanelSliderHue.setAttribute("type", "drag");
|
|
329
|
-
this.colorPickerPanelSliderHue.setAttribute("class", "ran-color-picker-slider-container-group-hue");
|
|
330
|
-
this.colorPickerPanelSliderAlpha = document.createElement("r-progress");
|
|
331
|
-
this.updateColorPickerPanelSliderAlphaProgressDot();
|
|
332
|
-
this.colorPickerPanelSliderAlpha.setAttribute("percent", `${this.context.transparency.getter() / 100}`);
|
|
333
|
-
this.updateColorPickerPanelSliderAlphaProgressWrap();
|
|
334
|
-
this.colorPickerPanelSliderAlpha.addEventListener("change", this.changeColorPickerAlpha);
|
|
335
|
-
this.colorPickerPanelSliderAlpha.setAttribute("type", "drag");
|
|
336
|
-
this.colorPickerPanelSliderAlpha.setAttribute("class", "ran-color-picker-slider-container-group-alpha");
|
|
337
|
-
this.colorPickerPanelSliderGroup.appendChild(this.colorPickerPanelSliderHue);
|
|
338
|
-
this.colorPickerPanelSliderGroup.appendChild(this.colorPickerPanelSliderAlpha);
|
|
339
|
-
this.colorPickerPanelSliderContainer.appendChild(this.colorPickerPanelSliderGroup);
|
|
340
|
-
this.colorPickerColorBlock = document.createElement("div");
|
|
341
|
-
this.colorPickerColorBlock.setAttribute("class", "ran-color-picker-slider-container-color-block");
|
|
342
|
-
this.colorPickerColorBlockInner = document.createElement("div");
|
|
343
|
-
this.colorPickerColorBlockInner.setAttribute("class", "ran-color-picker-slider-container-color-block-inner");
|
|
344
|
-
this.updateColorPickerColorBlockInnerBackground();
|
|
345
|
-
this.colorPickerColorBlock.appendChild(this.colorPickerColorBlockInner);
|
|
346
|
-
this.colorPickerPanelSliderContainer.appendChild(this.colorPickerColorBlock);
|
|
347
|
-
});
|
|
348
|
-
__publicField(this, "changeColorPickerHue", (e) => {
|
|
349
|
-
this.context.hue.setter(e.detail.value * HUE);
|
|
350
|
-
});
|
|
351
|
-
__publicField(this, "changeColorPickerAlpha", (e) => {
|
|
352
|
-
this.context.transparency.setter(e.detail.value * 100);
|
|
353
|
-
});
|
|
354
|
-
__publicField(this, "createColorPickerSelect", () => {
|
|
355
|
-
this.colorPickerPanel = document.createElement("div");
|
|
356
|
-
this.colorPickerPanel.setAttribute("class", "ran-color-picker-panel");
|
|
357
|
-
this.colorPickerInnerContentSelect = document.createElement("div");
|
|
358
|
-
this.colorPickerInnerContentSelect.setAttribute("class", "ran-color-picker-select");
|
|
359
|
-
this.colorPickerPanel.appendChild(this.colorPickerInnerContentSelect);
|
|
360
|
-
this.colorPickerPanelPalette = document.createElement("div");
|
|
361
|
-
this.colorPickerPanelPalette.setAttribute("class", "ran-color-picker-palette");
|
|
362
|
-
this.colorPickerInnerContentSelect.appendChild(this.colorPickerPanelPalette);
|
|
363
|
-
this.colorPickerPanelSaturation = document.createElement("div");
|
|
364
|
-
this.colorPickerPanelSaturation.setAttribute("class", "ran-color-picker-saturation");
|
|
365
|
-
this.updateColorPickerPanelSaturationBackground();
|
|
366
|
-
this.colorPickerPanelDot = document.createElement("div");
|
|
367
|
-
this.colorPickerPanelDotInner = document.createElement("div");
|
|
368
|
-
this.colorPickerPanelDotInner.setAttribute("class", "ran-color-picker-palette-dot-inner");
|
|
369
|
-
this.colorPickerPanelDot.setAttribute("class", "ran-color-picker-palette-dot");
|
|
370
|
-
this.colorPickerPanelDot.addEventListener("mousedown", this.mouseDownColorPickerPalette);
|
|
371
|
-
document.body.addEventListener("mousemove", this.mouseMoveColorPickerPalette);
|
|
372
|
-
this.colorPickerPanelDot.addEventListener("mouseup", this.mouseUpColorPickerPalette);
|
|
373
|
-
this.colorPickerPanelDot.appendChild(this.colorPickerPanelDotInner);
|
|
374
|
-
this.colorPickerPanelPalette.appendChild(this.colorPickerPanelDot);
|
|
375
|
-
this.colorPickerPanelPalette.appendChild(this.colorPickerPanelSaturation);
|
|
376
|
-
this.colorPickerPanelPalette.addEventListener("mousedown", this.clickColorPalette);
|
|
377
|
-
});
|
|
378
|
-
__publicField(this, "createColorPickerInput", () => {
|
|
379
|
-
this.colorPickerInputContainer = document.createElement("div");
|
|
380
|
-
this.colorPickerInputContainer.setAttribute("class", "ran-color-picker-input-container");
|
|
381
|
-
const colorPickerInputContainerId = `${performance.now()}`.replace(".", "");
|
|
382
|
-
this.colorPickerInputContainerSelect = document.createElement("div");
|
|
383
|
-
this.colorPickerInputContainerSelect.setAttribute("class", "ran-color-picker-input-container-select");
|
|
384
|
-
this.colorPickerInputContainerSelect.setAttribute("id", colorPickerInputContainerId);
|
|
385
|
-
this.colorPickerInputContainerSelectItem = document.createElement("ra-select");
|
|
386
|
-
this.colorPickerInputContainerSelectItem.setAttribute("value", "HEX");
|
|
387
|
-
this.colorPickerInputContainerSelectItem.setAttribute("class", "ran-color-picker-input-container-select-item");
|
|
388
|
-
this.colorPickerInputContainerSelectItem.setAttribute("type", "text");
|
|
389
|
-
this.colorPickerInputContainerSelectItem.setAttribute("getPopupContainerId", colorPickerInputContainerId);
|
|
390
|
-
const colorSelectOption = ["HEX", "HSB", "RGB"];
|
|
391
|
-
const Fragment = document.createDocumentFragment();
|
|
392
|
-
colorSelectOption.forEach((item) => {
|
|
393
|
-
const Option = document.createElement("r-option");
|
|
394
|
-
Option.setAttribute("value", item);
|
|
395
|
-
Option.innerText = item;
|
|
396
|
-
Fragment.appendChild(Option);
|
|
397
|
-
});
|
|
398
|
-
this.colorPickerInputContainerSelectItem.appendChild(Fragment);
|
|
399
|
-
this.colorPickerInputContainerSelect.appendChild(this.colorPickerInputContainerSelectItem);
|
|
400
|
-
this.colorPickerInputContainer.appendChild(this.colorPickerInputContainerSelect);
|
|
401
|
-
this.colorPickerInputContainerInputColor = document.createElement("ra-input");
|
|
402
|
-
this.colorPickerInputContainerInputColor.setAttribute("class", "ran-color-picker-input-container-input-color");
|
|
403
|
-
this.colorPickerInputContainerInputNumber = document.createElement("ra-input");
|
|
404
|
-
this.colorPickerInputContainerInputNumber.setAttribute("class", "ran-color-picker-input-container-input-number");
|
|
405
|
-
this.colorPickerInputContainer.appendChild(this.colorPickerInputContainerInputColor);
|
|
406
|
-
this.colorPickerInputContainer.appendChild(this.colorPickerInputContainerInputNumber);
|
|
407
|
-
});
|
|
408
|
-
__publicField(this, "openColorPicker", () => {
|
|
409
|
-
if (this.colorPickerInner) return;
|
|
410
|
-
this.colorPickerInner = document.createElement("div");
|
|
411
|
-
this.colorPickerInner.setAttribute("class", "ran-color-picker-inner");
|
|
412
|
-
this.colorPickerInnerContent = document.createElement("div");
|
|
413
|
-
this.colorPickerInnerContent.setAttribute("class", "ran-color-picker-inner-content");
|
|
414
|
-
this.createColorPickerProgress();
|
|
415
|
-
this.createColorPickerSelect();
|
|
416
|
-
this.createColorPickerInput();
|
|
417
|
-
this.colorPickerPanel && this.colorPickerInnerContent.appendChild(this.colorPickerPanel);
|
|
418
|
-
this.colorPickerPanelSliderContainer && this.colorPickerInnerContent.appendChild(this.colorPickerPanelSliderContainer);
|
|
419
|
-
this.colorPickerInputContainer && this.colorPickerInnerContent.appendChild(this.colorPickerInputContainer);
|
|
420
|
-
this.colorPickerInner.appendChild(this.colorPickerInnerContent);
|
|
421
|
-
this.popoverContent.appendChild(this.colorPickerInner);
|
|
422
|
-
this.changeColorPalettePositionByContext();
|
|
423
|
-
});
|
|
424
|
-
__publicField(this, "mouseMoveColorPickerPalette", (e) => {
|
|
425
|
-
var _a;
|
|
426
|
-
if (!this.colorPickerPanelPalette || !this.colorPickerPaletteSelect) return;
|
|
427
|
-
const { pageX, pageY } = e;
|
|
428
|
-
const { top = 0, left = 0, width, height } = ((_a = this.colorPickerPanelPalette) == null ? void 0 : _a.getBoundingClientRect()) || {};
|
|
429
|
-
const limitY = range(pageY - top - BOT_WIDTH, -BOT_WIDTH, height - BOT_WIDTH);
|
|
430
|
-
const limitX = range(pageX - left - BOT_WIDTH, -BOT_WIDTH, width - BOT_WIDTH);
|
|
431
|
-
this.context.saturation.setter(limitX / width * 100);
|
|
432
|
-
this.context.lightness.setter(limitY / height * 100);
|
|
433
|
-
window.requestAnimationFrame(() => {
|
|
434
|
-
var _a2, _b;
|
|
435
|
-
(_a2 = this.colorPickerPanelDot) == null ? void 0 : _a2.style.setProperty("top", `${limitY}px`);
|
|
436
|
-
(_b = this.colorPickerPanelDot) == null ? void 0 : _b.style.setProperty("left", `${limitX}px`);
|
|
437
|
-
});
|
|
438
|
-
});
|
|
439
|
-
__publicField(this, "mouseDownColorPickerPalette", (e) => {
|
|
440
|
-
e.stopPropagation();
|
|
441
|
-
e.preventDefault();
|
|
442
|
-
this.colorPickerPaletteSelect = true;
|
|
443
|
-
});
|
|
444
|
-
__publicField(this, "mouseUpColorPickerPalette", (e) => {
|
|
445
|
-
this.colorPickerPaletteSelect = false;
|
|
446
|
-
});
|
|
447
|
-
this.setAttribute("class", "ran-colorpicker");
|
|
448
|
-
this.popoverBlock = document.createElement("r-popover");
|
|
449
|
-
this.popoverBlock.setAttribute("class", "ran-popover");
|
|
450
|
-
this.popoverContent = document.createElement("r-content");
|
|
451
|
-
this.popoverContent.setAttribute("class", "ran-content");
|
|
452
|
-
this.colorpicker = document.createElement("div");
|
|
453
|
-
this.colorpicker.setAttribute("class", "ran-colorpicker-block");
|
|
454
|
-
this.colorpickerInner = document.createElement("div");
|
|
455
|
-
this.colorpickerInner.setAttribute("class", "ran-colorpicker-inner");
|
|
456
|
-
this.popoverBlock.appendChild(this.colorpicker);
|
|
457
|
-
this.popoverBlock.appendChild(this.popoverContent);
|
|
458
|
-
this.colorpicker.appendChild(this.colorpickerInner);
|
|
459
|
-
this.appendChild(this.popoverBlock);
|
|
460
|
-
this.colorPickerPaletteSelect = false;
|
|
461
|
-
this.createContext();
|
|
462
|
-
}
|
|
463
|
-
static get observedAttributes() {
|
|
464
|
-
return ["disabled", "value"];
|
|
465
|
-
}
|
|
466
|
-
get value() {
|
|
467
|
-
var _a;
|
|
468
|
-
return ((_a = this.context) == null ? void 0 : _a.value.getter()) || "";
|
|
469
|
-
}
|
|
470
|
-
set value(value) {
|
|
471
|
-
this.setAttribute("value", value);
|
|
472
|
-
this.updateColorValue(value);
|
|
473
|
-
}
|
|
474
|
-
connectedCallback() {
|
|
475
|
-
this.popoverBlock.addEventListener("click", this.openColorPicker);
|
|
476
|
-
}
|
|
477
|
-
disconnectCallback() {
|
|
478
|
-
var _a, _b, _c;
|
|
479
|
-
this.popoverBlock.removeEventListener("click", this.openColorPicker);
|
|
480
|
-
(_a = this.colorPickerPanelDot) == null ? void 0 : _a.removeEventListener("mousedown", this.mouseDownColorPickerPalette);
|
|
481
|
-
document.body.removeEventListener("mousemove", this.mouseMoveColorPickerPalette);
|
|
482
|
-
(_b = this.colorPickerPanelDot) == null ? void 0 : _b.removeEventListener("mouseup", this.mouseUpColorPickerPalette);
|
|
483
|
-
(_c = this.colorPickerPanelPalette) == null ? void 0 : _c.removeEventListener("mousedown", this.clickColorPalette);
|
|
484
|
-
}
|
|
485
|
-
attributeChangedCallback(n, o, v) {
|
|
486
|
-
if (o !== v) {
|
|
487
|
-
if (n === "value") {
|
|
488
|
-
this.updateColorValue(v);
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
function Custom() {
|
|
494
|
-
if (typeof document !== "undefined" && !customElements.get("r-colorpicker")) {
|
|
495
|
-
customElements.define("r-colorpicker", ColorPicker);
|
|
496
|
-
return ColorPicker;
|
|
497
|
-
} else {
|
|
498
|
-
return createCustomError("document is undefined or r-colorpicker is exist");
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
const index = Custom();
|
|
502
|
-
const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
503
|
-
__proto__: null,
|
|
504
|
-
ColorPicker,
|
|
505
|
-
default: index
|
|
506
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
507
|
-
export {
|
|
508
|
-
ColorPicker as C,
|
|
509
|
-
index as a,
|
|
510
|
-
index$1 as i
|
|
511
|
-
};
|