geekin-devtoys 0.5.0 → 0.5.3
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/lib/GBranched/style.css +92 -0
- package/lib/GBranched.d.ts +3 -0
- package/lib/GButton/index.js +1 -1
- package/lib/GButton/index.mjs +13 -13
- package/lib/GButton/style.css +92 -1
- package/lib/GButton.d.ts +3 -0
- package/lib/GCard/index.js +1 -1
- package/lib/GCard/index.mjs +1 -1
- package/lib/GCard/style.css +93 -1
- package/lib/GCard.d.ts +3 -0
- package/lib/GCount.d.ts +3 -0
- package/lib/GDialog/style.css +92 -1
- package/lib/GDialog.d.ts +3 -0
- package/lib/GDropdown/style.css +92 -0
- package/lib/GDropdown.d.ts +3 -0
- package/lib/GFuzzyText/index.js +1 -1
- package/lib/GFuzzyText/index.mjs +15 -14
- package/lib/GFuzzyText.d.ts +3 -0
- package/lib/GInput/index.js +1 -1
- package/lib/GInput/index.mjs +1 -1
- package/lib/GInput/style.css +92 -1
- package/lib/GInput.d.ts +3 -0
- package/lib/GPagination.d.ts +3 -0
- package/lib/GPicker/index.js +1 -1
- package/lib/GPicker/index.mjs +1 -1
- package/lib/GPicker/style.css +92 -1
- package/lib/GPicker.d.ts +3 -0
- package/lib/GPie3D/index.js +1 -1
- package/lib/GPie3D/index.mjs +21 -20
- package/lib/GPie3D/style.css +93 -1
- package/lib/GPie3D.d.ts +3 -0
- package/lib/GPluginVideo/index.js +1 -1
- package/lib/GPluginVideo/index.mjs +9 -9
- package/lib/GPluginVideo.d.ts +5 -0
- package/lib/GProgress/index.js +1 -1
- package/lib/GProgress/index.mjs +1 -1
- package/lib/GProgress/style.css +93 -1
- package/lib/GProgress.d.ts +3 -0
- package/lib/GRing/index.js +1 -1
- package/lib/GRing/index.mjs +1 -1
- package/lib/GRing/style.css +93 -1
- package/lib/GRing.d.ts +3 -0
- package/lib/GScreen.d.ts +3 -0
- package/lib/GScroller/index.js +1 -1
- package/lib/GScroller/index.mjs +1 -1
- package/lib/GScroller/style.css +93 -1
- package/lib/GScroller.d.ts +3 -0
- package/lib/GScrubber/index.js +1 -0
- package/lib/GScrubber/index.mjs +250 -0
- package/lib/GScrubber.d.ts +4 -0
- package/lib/GSegment/index.js +1 -1
- package/lib/GSegment/index.mjs +246 -212
- package/lib/GSegment/style.css +93 -1
- package/lib/GSegment.d.ts +3 -0
- package/lib/GShinyText.d.ts +3 -0
- package/lib/GSlider/style.css +92 -0
- package/lib/GSlider.d.ts +3 -0
- package/lib/GSteps/index.js +1 -1
- package/lib/GSteps/index.mjs +19 -19
- package/lib/GSteps/style.css +93 -1
- package/lib/GSteps.d.ts +3 -0
- package/lib/GSwitch/index.js +1 -0
- package/lib/GSwitch/index.mjs +199 -0
- package/lib/GSwitch/style.css +93 -0
- package/lib/GSwitch.d.ts +4 -0
- package/lib/GTable/index.js +1 -1
- package/lib/GTable/index.mjs +6 -6
- package/lib/GTable/style.css +92 -1
- package/lib/GTable.d.ts +3 -0
- package/lib/GTag/index.js +1 -1
- package/lib/GTag/index.mjs +17 -17
- package/lib/GTag/style.css +92 -1
- package/lib/GTag.d.ts +3 -0
- package/lib/GToast/index.js +1 -1
- package/lib/GToast/index.mjs +10 -10
- package/lib/GToast/style.css +93 -1
- package/lib/GToast.d.ts +3 -0
- package/lib/GTree/index.js +1 -1
- package/lib/GTree/index.mjs +28 -28
- package/lib/GTree/style.css +93 -1
- package/lib/GTree.d.ts +3 -0
- package/lib/GVideo/index.js +2 -2
- package/lib/GVideo/index.mjs +8 -8
- package/lib/GVideo/style.css +93 -1
- package/lib/GVideo.d.ts +5 -0
- package/lib/assets/GScrubber.css +1 -0
- package/lib/components/GBranched/__tests__/index.test.d.ts +1 -0
- package/lib/components/GBranched/index.d.ts +6 -6
- package/lib/components/GButton/__tests__/index.test.d.ts +1 -0
- package/lib/components/GButton/index.d.ts +8 -19
- package/lib/components/GButton/types.d.ts +37 -0
- package/lib/components/GCard/__tests__/index.test.d.ts +1 -0
- package/lib/components/GCard/index.d.ts +2 -18
- package/lib/components/GCard/types.d.ts +66 -0
- package/lib/components/GCount/__tests__/index.test.d.ts +1 -0
- package/lib/components/GCount/index.d.ts +8 -23
- package/lib/components/GCount/types.d.ts +38 -0
- package/lib/components/GDialog/__tests__/index.test.d.ts +1 -0
- package/lib/components/GDialog/index.d.ts +1 -1
- package/lib/components/GDropdown/index.d.ts +6 -34
- package/lib/components/GDropdown/types.d.ts +116 -0
- package/lib/components/GFuzzyText/__tests__/index.test.d.ts +1 -0
- package/lib/components/GFuzzyText/index.d.ts +5 -42
- package/lib/components/GFuzzyText/types.d.ts +93 -0
- package/lib/components/GInput/__tests__/index.test.d.ts +1 -0
- package/lib/components/GInput/index.d.ts +5 -25
- package/lib/components/GInput/types.d.ts +50 -0
- package/lib/components/GPagination/index.d.ts +1 -1
- package/lib/components/GPicker/__tests__/index.test.d.ts +1 -0
- package/lib/components/GPicker/index.d.ts +7 -70
- package/lib/components/GPicker/types.d.ts +165 -0
- package/lib/components/GPie3D/__tests__/index.test.d.ts +1 -0
- package/lib/components/GPie3D/index.d.ts +5 -83
- package/lib/components/GPie3D/types.d.ts +106 -0
- package/lib/components/GPluginVideo/__tests__/index.test.d.ts +1 -0
- package/lib/components/GPluginVideo/index.d.ts +1 -0
- package/lib/components/GPluginVideo/types.d.ts +86 -0
- package/lib/components/GProgress/__tests__/index.test.d.ts +1 -0
- package/lib/components/GProgress/index.d.ts +3 -47
- package/lib/components/GProgress/types.d.ts +46 -0
- package/lib/components/GRing/__tests__/index.test.d.ts +1 -0
- package/lib/components/GRing/index.d.ts +4 -54
- package/lib/components/GRing/types.d.ts +52 -0
- package/lib/components/GScreen/__tests__/index.test.d.ts +1 -0
- package/lib/components/GScreen/index.d.ts +3 -22
- package/lib/components/GScreen/types.d.ts +21 -0
- package/lib/components/GScroller/__tests__/index.test.d.ts +1 -0
- package/lib/components/GScroller/index.d.ts +4 -23
- package/lib/components/GScroller/types.d.ts +73 -0
- package/lib/components/GScrubber/__tests__/index.test.d.ts +1 -0
- package/lib/components/GScrubber/index.d.ts +31 -0
- package/lib/components/GScrubber/types.d.ts +101 -0
- package/lib/components/GSegment/__tests__/index.test.d.ts +1 -0
- package/lib/components/GSegment/index.d.ts +8 -7
- package/lib/components/GSegment/types.d.ts +10 -4
- package/lib/components/GShinyText/__tests__/index.test.d.ts +1 -0
- package/lib/components/GShinyText/index.d.ts +5 -28
- package/lib/components/GShinyText/types.d.ts +65 -0
- package/lib/components/GSlider/__tests__/index.test.d.ts +1 -0
- package/lib/components/GSlider/index.d.ts +3 -3
- package/lib/components/GSteps/__tests__/index.test.d.ts +1 -0
- package/lib/components/GSteps/index.d.ts +3 -21
- package/lib/components/GSteps/types.d.ts +42 -0
- package/lib/components/GSwitch/__tests__/index.test.d.ts +1 -0
- package/lib/components/{GRadio → GSwitch}/index.d.ts +9 -9
- package/lib/components/{GRadio → GSwitch}/types.d.ts +7 -7
- package/lib/components/GTable/index.d.ts +4 -89
- package/lib/components/GTable/types.d.ts +87 -0
- package/lib/components/GTag/__tests__/index.test.d.ts +1 -0
- package/lib/components/GTag/index.d.ts +7 -18
- package/lib/components/GTag/types.d.ts +34 -0
- package/lib/components/GToast/__tests__/index.test.d.ts +1 -0
- package/lib/components/GTree/__tests__/index.test.d.ts +1 -0
- package/lib/components/GVideo/__tests__/index.test.d.ts +1 -0
- package/lib/components/GVideo/index.d.ts +1 -0
- package/lib/components/GVideo/types.d.ts +38 -0
- package/lib/index/index.js +1 -1
- package/lib/index/index.mjs +48 -45
- package/lib/index/style.css +109 -17
- package/lib/index.d.ts +5 -3
- package/package.json +19 -16
- package/lib/GRadio/index.js +0 -1
- package/lib/GRadio/index.mjs +0 -198
- package/lib/GRadio/style.css +0 -1
- package/lib/GRadio.d.ts +0 -1
package/lib/GDropdown/style.css
CHANGED
|
@@ -1 +1,93 @@
|
|
|
1
|
+
@charset "UTF-8";
|
|
2
|
+
/*
|
|
3
|
+
* 组件库公共样式:全局 CSS 变量,供各组件消费
|
|
4
|
+
* 按模块拆分文件管理(颜色 → color.css,尺寸 → size.css),在此聚合引入
|
|
5
|
+
* 此文件额外承载非颜色非尺寸类变量,颜色变量一律放 color.css、尺寸变量一律放 size.css
|
|
6
|
+
*/
|
|
7
|
+
/*
|
|
8
|
+
* 颜色变量模块:所有颜色类 CSS 变量集中于此管理
|
|
9
|
+
* 变量统一携带 --g- 库名称空间前缀,避免污染宿主项目的命名空间
|
|
10
|
+
* 同一颜色全库共用一个变量(如 --g-primary-color),不再按组件拆分
|
|
11
|
+
* 派生色(primary-light 等)用 color-mix() 从基础色实时混出,
|
|
12
|
+
* 业务侧覆盖基础色换肤时派生色自动跟随,无需逐个同步
|
|
13
|
+
* 业务侧可在任意祖先节点(:root / body / 容器)覆盖同名变量实现换肤
|
|
14
|
+
*/
|
|
15
|
+
:root {
|
|
16
|
+
/* ===== 公共语义色(primary / success / warning / danger 全库共用) ===== */
|
|
17
|
+
--g-primary-color: #039be5; /* 主色,覆盖它即可换主题色,派生色自动联动 */
|
|
18
|
+
--g-primary-light-color: color-mix(in srgb, var(--g-primary-color) 10%, var(--g-bg-color)); /* 主色浅底,hover / 选中背景 */
|
|
19
|
+
--g-success-color: #50c189; /* 成功色 */
|
|
20
|
+
--g-warning-color: #f78716; /* 警告色 */
|
|
21
|
+
--g-danger-color: #e1594d; /* 危险色 */
|
|
22
|
+
--g-emphasis-color: #000000; /* 强调色(浅色模式黑,深色模式反白为白) */
|
|
23
|
+
--g-emphasis-text-color: #ffffff; /* 强调色上的文字色 */
|
|
24
|
+
|
|
25
|
+
/* ===== 公共中性色(随深色模式切换) ===== */
|
|
26
|
+
--g-text-color: rgba(0, 0, 0, 0.88); /* 主要文字色 */
|
|
27
|
+
--g-text-secondary-color: rgba(0, 0, 0, 0.45); /* 次要文字色 */
|
|
28
|
+
--g-text-placeholder-color: rgba(0, 0, 0, 0.35); /* 占位文字色 */
|
|
29
|
+
--g-bg-color: #ffffff; /* 组件背景色 */
|
|
30
|
+
--g-overlay-bg-color: #ffffff; /* 浮层(dropdown / 弹层)背景色 */
|
|
31
|
+
--g-border-color: #dcdfe3; /* 边框色 */
|
|
32
|
+
--g-border-light-color: #e4e7ea; /* 更浅边框色(行分隔线等) */
|
|
33
|
+
--g-border-strong-color: #cdd0d4; /* 更深边框色(容器外框等) */
|
|
34
|
+
--g-fill-color: #f0f2f5; /* 填充色(表头渐变深端) */
|
|
35
|
+
--g-fill-light-color: #f5f7fa; /* 浅填充色(表头渐变浅端 / 底座背景) */
|
|
36
|
+
--g-fill-lighter-color: #fafafa; /* 更浅填充色(斑马纹) */
|
|
37
|
+
|
|
38
|
+
/* ===== 组件特有变量 ===== */
|
|
39
|
+
--g-button-default-color: #e8e8eb; /* default 按钮底色 */
|
|
40
|
+
--g-input-group-bg-color: #e8e8eb; /* input 的 prepend / append 拼接块底色 */
|
|
41
|
+
--g-scrubber-chip-color: #e8e8eb; /* GScrubber 数值刮擦器芯片底色 */
|
|
42
|
+
--g-scrubber-accent-color: var(--g-primary-color); /* GScrubber 主题色(填充 / 描边 / 增量气泡底),联动主色换肤 */
|
|
43
|
+
--g-scrubber-ghost-ink-color: #ffffff; /* GScrubber 增量气泡文字色(主色底上反白) */
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* 深色模式:跟随 vueuse useDark 的 html.dark 约定自动切换
|
|
47
|
+
仅覆盖随模式变化的值;--g-primary-light-color 混入的 --g-bg-color 在此处已是深色底,自动联动无需覆盖 */
|
|
48
|
+
html.dark {
|
|
49
|
+
--g-emphasis-color: #ffffff; /* 深色底上反白为白,避免融进背景 */
|
|
50
|
+
--g-emphasis-text-color: #000000; /* 反白后文字为黑 */
|
|
51
|
+
|
|
52
|
+
--g-text-color: #e5eaf3; /* 主要文字色 */
|
|
53
|
+
--g-text-secondary-color: rgba(255, 255, 255, 0.45);
|
|
54
|
+
--g-text-placeholder-color: rgba(255, 255, 255, 0.35);
|
|
55
|
+
--g-bg-color: #2b2b2f;
|
|
56
|
+
--g-overlay-bg-color: #1d1e1f; /* 浮层比页面底更深一档 */
|
|
57
|
+
--g-border-color: #4c4d4f;
|
|
58
|
+
--g-border-light-color: #414243;
|
|
59
|
+
--g-border-strong-color: #636466;
|
|
60
|
+
--g-fill-color: #303030;
|
|
61
|
+
--g-fill-light-color: #262727;
|
|
62
|
+
--g-fill-lighter-color: #1d1e1f;
|
|
63
|
+
|
|
64
|
+
--g-button-default-color: #333336; /* 深色底上的 default 按钮底色 */
|
|
65
|
+
--g-input-group-bg-color: #333336; /* 深色拼接块底色 */
|
|
66
|
+
--g-scrubber-chip-color: #333336; /* 深色底上的刮擦器芯片底色 */
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/*
|
|
70
|
+
* 组件尺寸体系:大 / 中(默认)/ 小,全库统一(GButton / GInput / GTag / GSwitch 共用)
|
|
71
|
+
* 高度基准与 GButton 一致:large 40 / middle 32 / small 24,字号 16 / 14 / 12
|
|
72
|
+
* 组件以回退形式消费:var(--g-size-xxx, 组件内默认值),在任意祖先节点覆盖变量即可全库联动
|
|
73
|
+
* 圆角 / 内边距等派生尺寸由各组件按自身规则推导,不放这里
|
|
74
|
+
*/
|
|
75
|
+
:root {
|
|
76
|
+
/* 高度 */
|
|
77
|
+
--g-size-large-height: 40px;
|
|
78
|
+
--g-size-middle-height: 32px;
|
|
79
|
+
--g-size-small-height: 24px;
|
|
80
|
+
/* 字号 */
|
|
81
|
+
--g-size-large-font-size: 16px;
|
|
82
|
+
--g-size-middle-font-size: 14px;
|
|
83
|
+
--g-size-small-font-size: 12px;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
:root {
|
|
88
|
+
/* ===== GButton ===== */
|
|
89
|
+
--g-button-bg-color: var(--g-button-default-color); /* 按钮背景色 @default 跟随 --g-button-default-color(深色模式自动切换) */
|
|
90
|
+
--g-button-font-size: var(--g-size-middle-font-size, 14px); /* 按钮字号 @default 跟随统一尺寸体系的 middle 档字号 */
|
|
91
|
+
--g-button-radius: 6px; /* 按钮圆角 @default 6px(large 尺寸 8px / small 尺寸 4px 由组件推导) */
|
|
92
|
+
}
|
|
1
93
|
.g-dropdown{position:relative;display:inline-block}.g-dropdown[data-disabled]{opacity:.5}.g-dropdown__trigger{position:relative;display:inline-flex;align-items:center;gap:6px;height:var(--gs-chip);margin:0;padding:0 8px 0 10px;border:0;border-radius:var(--gs-inner-radius);outline:none;background:var(--gs-surface);color:var(--gs-text);font-family:inherit;font-size:var(--gs-font);font-weight:500;line-height:1;cursor:pointer;-webkit-user-select:none;user-select:none;touch-action:manipulation;-webkit-tap-highlight-color:transparent;transition:background-color .1s ease,transform .16s cubic-bezier(.23,1,.32,1)}.g-dropdown__trigger:disabled{cursor:default}.g-dropdown__trigger:not(:disabled):active{transform:scale(.97)}.g-dropdown__trigger[aria-expanded=true]{background:color-mix(in srgb,var(--gs-highlight) 60%,var(--gs-surface))}@media(hover:hover)and (pointer:fine){.g-dropdown__trigger:not(:disabled):hover{background:color-mix(in srgb,var(--gs-highlight) 60%,var(--gs-surface))}}.g-dropdown__trigger[data-custom]{height:auto;padding:0;gap:0;background:transparent;border-radius:0}.g-dropdown__trigger[data-custom][aria-expanded=true]{background:transparent}@media(hover:hover)and (pointer:fine){.g-dropdown__trigger[data-custom]:not(:disabled):hover{background:transparent}}.g-dropdown__trigger[data-custom]:not(:disabled):active{transform:none}.g-dropdown__label[data-empty]{opacity:.6}.g-dropdown[data-swap] .g-dropdown__label{animation:gs-swap .16s ease}.g-dropdown__arrow{display:inline-flex;color:color-mix(in srgb,var(--gs-text) 55%,transparent);transition:transform .2s cubic-bezier(.23,1,.32,1)}.g-dropdown__trigger[aria-expanded=true] .g-dropdown__arrow{transform:rotate(180deg)}.g-dropdown__menu{position:absolute;z-index:20;top:calc(100% + 6px);left:0;min-width:100%;width:var(--gs-menu-w);padding:4px;border-radius:var(--gs-radius);background:var(--gs-surface);box-shadow:0 4px 16px color-mix(in srgb,#000 22%,transparent);transform:scale(.95);transform-origin:var(--gs-origin);opacity:0;pointer-events:none;transition:opacity var(--gs-pop) cubic-bezier(.23,1,.32,1),transform var(--gs-pop) cubic-bezier(.23,1,.32,1)}.g-dropdown__menu[data-side=top]{top:auto;bottom:calc(100% + 6px)}.g-dropdown__menu[data-align=right]{left:auto;right:0}.g-dropdown__menu[data-state=open]{transform:scale(1);opacity:1;pointer-events:auto}.g-dropdown__menu[data-state=closed]{transition-duration:var(--gs-pop-out);pointer-events:none}.g-dropdown__menu[data-slot]{width:auto;min-width:0}.g-dropdown__menu[data-teleported]{min-width:0;z-index:2000}.g-dropdown__list{position:relative;display:grid;gap:1px;touch-action:none}.g-dropdown__pill{position:absolute;top:0;right:0;left:0;height:var(--gs-row);border-radius:var(--gs-inner-radius);background:var(--gs-highlight);opacity:0;pointer-events:none;transition:transform var(--gs-glide) cubic-bezier(.23,1,.32,1),opacity .15s ease}.g-dropdown__option{position:relative;z-index:1;display:flex;align-items:center;gap:8px;height:var(--gs-row);padding:0 8px 0 10px;border-radius:var(--gs-inner-radius);color:var(--gs-text);font-size:var(--gs-font);cursor:pointer;-webkit-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent;transition:background-color .15s ease}.g-dropdown__option[aria-selected=true]{background:color-mix(in srgb,var(--gs-highlight) 60%,transparent)}.g-dropdown__list[data-live] .g-dropdown__option[aria-selected=true]{background:transparent}.g-dropdown__option-label{flex:1 1 0%;min-width:0;overflow:hidden;font-weight:500;text-overflow:ellipsis;white-space:nowrap}.g-dropdown__option-tag{flex-shrink:0;color:color-mix(in srgb,var(--gs-text) 55%,transparent);font-size:calc(var(--gs-font) - 2px)}.g-dropdown__option-check{display:inline-flex;flex-shrink:0;visibility:hidden;color:var(--gs-accent)}.g-dropdown__option-check[data-on]{visibility:visible}@keyframes gs-swap{0%{opacity:.6;filter:blur(2px)}}@media(prefers-reduced-motion:reduce){.g-dropdown__trigger{transition:background-color .1s ease}.g-dropdown__trigger:not(:disabled):active{transform:none}.g-dropdown[data-swap] .g-dropdown__label{animation:none}.g-dropdown__arrow{transition:none}.g-dropdown__menu{transform:none!important;transition:opacity var(--gs-pop) ease}.g-dropdown__menu[data-state=closed]{transition-duration:var(--gs-pop-out)}.g-dropdown__pill{transition:opacity .15s ease}}
|
package/lib/GDropdown.d.ts
CHANGED
package/lib/GFuzzyText/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("vue"),S=a.defineComponent({__name:"index",props:{fontSize:{default:"clamp(2rem, 8vw, 8rem)"},fontWeight:{default:900},fontFamily:{default:"inherit"},color:{default:"#fff"},enableHover:{type:Boolean,default:!0},baseIntensity:{default:.18},hoverIntensity:{default:.5},fuzzRange:{default:30},fps:{default:60},direction:{default:"horizontal"},transitionDuration:{default:0},clickEffect:{type:Boolean,default:!1},glitchMode:{type:Boolean,default:!1},glitchInterval:{default:2e3},glitchDuration:{default:200},gradient:{default:null},letterSpacing:{default:0},className:{default:""}},setup(
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("vue"),S=a.defineComponent({name:"GFuzzyText",__name:"index",props:{fontSize:{default:"clamp(2rem, 8vw, 8rem)"},fontWeight:{default:900},fontFamily:{default:"inherit"},color:{default:"#fff"},enableHover:{type:Boolean,default:!0},baseIntensity:{default:.18},hoverIntensity:{default:.5},fuzzRange:{default:30},fps:{default:60},direction:{default:"horizontal"},transitionDuration:{default:0},clickEffect:{type:Boolean,default:!1},glitchMode:{type:Boolean,default:!1},glitchInterval:{default:2e3},glitchDuration:{default:200},gradient:{default:null},letterSpacing:{default:0},className:{default:""}},setup(F){const e=F,_=a.useTemplateRef("canvasRef"),Q=a.useSlots(),G=a.computed(()=>{const d=Q.default?.()??[],c=h=>h.map(s=>typeof s.children=="string"?s.children:Array.isArray(s.children)?c(s.children):"").join("");return c(d)});let I=0,x=null;const H=async()=>{const d=++I;let c=0,h=null,s=null,T=null;const q=[],M=()=>d!==I,l=_.value;if(!l)return;const R=l.getContext("2d");if(!R)return;const V=e.fontFamily==="inherit"?window.getComputedStyle(l).fontFamily||"sans-serif":e.fontFamily,Z=typeof e.fontSize=="number"?`${e.fontSize}px`:e.fontSize,C=`${e.fontWeight} ${Z} ${V}`;try{await document.fonts.load(C)}catch{await document.fonts.ready}if(M())return;let B;if(typeof e.fontSize=="number")B=e.fontSize;else{const t=document.createElement("span");t.style.fontSize=e.fontSize,document.body.appendChild(t),B=parseFloat(getComputedStyle(t).fontSize),document.body.removeChild(t)}const g=G.value,b=document.createElement("canvas"),o=b.getContext("2d");if(!o)return;o.font=C,o.textBaseline="alphabetic";let m=0;if(e.letterSpacing!==0){for(const t of g)m+=o.measureText(t).width+e.letterSpacing;m-=e.letterSpacing}else m=o.measureText(g).width;const p=o.measureText(g),$=p.actualBoundingBoxLeft??0,ee=e.letterSpacing!==0?m:p.actualBoundingBoxRight??p.width,w=p.actualBoundingBoxAscent??B,te=p.actualBoundingBoxDescent??B*.2,j=Math.ceil(e.letterSpacing!==0?m:$+ee),z=Math.ceil(w+te),N=10,f=j+N;b.width=f,b.height=z;const A=N/2;if(o.font=C,o.textBaseline="alphabetic",e.gradient&&Array.isArray(e.gradient)&&e.gradient.length>=2){const t=o.createLinearGradient(0,0,f,0);e.gradient.forEach((n,i)=>t.addColorStop(i/(e.gradient.length-1),n)),o.fillStyle=t}else o.fillStyle=e.color;if(e.letterSpacing!==0){let t=A;for(const n of g)o.fillText(n,t,w),t+=o.measureText(n).width+e.letterSpacing}else o.fillText(g,A-$,w);const E=e.fuzzRange+20,k=e.direction==="vertical"||e.direction==="both"?e.fuzzRange+10:0;l.width=f+E*2,l.height=z+k*2,R.translate(E,k);const O=E+A,P=k,ne=O+j,ie=P+z;let v=!1,D=!1,L=!1,r=e.baseIntensity,u=e.baseIntensity,X=0;const Y=()=>{!e.glitchMode||M()||(h=setTimeout(()=>{M()||(L=!0,s=setTimeout(()=>{L=!1,Y()},e.glitchDuration))},e.glitchInterval))};e.glitchMode&&Y();const W=t=>{if(M())return;const n=1e3/e.fps;if(t-X<n){c=requestAnimationFrame(W);return}if(X=t,R.clearRect(-(e.fuzzRange+20),-(e.fuzzRange+10),f+2*(e.fuzzRange+20),z+2*(e.fuzzRange+10)),D||L?u=1:v?u=e.hoverIntensity:u=e.baseIntensity,e.transitionDuration>0){const i=1/(e.transitionDuration/n);r<u?r=Math.min(r+i,u):r>u&&(r=Math.max(r-i,u))}else r=u;for(let i=0;i<z;i++){let J=0,K=0;(e.direction==="horizontal"||e.direction==="both")&&(J=Math.floor(r*(Math.random()-.5)*e.fuzzRange)),(e.direction==="vertical"||e.direction==="both")&&(K=Math.floor(r*(Math.random()-.5)*e.fuzzRange*.5)),R.drawImage(b,0,i,f,1,J,i+K,f,1)}c=requestAnimationFrame(W)};c=requestAnimationFrame(W);const U=(t,n)=>t>=O&&t<=ne&&n>=P&&n<=ie,oe=t=>{if(!e.enableHover)return;const n=l.getBoundingClientRect();v=U(t.clientX-n.left,t.clientY-n.top)},ae=()=>{v=!1},le=()=>{e.clickEffect&&(D=!0,clearTimeout(T??void 0),T=setTimeout(()=>{D=!1},150))},re=t=>{if(!e.enableHover)return;t.preventDefault();const n=l.getBoundingClientRect(),i=t.touches[0];v=U(i.clientX-n.left,i.clientY-n.top)},ce=()=>{v=!1},y=(t,n,i)=>{l.addEventListener(t,n,i),q.push(()=>l.removeEventListener(t,n,i))};y("mousemove",oe),y("mouseleave",ae),y("touchmove",re,{passive:!1}),y("touchend",ce),y("click",le),x=()=>{cancelAnimationFrame(c),h!==null&&clearTimeout(h),s!==null&&clearTimeout(s),T!==null&&clearTimeout(T),q.forEach(t=>t())}};return a.onMounted(()=>{H()}),a.onBeforeUnmount(()=>{I++,x?.()}),a.watch(()=>({text:G.value,fontSize:e.fontSize,fontWeight:e.fontWeight,fontFamily:e.fontFamily,color:e.color,gradient:e.gradient,letterSpacing:e.letterSpacing,direction:e.direction,fuzzRange:e.fuzzRange,glitchMode:e.glitchMode}),()=>{x?.(),x=null,H()},{deep:!0}),(d,c)=>(a.openBlock(),a.createElementBlock("canvas",{ref_key:"canvasRef",ref:_,class:a.normalizeClass(d.className)},null,2))}});S.install=F=>{F.component(S.name,S)};exports.GFuzzyText=S;exports.default=S;
|
package/lib/GFuzzyText/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineComponent as ct, useTemplateRef as st, useSlots as ft, computed as ut, onMounted as dt, onBeforeUnmount as ht, watch as mt, createElementBlock as gt, openBlock as pt, normalizeClass as zt } from "vue";
|
|
2
2
|
const L = /* @__PURE__ */ ct({
|
|
3
|
+
name: "GFuzzyText",
|
|
3
4
|
__name: "index",
|
|
4
5
|
props: {
|
|
5
6
|
fontSize: { default: "clamp(2rem, 8vw, 8rem)" },
|
|
@@ -27,16 +28,16 @@ const L = /* @__PURE__ */ ct({
|
|
|
27
28
|
return r(u);
|
|
28
29
|
});
|
|
29
30
|
let b = 0, v = null;
|
|
30
|
-
const
|
|
31
|
+
const G = async () => {
|
|
31
32
|
const u = ++b;
|
|
32
33
|
let r = 0, d = null, c = null, S = null;
|
|
33
|
-
const
|
|
34
|
+
const H = [], x = () => u !== b, a = W.value;
|
|
34
35
|
if (!a) return;
|
|
35
36
|
const T = a.getContext("2d");
|
|
36
37
|
if (!T) return;
|
|
37
|
-
const Q = t.fontFamily === "inherit" ? window.getComputedStyle(a).fontFamily || "sans-serif" : t.fontFamily, V = typeof t.fontSize == "number" ? `${t.fontSize}px` : t.fontSize,
|
|
38
|
+
const Q = t.fontFamily === "inherit" ? window.getComputedStyle(a).fontFamily || "sans-serif" : t.fontFamily, V = typeof t.fontSize == "number" ? `${t.fontSize}px` : t.fontSize, F = `${t.fontWeight} ${V} ${Q}`;
|
|
38
39
|
try {
|
|
39
|
-
await document.fonts.load(
|
|
40
|
+
await document.fonts.load(F);
|
|
40
41
|
} catch {
|
|
41
42
|
await document.fonts.ready;
|
|
42
43
|
}
|
|
@@ -50,7 +51,7 @@ const L = /* @__PURE__ */ ct({
|
|
|
50
51
|
}
|
|
51
52
|
const h = _.value, B = document.createElement("canvas"), o = B.getContext("2d");
|
|
52
53
|
if (!o) return;
|
|
53
|
-
o.font =
|
|
54
|
+
o.font = F, o.textBaseline = "alphabetic";
|
|
54
55
|
let m = 0;
|
|
55
56
|
if (t.letterSpacing !== 0) {
|
|
56
57
|
for (const e of h)
|
|
@@ -58,12 +59,12 @@ const L = /* @__PURE__ */ ct({
|
|
|
58
59
|
m -= t.letterSpacing;
|
|
59
60
|
} else
|
|
60
61
|
m = o.measureText(h).width;
|
|
61
|
-
const g = o.measureText(h), $ = g.actualBoundingBoxLeft ?? 0, Z = t.letterSpacing !== 0 ? m : g.actualBoundingBoxRight ?? g.width,
|
|
62
|
+
const g = o.measureText(h), $ = g.actualBoundingBoxLeft ?? 0, Z = t.letterSpacing !== 0 ? m : g.actualBoundingBoxRight ?? g.width, I = g.actualBoundingBoxAscent ?? R, tt = g.actualBoundingBoxDescent ?? R * 0.2, q = Math.ceil(
|
|
62
63
|
t.letterSpacing !== 0 ? m : $ + Z
|
|
63
|
-
), p = Math.ceil(
|
|
64
|
+
), p = Math.ceil(I + tt), j = 10, f = q + j;
|
|
64
65
|
B.width = f, B.height = p;
|
|
65
66
|
const C = j / 2;
|
|
66
|
-
if (o.font =
|
|
67
|
+
if (o.font = F, o.textBaseline = "alphabetic", t.gradient && Array.isArray(t.gradient) && t.gradient.length >= 2) {
|
|
67
68
|
const e = o.createLinearGradient(0, 0, f, 0);
|
|
68
69
|
t.gradient.forEach((n, i) => e.addColorStop(i / (t.gradient.length - 1), n)), o.fillStyle = e;
|
|
69
70
|
} else
|
|
@@ -71,9 +72,9 @@ const L = /* @__PURE__ */ ct({
|
|
|
71
72
|
if (t.letterSpacing !== 0) {
|
|
72
73
|
let e = C;
|
|
73
74
|
for (const n of h)
|
|
74
|
-
o.fillText(n, e,
|
|
75
|
+
o.fillText(n, e, I), e += o.measureText(n).width + t.letterSpacing;
|
|
75
76
|
} else
|
|
76
|
-
o.fillText(h, C - $,
|
|
77
|
+
o.fillText(h, C - $, I);
|
|
77
78
|
const w = t.fuzzRange + 20, A = t.direction === "vertical" || t.direction === "both" ? t.fuzzRange + 10 : 0;
|
|
78
79
|
a.width = f + w * 2, a.height = p + A * 2, T.translate(w, A);
|
|
79
80
|
const N = w + C, X = A, et = N + q, nt = X + p;
|
|
@@ -128,14 +129,14 @@ const L = /* @__PURE__ */ ct({
|
|
|
128
129
|
}, rt = () => {
|
|
129
130
|
z = !1;
|
|
130
131
|
}, y = (e, n, i) => {
|
|
131
|
-
a.addEventListener(e, n, i),
|
|
132
|
+
a.addEventListener(e, n, i), H.push(() => a.removeEventListener(e, n, i));
|
|
132
133
|
};
|
|
133
134
|
y("mousemove", it), y("mouseleave", ot), y("touchmove", lt, { passive: !1 }), y("touchend", rt), y("click", at), v = () => {
|
|
134
|
-
cancelAnimationFrame(r), d !== null && clearTimeout(d), c !== null && clearTimeout(c), S !== null && clearTimeout(S),
|
|
135
|
+
cancelAnimationFrame(r), d !== null && clearTimeout(d), c !== null && clearTimeout(c), S !== null && clearTimeout(S), H.forEach((e) => e());
|
|
135
136
|
};
|
|
136
137
|
};
|
|
137
138
|
return dt(() => {
|
|
138
|
-
|
|
139
|
+
G();
|
|
139
140
|
}), ht(() => {
|
|
140
141
|
b++, v?.();
|
|
141
142
|
}), mt(
|
|
@@ -152,7 +153,7 @@ const L = /* @__PURE__ */ ct({
|
|
|
152
153
|
glitchMode: t.glitchMode
|
|
153
154
|
}),
|
|
154
155
|
() => {
|
|
155
|
-
v?.(), v = null,
|
|
156
|
+
v?.(), v = null, G();
|
|
156
157
|
},
|
|
157
158
|
{ deep: !0 }
|
|
158
159
|
), (u, r) => (pt(), gt("canvas", {
|
package/lib/GFuzzyText.d.ts
CHANGED
package/lib/GInput/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),u=require("motion-v"),M=require("../GBranched-BtF7heMk.js"),P={class:"g-input__wrapper"},T={key:0,class:"g-input__prefix"},q=["type","value","disabled","readonly","maxlength"],O={key:1,class:"g-input__suffix"},D={key:0,class:"g-input__slot-suffix"},F={key:1,class:"g-input__count"},L={key:0,class:"g-input__count-max"},R=e.defineComponent({name:"GInput",inheritAttrs:!1,__name:"index",props:{modelValue:{},type:{},size:{},disabled:{type:Boolean},readonly:{type:Boolean},clearable:{type:Boolean},showCount:{type:Boolean},maxlength:{},block:{type:Boolean}},emits:["update:modelValue","input","change","focus","blur","clear"],setup(c,{expose:y,emit:v}){const o=c,n=v,i=e.useAttrs(),_=e.useSlots(),g=e.computed(()=>{const{class:t,style:l,...d}=i;return d}),k=e.computed(()=>["g-input",`g-input--${o.size??"middle"}`,{"is-block":o.block,"is-disabled":o.disabled,"is-readonly":o.readonly,"is-focused":p.value},i.class]),h=e.computed(()=>i.style),s=e.ref(),r=e.ref(!1),p=e.ref(!1),B=e.computed(()=>m.value||!!_.suffix||o.showCount),m=e.computed(()=>o.clearable&&!o.disabled&&!o.readonly&&r.value&&String(o.modelValue??"").length>0),f=e.computed(()=>String(o.modelValue??"").length),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),u=require("motion-v"),M=require("../GBranched-BtF7heMk.js"),P={class:"g-input__wrapper"},T={key:0,class:"g-input__prefix"},q=["type","value","disabled","readonly","maxlength"],O={key:1,class:"g-input__suffix"},D={key:0,class:"g-input__slot-suffix"},F={key:1,class:"g-input__count"},L={key:0,class:"g-input__count-max"},R=e.defineComponent({name:"GInput",inheritAttrs:!1,__name:"index",props:{modelValue:{},type:{},size:{},disabled:{type:Boolean},readonly:{type:Boolean},clearable:{type:Boolean},showCount:{type:Boolean},maxlength:{},block:{type:Boolean}},emits:["update:modelValue","input","change","focus","blur","clear"],setup(c,{expose:y,emit:v}){const o=c,n=v,i=e.useAttrs(),_=e.useSlots(),g=e.computed(()=>{const{class:t,style:l,...d}=i;return d}),k=e.computed(()=>["g-input",`g-input--${o.size??"middle"}`,{"is-block":o.block,"is-disabled":o.disabled,"is-readonly":o.readonly,"is-focused":p.value},i.class]),h=e.computed(()=>i.style),s=e.ref(),r=e.ref(!1),p=e.ref(!1),B=e.computed(()=>m.value||!!_.suffix||o.showCount),m=e.computed(()=>o.clearable&&!o.disabled&&!o.readonly&&r.value&&String(o.modelValue??"").length>0),f=e.computed(()=>String(o.modelValue??"").length),b={opacity:0,scale:.6},C={opacity:1,scale:1},V={opacity:0,scale:.6},x={duration:.15,ease:"easeOut"},S={opacity:0,y:4},N={opacity:1,y:0},E={opacity:0,y:-4},w={duration:.15,ease:"easeOut"},A=t=>{const l=t.target.value;n("update:modelValue",l),n("input",l)},I=t=>{n("change",t.target.value)},$=t=>{p.value=!0,n("focus",t)},z=t=>{p.value=!1,n("blur",t)},G=()=>{n("update:modelValue",""),n("input",""),n("change",""),n("clear"),s.value?.focus()};return y({focus:()=>s.value?.focus(),blur:()=>s.value?.blur(),select:()=>s.value?.select()}),(t,l)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(k.value),style:e.normalizeStyle(h.value),onMouseenter:l[0]||(l[0]=d=>r.value=!0),onMouseleave:l[1]||(l[1]=d=>r.value=!1)},[e.createElementVNode("div",P,[t.$slots.prefix?(e.openBlock(),e.createElementBlock("span",T,[e.renderSlot(t.$slots,"prefix",{},void 0,!0)])):e.createCommentVNode("",!0),e.createElementVNode("input",e.mergeProps({ref_key:"inputRef",ref:s,class:"g-input__inner",type:t.type,value:t.modelValue??"",disabled:t.disabled,readonly:t.readonly,maxlength:t.maxlength},g.value,{onInput:A,onChange:I,onFocus:$,onBlur:z}),null,16,q),B.value?(e.openBlock(),e.createElementBlock("span",O,[e.createVNode(e.unref(u.AnimatePresence),null,{default:e.withCtx(()=>[m.value?(e.openBlock(),e.createBlock(e.unref(u.motion).span,{key:0,class:"g-input__clear",initial:b,animate:C,exit:V,transition:x,onClick:G})):e.createCommentVNode("",!0)]),_:1}),t.$slots.suffix?(e.openBlock(),e.createElementBlock("span",D,[e.renderSlot(t.$slots,"suffix",{},void 0,!0)])):e.createCommentVNode("",!0),t.showCount?(e.openBlock(),e.createElementBlock("span",F,[e.createVNode(e.unref(u.AnimatePresence),{mode:"popLayout"},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.unref(u.motion).span,{key:f.value,class:"g-input__count-text",initial:S,animate:N,exit:E,transition:w},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(f.value),1)]),_:1}))]),_:1}),t.maxlength!=null?(e.openBlock(),e.createElementBlock("span",L," / "+e.toDisplayString(t.maxlength),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])],38))}}),a=M._export_sfc(R,[["__scopeId","data-v-313c3b35"]]);a.install=c=>{c.component(a.name,a)};exports.GInput=a;exports.default=a;
|
package/lib/GInput/index.mjs
CHANGED
|
@@ -135,7 +135,7 @@ const te = { class: "g-input__wrapper" }, se = {
|
|
|
135
135
|
])
|
|
136
136
|
], 38));
|
|
137
137
|
}
|
|
138
|
-
}), v = /* @__PURE__ */ ee(ie, [["__scopeId", "data-v-
|
|
138
|
+
}), v = /* @__PURE__ */ ee(ie, [["__scopeId", "data-v-313c3b35"]]);
|
|
139
139
|
v.install = (c) => {
|
|
140
140
|
c.component(v.name, v);
|
|
141
141
|
};
|
package/lib/GInput/style.css
CHANGED
|
@@ -1 +1,92 @@
|
|
|
1
|
-
@charset "UTF-8"
|
|
1
|
+
@charset "UTF-8";/*
|
|
2
|
+
* 组件库公共样式:全局 CSS 变量,供各组件消费
|
|
3
|
+
* 按模块拆分文件管理(颜色 → color.css,尺寸 → size.css),在此聚合引入
|
|
4
|
+
* 此文件额外承载非颜色非尺寸类变量,颜色变量一律放 color.css、尺寸变量一律放 size.css
|
|
5
|
+
*/
|
|
6
|
+
/*
|
|
7
|
+
* 颜色变量模块:所有颜色类 CSS 变量集中于此管理
|
|
8
|
+
* 变量统一携带 --g- 库名称空间前缀,避免污染宿主项目的命名空间
|
|
9
|
+
* 同一颜色全库共用一个变量(如 --g-primary-color),不再按组件拆分
|
|
10
|
+
* 派生色(primary-light 等)用 color-mix() 从基础色实时混出,
|
|
11
|
+
* 业务侧覆盖基础色换肤时派生色自动跟随,无需逐个同步
|
|
12
|
+
* 业务侧可在任意祖先节点(:root / body / 容器)覆盖同名变量实现换肤
|
|
13
|
+
*/
|
|
14
|
+
:root {
|
|
15
|
+
/* ===== 公共语义色(primary / success / warning / danger 全库共用) ===== */
|
|
16
|
+
--g-primary-color: #039be5; /* 主色,覆盖它即可换主题色,派生色自动联动 */
|
|
17
|
+
--g-primary-light-color: color-mix(in srgb, var(--g-primary-color) 10%, var(--g-bg-color)); /* 主色浅底,hover / 选中背景 */
|
|
18
|
+
--g-success-color: #50c189; /* 成功色 */
|
|
19
|
+
--g-warning-color: #f78716; /* 警告色 */
|
|
20
|
+
--g-danger-color: #e1594d; /* 危险色 */
|
|
21
|
+
--g-emphasis-color: #000000; /* 强调色(浅色模式黑,深色模式反白为白) */
|
|
22
|
+
--g-emphasis-text-color: #ffffff; /* 强调色上的文字色 */
|
|
23
|
+
|
|
24
|
+
/* ===== 公共中性色(随深色模式切换) ===== */
|
|
25
|
+
--g-text-color: rgba(0, 0, 0, 0.88); /* 主要文字色 */
|
|
26
|
+
--g-text-secondary-color: rgba(0, 0, 0, 0.45); /* 次要文字色 */
|
|
27
|
+
--g-text-placeholder-color: rgba(0, 0, 0, 0.35); /* 占位文字色 */
|
|
28
|
+
--g-bg-color: #ffffff; /* 组件背景色 */
|
|
29
|
+
--g-overlay-bg-color: #ffffff; /* 浮层(dropdown / 弹层)背景色 */
|
|
30
|
+
--g-border-color: #dcdfe3; /* 边框色 */
|
|
31
|
+
--g-border-light-color: #e4e7ea; /* 更浅边框色(行分隔线等) */
|
|
32
|
+
--g-border-strong-color: #cdd0d4; /* 更深边框色(容器外框等) */
|
|
33
|
+
--g-fill-color: #f0f2f5; /* 填充色(表头渐变深端) */
|
|
34
|
+
--g-fill-light-color: #f5f7fa; /* 浅填充色(表头渐变浅端 / 底座背景) */
|
|
35
|
+
--g-fill-lighter-color: #fafafa; /* 更浅填充色(斑马纹) */
|
|
36
|
+
|
|
37
|
+
/* ===== 组件特有变量 ===== */
|
|
38
|
+
--g-button-default-color: #e8e8eb; /* default 按钮底色 */
|
|
39
|
+
--g-input-group-bg-color: #e8e8eb; /* input 的 prepend / append 拼接块底色 */
|
|
40
|
+
--g-scrubber-chip-color: #e8e8eb; /* GScrubber 数值刮擦器芯片底色 */
|
|
41
|
+
--g-scrubber-accent-color: var(--g-primary-color); /* GScrubber 主题色(填充 / 描边 / 增量气泡底),联动主色换肤 */
|
|
42
|
+
--g-scrubber-ghost-ink-color: #ffffff; /* GScrubber 增量气泡文字色(主色底上反白) */
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* 深色模式:跟随 vueuse useDark 的 html.dark 约定自动切换
|
|
46
|
+
仅覆盖随模式变化的值;--g-primary-light-color 混入的 --g-bg-color 在此处已是深色底,自动联动无需覆盖 */
|
|
47
|
+
html.dark {
|
|
48
|
+
--g-emphasis-color: #ffffff; /* 深色底上反白为白,避免融进背景 */
|
|
49
|
+
--g-emphasis-text-color: #000000; /* 反白后文字为黑 */
|
|
50
|
+
|
|
51
|
+
--g-text-color: #e5eaf3; /* 主要文字色 */
|
|
52
|
+
--g-text-secondary-color: rgba(255, 255, 255, 0.45);
|
|
53
|
+
--g-text-placeholder-color: rgba(255, 255, 255, 0.35);
|
|
54
|
+
--g-bg-color: #2b2b2f;
|
|
55
|
+
--g-overlay-bg-color: #1d1e1f; /* 浮层比页面底更深一档 */
|
|
56
|
+
--g-border-color: #4c4d4f;
|
|
57
|
+
--g-border-light-color: #414243;
|
|
58
|
+
--g-border-strong-color: #636466;
|
|
59
|
+
--g-fill-color: #303030;
|
|
60
|
+
--g-fill-light-color: #262727;
|
|
61
|
+
--g-fill-lighter-color: #1d1e1f;
|
|
62
|
+
|
|
63
|
+
--g-button-default-color: #333336; /* 深色底上的 default 按钮底色 */
|
|
64
|
+
--g-input-group-bg-color: #333336; /* 深色拼接块底色 */
|
|
65
|
+
--g-scrubber-chip-color: #333336; /* 深色底上的刮擦器芯片底色 */
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/*
|
|
69
|
+
* 组件尺寸体系:大 / 中(默认)/ 小,全库统一(GButton / GInput / GTag / GSwitch 共用)
|
|
70
|
+
* 高度基准与 GButton 一致:large 40 / middle 32 / small 24,字号 16 / 14 / 12
|
|
71
|
+
* 组件以回退形式消费:var(--g-size-xxx, 组件内默认值),在任意祖先节点覆盖变量即可全库联动
|
|
72
|
+
* 圆角 / 内边距等派生尺寸由各组件按自身规则推导,不放这里
|
|
73
|
+
*/
|
|
74
|
+
:root {
|
|
75
|
+
/* 高度 */
|
|
76
|
+
--g-size-large-height: 40px;
|
|
77
|
+
--g-size-middle-height: 32px;
|
|
78
|
+
--g-size-small-height: 24px;
|
|
79
|
+
/* 字号 */
|
|
80
|
+
--g-size-large-font-size: 16px;
|
|
81
|
+
--g-size-middle-font-size: 14px;
|
|
82
|
+
--g-size-small-font-size: 12px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
:root {
|
|
87
|
+
/* ===== GButton ===== */
|
|
88
|
+
--g-button-bg-color: var(--g-button-default-color); /* 按钮背景色 @default 跟随 --g-button-default-color(深色模式自动切换) */
|
|
89
|
+
--g-button-font-size: var(--g-size-middle-font-size, 14px); /* 按钮字号 @default 跟随统一尺寸体系的 middle 档字号 */
|
|
90
|
+
--g-button-radius: 6px; /* 按钮圆角 @default 6px(large 尺寸 8px / small 尺寸 4px 由组件推导) */
|
|
91
|
+
}
|
|
92
|
+
.g-input[data-v-313c3b35]{display:inline-flex;align-items:stretch;width:var(--g-input-width, 240px);font-size:var(--g-input-font-size, var(--g-size-middle-font-size, 14px));color:var(--g-text-color, rgba(0, 0, 0, .88))}.g-input:not(.is-disabled):hover .g-input__wrapper[data-v-313c3b35]{border-color:var(--g-primary-color, #039be5)}.g-input.is-focused:not(.is-disabled) .g-input__wrapper[data-v-313c3b35]{border-color:var(--g-primary-color, #039be5);box-shadow:0 0 0 2px color-mix(in srgb,var(--g-primary-color, #039be5) 15%,transparent)}.g-input.is-block[data-v-313c3b35]{display:flex;width:100%}.g-input.is-disabled[data-v-313c3b35]{cursor:not-allowed;color:var(--g-input-disabled-text-color, rgba(0, 0, 0, .3))}.g-input.is-disabled .g-input__wrapper[data-v-313c3b35]{background:var(--g-input-disabled-bg-color, #f2f3f5);border-color:var(--g-border-color, #dcdfe3)}.g-input.is-disabled .g-input__inner[data-v-313c3b35]{cursor:not-allowed;-webkit-text-fill-color:var(--g-input-disabled-text-color, rgba(0, 0, 0, .3))}.g-input.is-disabled .g-input__inner[data-v-313c3b35]::placeholder{color:var(--g-input-disabled-text-color, rgba(0, 0, 0, .3))}.g-input--large[data-v-313c3b35]{--g-input-height: var(--g-size-large-height, 40px);--g-input-font-size: var(--g-size-large-font-size, 16px)}.g-input--small[data-v-313c3b35]{--g-input-height: var(--g-size-small-height, 24px);--g-input-font-size: var(--g-size-small-font-size, 12px)}.g-input__wrapper[data-v-313c3b35]{position:relative;flex:1;display:inline-flex;align-items:center;gap:4px;min-width:0;height:var(--g-input-height, var(--g-size-middle-height, 32px));padding:0 8px;background:var(--g-bg-color, #ffffff);border:1px solid var(--g-border-color, #dcdfe3);border-radius:var(--g-input-radius, 6px);transition:border-color .2s cubic-bezier(.645,.045,.355,1),box-shadow .2s cubic-bezier(.645,.045,.355,1)}.g-input__inner[data-v-313c3b35]{flex:1;min-width:0;height:100%;padding:0;font:inherit;color:inherit;background:transparent;border:none;outline:none;caret-color:var(--g-primary-color, #039be5)}.g-input__inner[data-v-313c3b35]::placeholder{color:var(--g-text-placeholder-color, rgba(0, 0, 0, .35))}.g-input__prefix[data-v-313c3b35],.g-input__suffix[data-v-313c3b35]{display:inline-flex;align-items:center;gap:4px;color:var(--g-text-placeholder-color, rgba(0, 0, 0, .35))}.g-input__prefix[data-v-313c3b35] svg,.g-input__suffix[data-v-313c3b35] svg{width:1em;height:1em;display:block}.g-input__clear[data-v-313c3b35]{position:relative;flex-shrink:0;width:1em;height:1em;cursor:pointer;color:var(--g-text-placeholder-color, rgba(0, 0, 0, .35));transition:color .2s}.g-input__clear[data-v-313c3b35]:before,.g-input__clear[data-v-313c3b35]:after{content:"";position:absolute;left:50%;top:50%;width:100%;height:1px;background:currentcolor}.g-input__clear[data-v-313c3b35]:before{transform:translate(-50%,-50%) rotate(45deg)}.g-input__clear[data-v-313c3b35]:after{transform:translate(-50%,-50%) rotate(-45deg)}.g-input__clear[data-v-313c3b35]:hover{color:var(--g-text-color, rgba(0, 0, 0, .88))}.g-input__count[data-v-313c3b35]{flex-shrink:0;font-size:12px;font-variant-numeric:tabular-nums;color:var(--g-text-placeholder-color, rgba(0, 0, 0, .35))}.g-input__count-text[data-v-313c3b35]{display:inline-block}
|
package/lib/GInput.d.ts
CHANGED
package/lib/GPagination.d.ts
CHANGED
package/lib/GPicker/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),ve=require("../GInput/index.js"),me=require("../GTag/index.js"),be=require("../GTree/index.js"),O=require("../GToast/index.js"),x=require("motion-v"),ge=require("../GBranched-BtF7heMk.js"),he={key:0,class:"g-picker__tags"},ye=t.defineComponent({__name:"index",props:{modelValue:{default:()=>[]},data:{default:()=>[]},props:{default:()=>({})},echoProps:{},nodeKey:{default:"id"},placeholder:{default:"请输入关键字搜索"},width:{default:320},popperMaxHeight:{default:320},popperZIndex:{default:2e3},popperOffset:{default:4},defaultExpandAll:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},clearable:{type:Boolean,default:!0},closable:{type:Boolean,default:!0},tagType:{default:"primary"},tagVariant:{default:"filled"},clearInputAfterSelect:{type:Boolean,default:!0},enterToAdd:{type:Boolean,default:!0},valueFormat:{default:"value"},selectable:{},filterMethod:{},duplicateMessage:{default:"该项已添加"},notFoundMessage:{default:"未找到匹配项"}},emits:["update:modelValue","change","add","remove","node-click","duplicate","not-found"],setup(E,{expose:R,emit:$}){const a=E,r=$,H=t.computed(()=>({label:a.props.label||"label",children:a.props.children||"children",disabled:a.props.disabled})),q=t.computed(()=>a.props.value||a.nodeKey||"id"),G=t.computed(()=>a.props.label||"label"),j=t.computed(()=>a.props.children||"children"),S=t.computed(()=>a.props.isLeaf),K=t.computed(()=>a.echoProps?.value||"value"),U=t.computed(()=>a.echoProps?.label||"label"),v=e=>e?e[q.value]:void 0,c=e=>e?e[G.value]:"",M=e=>e?e[j.value]:void 0,Z=e=>e?.[K.value]??e?.value,W=e=>e?.[U.value]??e?.label,d=e=>{if(!e)return!1;if(typeof a.selectable=="function")return a.selectable(e);if(S.value&&e[S.value]!==void 0)return!!e[S.value];const o=M(e);return!o||!o.length},C=t.computed(()=>{const e=new Map,o=(l=[])=>{l.forEach(n=>{d(n)&&e.set(v(n),n);const s=M(n);s?.length&&o(s)})};return o(a.data||[]),e}),i=t.computed(()=>(a.modelValue||[]).map(o=>{const l=a.valueFormat==="object"?Z(o):o,n=C.value.get(l),s=a.valueFormat==="object"?W(o):void 0;return{value:l,label:n?c(n):s??String(l??""),raw:n??(a.valueFormat==="object"?o:void 0)}})),y=e=>i.value.some(o=>o.value===e),w=t.ref(""),u=t.ref(!1),N=t.ref(null),I=t.ref(null),T=t.ref(null),p=t.ref(null),J=e=>{if(!e){p.value=null;return}p.value=e.$el??(e instanceof HTMLElement?e:null)},L=t.ref({}),m=t.ref("bottom"),Q=t.computed(()=>({opacity:0,scale:.95,y:m.value==="bottom"?-8:8})),X={opacity:1,scale:1,y:0},Y=t.computed(()=>({opacity:0,scale:.95,y:m.value==="bottom"?-8:8})),D={duration:.2,ease:"easeOut"},ee=t.computed(()=>({...L.value,transformOrigin:m.value==="bottom"?"top center":"bottom center"})),te={opacity:0,scale:.8},oe={opacity:1,scale:1},le={opacity:0,scale:.8},ae={duration:.2,ease:"easeOut"},ne=t.computed(()=>typeof a.width=="number"?`${a.width}px`:a.width),_=()=>{a.disabled||(u.value=!0)},k=()=>{if(!u.value)return;const e=T.value,o=p.value;if(!e||!o)return;const l=e.getBoundingClientRect(),n=o.offsetHeight||a.popperMaxHeight,B=window.innerHeight-l.bottom-a.popperOffset,pe=l.top-a.popperOffset,z=B>=n||B>=pe?"bottom":"top";m.value=z;const fe=z==="bottom"?l.bottom+a.popperOffset:l.top-n-a.popperOffset;L.value={position:"fixed",top:`${fe}px`,left:`${l.left}px`,width:`${l.width}px`,zIndex:String(a.popperZIndex)}};let f=null;const b=()=>{u.value&&(f&&cancelAnimationFrame(f),f=requestAnimationFrame(()=>{f=null,k()}))};let g=null;const re=()=>{typeof ResizeObserver>"u"||!p.value||(g?.disconnect(),g=new ResizeObserver(()=>b()),g.observe(p.value))},P=()=>{g?.disconnect(),g=null};t.watch(u,async e=>{if(!e){P();return}await t.nextTick(),k(),requestAnimationFrame(k),re()});const A=e=>{if(!u.value)return;const o=e.target;I.value?.contains(o)||p.value?.contains(o)||(u.value=!1)};t.onMounted(()=>{document.addEventListener("mousedown",A,!0),window.addEventListener("scroll",b,!0),window.addEventListener("resize",b)}),t.onBeforeUnmount(()=>{document.removeEventListener("mousedown",A,!0),window.removeEventListener("scroll",b,!0),window.removeEventListener("resize",b),f&&cancelAnimationFrame(f),P()});const se=e=>{u.value=!0,N.value?.filter(e),t.nextTick(k)},ie=(e,o)=>e?typeof a.filterMethod=="function"?a.filterMethod(e,o):String(c(o)??"").toLowerCase().includes(String(e).toLowerCase()):!0,ue=e=>{r("node-click",e),d(e)&&(F(e),u.value=!1)},ce=e=>a.valueFormat==="object"?{value:e.value,label:e.label,raw:e.raw}:e.value,F=e=>{const o=v(e);if(o==null||o==="")return;if(y(o)){const s={value:o,label:c(e),raw:e};r("duplicate",s),a.duplicateMessage&&O.toast.warning(a.duplicateMessage,{position:"top-center"});return}const l={value:o,label:c(e),raw:e},n=[...a.modelValue||[],ce(l)];r("update:modelValue",n),r("add",l),r("change",n,[...i.value,l]),a.clearInputAfterSelect&&(w.value="")},de=()=>{if(!a.enterToAdd)return;const e=(w.value||"").trim();if(!e)return;let o=null;for(const l of C.value.values())if(c(l)===e){o=l;break}if(!o){r("not-found",e),a.notFoundMessage&&O.toast.warning(a.notFoundMessage,{position:"top-center"});return}F(o)},V=e=>{if(e<0||e>=i.value.length)return;const o=i.value[e],l=[...a.modelValue||[]];l.splice(e,1),r("update:modelValue",l),o&&r("remove",o,e);const n=i.value.filter((s,B)=>B!==e);r("change",l,n)};return R({open:_,close:()=>u.value=!1,clear:()=>{r("update:modelValue",[]),r("change",[],[])},addByValue:e=>{const o=C.value.get(e);o&&F(o)},removeByIndex:e=>{V(e)},removeByValue:e=>{const o=i.value.findIndex(l=>l.value===e);o>-1&&V(o)},getSelectedItems:()=>i.value}),(e,o)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["g-picker",{"is-disabled":e.disabled}])},[t.createElementVNode("div",{class:"g-picker__wrap",ref_key:"wrapRef",ref:I},[t.createElementVNode("div",{class:"g-picker__input-box",ref_key:"inputBoxRef",ref:T,style:t.normalizeStyle({width:ne.value})},[t.createVNode(t.unref(ve.default),{modelValue:w.value,"onUpdate:modelValue":o[0]||(o[0]=l=>w.value=l),placeholder:e.placeholder,clearable:e.clearable,disabled:e.disabled,block:"",class:"g-picker__input",onFocus:_,onClick:_,onInput:se,onKeyup:t.withKeys(de,["enter"])},null,8,["modelValue","placeholder","clearable","disabled"])],4),(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[t.createVNode(t.unref(x.AnimatePresence),null,{default:t.withCtx(()=>[u.value?(t.openBlock(),t.createBlock(t.unref(x.motion).div,{key:0,ref:J,class:t.normalizeClass(["g-picker__popover",`is-${m.value}`]),style:t.normalizeStyle(ee.value),initial:Q.value,animate:X,exit:Y.value,transition:D,onMousedown:o[1]||(o[1]=t.withModifiers(()=>{},["prevent"]))},{default:t.withCtx(()=>[t.createElementVNode("div",{class:"g-picker__tree-wrap",style:t.normalizeStyle({maxHeight:e.popperMaxHeight+"px"})},[t.createVNode(t.unref(be.default),{ref_key:"treeRef",ref:N,data:e.data,props:H.value,"node-key":e.nodeKey,"filter-method":ie,"default-expand-all":e.defaultExpandAll,"highlight-current":!1,onNodeClick:ue},{default:t.withCtx(({data:l,level:n,expanded:s})=>[t.renderSlot(e.$slots,"tree-node",{data:l,node:{level:n,expanded:s},selectable:d(l),selected:y(v(l))},()=>[l?(t.openBlock(),t.createElementBlock("span",{key:0,class:t.normalizeClass(["g-picker__node",{"is-selectable":d(l),"is-selected":d(l)&&y(v(l))}])},[t.renderSlot(e.$slots,"leaf-icon",{data:l,selectable:d(l),selected:y(v(l))},void 0,!0),t.createTextVNode(" "+t.toDisplayString(c(l)),1)],2)):t.createCommentVNode("",!0)],!0)]),_:3},8,["data","props","node-key","default-expand-all"])],4)]),_:3},8,["class","style","initial","exit"])):t.createCommentVNode("",!0)]),_:3})])),i.value.length?(t.openBlock(),t.createElementBlock("div",he,[t.renderSlot(e.$slots,"tags",{items:i.value,remove:V},()=>[t.createVNode(t.unref(x.AnimatePresence),{mode:"popLayout"},{default:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(i.value,(l,n)=>(t.openBlock(),t.createBlock(t.unref(x.motion).div,{key:l.value,layout:!0,class:"g-picker__tag-motion",initial:te,animate:oe,exit:le,transition:ae},{default:t.withCtx(()=>[t.createVNode(t.unref(me.default),{class:"g-picker__tag",type:e.tagType,variant:e.tagVariant,closable:e.closable&&!e.disabled,onClose:s=>V(n)},{default:t.withCtx(()=>[t.renderSlot(e.$slots,"tag",{item:l,index:n},()=>[t.createTextVNode(t.toDisplayString(l.label),1)],!0)]),_:2},1032,["type","variant","closable","onClose"])]),_:2},1024))),128))]),_:3})],!0)])):t.createCommentVNode("",!0)],512)],2))}}),h=ge._export_sfc(ye,[["__scopeId","data-v-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),ve=require("../GInput/index.js"),me=require("../GTag/index.js"),be=require("../GTree/index.js"),O=require("../GToast/index.js"),x=require("motion-v"),ge=require("../GBranched-BtF7heMk.js"),he={key:0,class:"g-picker__tags"},ye=t.defineComponent({__name:"index",props:{modelValue:{default:()=>[]},data:{default:()=>[]},props:{default:()=>({})},echoProps:{},nodeKey:{default:"id"},placeholder:{default:"请输入关键字搜索"},width:{default:320},popperMaxHeight:{default:320},popperZIndex:{default:2e3},popperOffset:{default:4},defaultExpandAll:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},clearable:{type:Boolean,default:!0},closable:{type:Boolean,default:!0},tagType:{default:"primary"},tagVariant:{default:"filled"},clearInputAfterSelect:{type:Boolean,default:!0},enterToAdd:{type:Boolean,default:!0},valueFormat:{default:"value"},selectable:{},filterMethod:{},duplicateMessage:{default:"该项已添加"},notFoundMessage:{default:"未找到匹配项"}},emits:["update:modelValue","change","add","remove","node-click","duplicate","not-found"],setup(E,{expose:R,emit:$}){const a=E,r=$,H=t.computed(()=>({label:a.props.label||"label",children:a.props.children||"children",disabled:a.props.disabled})),q=t.computed(()=>a.props.value||a.nodeKey||"id"),G=t.computed(()=>a.props.label||"label"),j=t.computed(()=>a.props.children||"children"),S=t.computed(()=>a.props.isLeaf),K=t.computed(()=>a.echoProps?.value||"value"),U=t.computed(()=>a.echoProps?.label||"label"),v=e=>e?e[q.value]:void 0,c=e=>e?e[G.value]:"",M=e=>e?e[j.value]:void 0,Z=e=>e?.[K.value]??e?.value,W=e=>e?.[U.value]??e?.label,d=e=>{if(!e)return!1;if(typeof a.selectable=="function")return a.selectable(e);if(S.value&&e[S.value]!==void 0)return!!e[S.value];const o=M(e);return!o||!o.length},C=t.computed(()=>{const e=new Map,o=(l=[])=>{l.forEach(n=>{d(n)&&e.set(v(n),n);const s=M(n);s?.length&&o(s)})};return o(a.data||[]),e}),i=t.computed(()=>(a.modelValue||[]).map(o=>{const l=a.valueFormat==="object"?Z(o):o,n=C.value.get(l),s=a.valueFormat==="object"?W(o):void 0;return{value:l,label:n?c(n):s??String(l??""),raw:n??(a.valueFormat==="object"?o:void 0)}})),y=e=>i.value.some(o=>o.value===e),w=t.ref(""),u=t.ref(!1),N=t.ref(null),I=t.ref(null),T=t.ref(null),p=t.ref(null),J=e=>{if(!e){p.value=null;return}p.value=e.$el??(e instanceof HTMLElement?e:null)},L=t.ref({}),m=t.ref("bottom"),Q=t.computed(()=>({opacity:0,scale:.95,y:m.value==="bottom"?-8:8})),X={opacity:1,scale:1,y:0},Y=t.computed(()=>({opacity:0,scale:.95,y:m.value==="bottom"?-8:8})),D={duration:.2,ease:"easeOut"},ee=t.computed(()=>({...L.value,transformOrigin:m.value==="bottom"?"top center":"bottom center"})),te={opacity:0,scale:.8},oe={opacity:1,scale:1},le={opacity:0,scale:.8},ae={duration:.2,ease:"easeOut"},ne=t.computed(()=>typeof a.width=="number"?`${a.width}px`:a.width),_=()=>{a.disabled||(u.value=!0)},k=()=>{if(!u.value)return;const e=T.value,o=p.value;if(!e||!o)return;const l=e.getBoundingClientRect(),n=o.offsetHeight||a.popperMaxHeight,B=window.innerHeight-l.bottom-a.popperOffset,pe=l.top-a.popperOffset,z=B>=n||B>=pe?"bottom":"top";m.value=z;const fe=z==="bottom"?l.bottom+a.popperOffset:l.top-n-a.popperOffset;L.value={position:"fixed",top:`${fe}px`,left:`${l.left}px`,width:`${l.width}px`,zIndex:String(a.popperZIndex)}};let f=null;const b=()=>{u.value&&(f&&cancelAnimationFrame(f),f=requestAnimationFrame(()=>{f=null,k()}))};let g=null;const re=()=>{typeof ResizeObserver>"u"||!p.value||(g?.disconnect(),g=new ResizeObserver(()=>b()),g.observe(p.value))},P=()=>{g?.disconnect(),g=null};t.watch(u,async e=>{if(!e){P();return}await t.nextTick(),k(),requestAnimationFrame(k),re()});const A=e=>{if(!u.value)return;const o=e.target;I.value?.contains(o)||p.value?.contains(o)||(u.value=!1)};t.onMounted(()=>{document.addEventListener("mousedown",A,!0),window.addEventListener("scroll",b,!0),window.addEventListener("resize",b)}),t.onBeforeUnmount(()=>{document.removeEventListener("mousedown",A,!0),window.removeEventListener("scroll",b,!0),window.removeEventListener("resize",b),f&&cancelAnimationFrame(f),P()});const se=e=>{u.value=!0,N.value?.filter(e),t.nextTick(k)},ie=(e,o)=>e?typeof a.filterMethod=="function"?a.filterMethod(e,o):String(c(o)??"").toLowerCase().includes(String(e).toLowerCase()):!0,ue=e=>{r("node-click",e),d(e)&&(F(e),u.value=!1)},ce=e=>a.valueFormat==="object"?{value:e.value,label:e.label,raw:e.raw}:e.value,F=e=>{const o=v(e);if(o==null||o==="")return;if(y(o)){const s={value:o,label:c(e),raw:e};r("duplicate",s),a.duplicateMessage&&O.toast.warning(a.duplicateMessage,{position:"top-center"});return}const l={value:o,label:c(e),raw:e},n=[...a.modelValue||[],ce(l)];r("update:modelValue",n),r("add",l),r("change",n,[...i.value,l]),a.clearInputAfterSelect&&(w.value="")},de=()=>{if(!a.enterToAdd)return;const e=(w.value||"").trim();if(!e)return;let o=null;for(const l of C.value.values())if(c(l)===e){o=l;break}if(!o){r("not-found",e),a.notFoundMessage&&O.toast.warning(a.notFoundMessage,{position:"top-center"});return}F(o)},V=e=>{if(e<0||e>=i.value.length)return;const o=i.value[e],l=[...a.modelValue||[]];l.splice(e,1),r("update:modelValue",l),o&&r("remove",o,e);const n=i.value.filter((s,B)=>B!==e);r("change",l,n)};return R({open:_,close:()=>u.value=!1,clear:()=>{r("update:modelValue",[]),r("change",[],[])},addByValue:e=>{const o=C.value.get(e);o&&F(o)},removeByIndex:e=>{V(e)},removeByValue:e=>{const o=i.value.findIndex(l=>l.value===e);o>-1&&V(o)},getSelectedItems:()=>i.value}),(e,o)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["g-picker",{"is-disabled":e.disabled}])},[t.createElementVNode("div",{class:"g-picker__wrap",ref_key:"wrapRef",ref:I},[t.createElementVNode("div",{class:"g-picker__input-box",ref_key:"inputBoxRef",ref:T,style:t.normalizeStyle({width:ne.value})},[t.createVNode(t.unref(ve.default),{modelValue:w.value,"onUpdate:modelValue":o[0]||(o[0]=l=>w.value=l),placeholder:e.placeholder,clearable:e.clearable,disabled:e.disabled,block:"",class:"g-picker__input",onFocus:_,onClick:_,onInput:se,onKeyup:t.withKeys(de,["enter"])},null,8,["modelValue","placeholder","clearable","disabled"])],4),(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[t.createVNode(t.unref(x.AnimatePresence),null,{default:t.withCtx(()=>[u.value?(t.openBlock(),t.createBlock(t.unref(x.motion).div,{key:0,ref:J,class:t.normalizeClass(["g-picker__popover",`is-${m.value}`]),style:t.normalizeStyle(ee.value),initial:Q.value,animate:X,exit:Y.value,transition:D,onMousedown:o[1]||(o[1]=t.withModifiers(()=>{},["prevent"]))},{default:t.withCtx(()=>[t.createElementVNode("div",{class:"g-picker__tree-wrap",style:t.normalizeStyle({maxHeight:e.popperMaxHeight+"px"})},[t.createVNode(t.unref(be.default),{ref_key:"treeRef",ref:N,data:e.data,props:H.value,"node-key":e.nodeKey,"filter-method":ie,"default-expand-all":e.defaultExpandAll,"highlight-current":!1,onNodeClick:ue},{default:t.withCtx(({data:l,level:n,expanded:s})=>[t.renderSlot(e.$slots,"tree-node",{data:l,node:{level:n,expanded:s},selectable:d(l),selected:y(v(l))},()=>[l?(t.openBlock(),t.createElementBlock("span",{key:0,class:t.normalizeClass(["g-picker__node",{"is-selectable":d(l),"is-selected":d(l)&&y(v(l))}])},[t.renderSlot(e.$slots,"leaf-icon",{data:l,selectable:d(l),selected:y(v(l))},void 0,!0),t.createTextVNode(" "+t.toDisplayString(c(l)),1)],2)):t.createCommentVNode("",!0)],!0)]),_:3},8,["data","props","node-key","default-expand-all"])],4)]),_:3},8,["class","style","initial","exit"])):t.createCommentVNode("",!0)]),_:3})])),i.value.length?(t.openBlock(),t.createElementBlock("div",he,[t.renderSlot(e.$slots,"tags",{items:i.value,remove:V},()=>[t.createVNode(t.unref(x.AnimatePresence),{mode:"popLayout"},{default:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(i.value,(l,n)=>(t.openBlock(),t.createBlock(t.unref(x.motion).div,{key:l.value,layout:!0,class:"g-picker__tag-motion",initial:te,animate:oe,exit:le,transition:ae},{default:t.withCtx(()=>[t.createVNode(t.unref(me.default),{class:"g-picker__tag",type:e.tagType,variant:e.tagVariant,closable:e.closable&&!e.disabled,onClose:s=>V(n)},{default:t.withCtx(()=>[t.renderSlot(e.$slots,"tag",{item:l,index:n},()=>[t.createTextVNode(t.toDisplayString(l.label),1)],!0)]),_:2},1032,["type","variant","closable","onClose"])]),_:2},1024))),128))]),_:3})],!0)])):t.createCommentVNode("",!0)],512)],2))}}),h=ge._export_sfc(ye,[["__scopeId","data-v-2ed9f6cf"]]);h.install=E=>{E.component(h.name,h)};exports.GPicker=h;exports.default=h;
|
package/lib/GPicker/index.mjs
CHANGED
package/lib/GPicker/style.css
CHANGED
|
@@ -1 +1,92 @@
|
|
|
1
|
-
@charset "UTF-8"
|
|
1
|
+
@charset "UTF-8";/*
|
|
2
|
+
* 组件库公共样式:全局 CSS 变量,供各组件消费
|
|
3
|
+
* 按模块拆分文件管理(颜色 → color.css,尺寸 → size.css),在此聚合引入
|
|
4
|
+
* 此文件额外承载非颜色非尺寸类变量,颜色变量一律放 color.css、尺寸变量一律放 size.css
|
|
5
|
+
*/
|
|
6
|
+
/*
|
|
7
|
+
* 颜色变量模块:所有颜色类 CSS 变量集中于此管理
|
|
8
|
+
* 变量统一携带 --g- 库名称空间前缀,避免污染宿主项目的命名空间
|
|
9
|
+
* 同一颜色全库共用一个变量(如 --g-primary-color),不再按组件拆分
|
|
10
|
+
* 派生色(primary-light 等)用 color-mix() 从基础色实时混出,
|
|
11
|
+
* 业务侧覆盖基础色换肤时派生色自动跟随,无需逐个同步
|
|
12
|
+
* 业务侧可在任意祖先节点(:root / body / 容器)覆盖同名变量实现换肤
|
|
13
|
+
*/
|
|
14
|
+
:root {
|
|
15
|
+
/* ===== 公共语义色(primary / success / warning / danger 全库共用) ===== */
|
|
16
|
+
--g-primary-color: #039be5; /* 主色,覆盖它即可换主题色,派生色自动联动 */
|
|
17
|
+
--g-primary-light-color: color-mix(in srgb, var(--g-primary-color) 10%, var(--g-bg-color)); /* 主色浅底,hover / 选中背景 */
|
|
18
|
+
--g-success-color: #50c189; /* 成功色 */
|
|
19
|
+
--g-warning-color: #f78716; /* 警告色 */
|
|
20
|
+
--g-danger-color: #e1594d; /* 危险色 */
|
|
21
|
+
--g-emphasis-color: #000000; /* 强调色(浅色模式黑,深色模式反白为白) */
|
|
22
|
+
--g-emphasis-text-color: #ffffff; /* 强调色上的文字色 */
|
|
23
|
+
|
|
24
|
+
/* ===== 公共中性色(随深色模式切换) ===== */
|
|
25
|
+
--g-text-color: rgba(0, 0, 0, 0.88); /* 主要文字色 */
|
|
26
|
+
--g-text-secondary-color: rgba(0, 0, 0, 0.45); /* 次要文字色 */
|
|
27
|
+
--g-text-placeholder-color: rgba(0, 0, 0, 0.35); /* 占位文字色 */
|
|
28
|
+
--g-bg-color: #ffffff; /* 组件背景色 */
|
|
29
|
+
--g-overlay-bg-color: #ffffff; /* 浮层(dropdown / 弹层)背景色 */
|
|
30
|
+
--g-border-color: #dcdfe3; /* 边框色 */
|
|
31
|
+
--g-border-light-color: #e4e7ea; /* 更浅边框色(行分隔线等) */
|
|
32
|
+
--g-border-strong-color: #cdd0d4; /* 更深边框色(容器外框等) */
|
|
33
|
+
--g-fill-color: #f0f2f5; /* 填充色(表头渐变深端) */
|
|
34
|
+
--g-fill-light-color: #f5f7fa; /* 浅填充色(表头渐变浅端 / 底座背景) */
|
|
35
|
+
--g-fill-lighter-color: #fafafa; /* 更浅填充色(斑马纹) */
|
|
36
|
+
|
|
37
|
+
/* ===== 组件特有变量 ===== */
|
|
38
|
+
--g-button-default-color: #e8e8eb; /* default 按钮底色 */
|
|
39
|
+
--g-input-group-bg-color: #e8e8eb; /* input 的 prepend / append 拼接块底色 */
|
|
40
|
+
--g-scrubber-chip-color: #e8e8eb; /* GScrubber 数值刮擦器芯片底色 */
|
|
41
|
+
--g-scrubber-accent-color: var(--g-primary-color); /* GScrubber 主题色(填充 / 描边 / 增量气泡底),联动主色换肤 */
|
|
42
|
+
--g-scrubber-ghost-ink-color: #ffffff; /* GScrubber 增量气泡文字色(主色底上反白) */
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* 深色模式:跟随 vueuse useDark 的 html.dark 约定自动切换
|
|
46
|
+
仅覆盖随模式变化的值;--g-primary-light-color 混入的 --g-bg-color 在此处已是深色底,自动联动无需覆盖 */
|
|
47
|
+
html.dark {
|
|
48
|
+
--g-emphasis-color: #ffffff; /* 深色底上反白为白,避免融进背景 */
|
|
49
|
+
--g-emphasis-text-color: #000000; /* 反白后文字为黑 */
|
|
50
|
+
|
|
51
|
+
--g-text-color: #e5eaf3; /* 主要文字色 */
|
|
52
|
+
--g-text-secondary-color: rgba(255, 255, 255, 0.45);
|
|
53
|
+
--g-text-placeholder-color: rgba(255, 255, 255, 0.35);
|
|
54
|
+
--g-bg-color: #2b2b2f;
|
|
55
|
+
--g-overlay-bg-color: #1d1e1f; /* 浮层比页面底更深一档 */
|
|
56
|
+
--g-border-color: #4c4d4f;
|
|
57
|
+
--g-border-light-color: #414243;
|
|
58
|
+
--g-border-strong-color: #636466;
|
|
59
|
+
--g-fill-color: #303030;
|
|
60
|
+
--g-fill-light-color: #262727;
|
|
61
|
+
--g-fill-lighter-color: #1d1e1f;
|
|
62
|
+
|
|
63
|
+
--g-button-default-color: #333336; /* 深色底上的 default 按钮底色 */
|
|
64
|
+
--g-input-group-bg-color: #333336; /* 深色拼接块底色 */
|
|
65
|
+
--g-scrubber-chip-color: #333336; /* 深色底上的刮擦器芯片底色 */
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/*
|
|
69
|
+
* 组件尺寸体系:大 / 中(默认)/ 小,全库统一(GButton / GInput / GTag / GSwitch 共用)
|
|
70
|
+
* 高度基准与 GButton 一致:large 40 / middle 32 / small 24,字号 16 / 14 / 12
|
|
71
|
+
* 组件以回退形式消费:var(--g-size-xxx, 组件内默认值),在任意祖先节点覆盖变量即可全库联动
|
|
72
|
+
* 圆角 / 内边距等派生尺寸由各组件按自身规则推导,不放这里
|
|
73
|
+
*/
|
|
74
|
+
:root {
|
|
75
|
+
/* 高度 */
|
|
76
|
+
--g-size-large-height: 40px;
|
|
77
|
+
--g-size-middle-height: 32px;
|
|
78
|
+
--g-size-small-height: 24px;
|
|
79
|
+
/* 字号 */
|
|
80
|
+
--g-size-large-font-size: 16px;
|
|
81
|
+
--g-size-middle-font-size: 14px;
|
|
82
|
+
--g-size-small-font-size: 12px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
:root {
|
|
87
|
+
/* ===== GButton ===== */
|
|
88
|
+
--g-button-bg-color: var(--g-button-default-color); /* 按钮背景色 @default 跟随 --g-button-default-color(深色模式自动切换) */
|
|
89
|
+
--g-button-font-size: var(--g-size-middle-font-size, 14px); /* 按钮字号 @default 跟随统一尺寸体系的 middle 档字号 */
|
|
90
|
+
--g-button-radius: 6px; /* 按钮圆角 @default 6px(large 尺寸 8px / small 尺寸 4px 由组件推导) */
|
|
91
|
+
}
|
|
92
|
+
.g-picker[data-v-2ed9f6cf]{width:100%}.g-picker__wrap[data-v-2ed9f6cf]{display:flex;flex-direction:column;align-items:flex-start;gap:8px;width:100%}.g-picker__tags[data-v-2ed9f6cf]{display:flex;flex-wrap:wrap;gap:8px;width:100%}.g-picker__tag-motion[data-v-2ed9f6cf]{display:inline-flex}.g-picker__tag[data-v-2ed9f6cf]{margin:0}.g-picker.is-disabled[data-v-2ed9f6cf]{cursor:not-allowed}.g-picker__popover{box-sizing:border-box;background:var(--g-bg-color, #fff);border:1px solid var(--g-border-color, #dcdfe3);border-radius:4px;box-shadow:0 0 12px #0000001f;padding:8px 0}.g-picker__popover .g-picker__tree-wrap{overflow:auto}.g-picker__popover .g-picker__node{display:inline-flex;align-items:center;gap:4px;font-size:13px}.g-picker__popover .g-picker__node.is-selectable{cursor:pointer;color:var(--g-text-color, rgba(0, 0, 0, .88))}.g-picker__popover .g-picker__node.is-selected{color:var(--g-primary-color, #039be5)}
|
package/lib/GPicker.d.ts
CHANGED
package/lib/GPie3D/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("vue"),pt=require("../GBranched-BtF7heMk.js"),vt={class:"g-pie3d-tooltip__default"},gt={class:"g-pie3d-tooltip__name"},yt={class:"g-pie3d-tooltip__value"},mt=260,xt=h.defineComponent({__name:"index",props:{data:{default:()=>[]},config:{default:()=>({})},animation:{type:Boolean,default:!0}},emits:["slice-click"],setup(N,{emit:at}){const S=N,lt=at,V={alpha:55,depth:26,startAngle:0,colors:["#22d3ee","#3b82f6","#8b5cf6","#06b6d4","#0ea5e9","#a855f7","#14b8a6"],textColor:"#cbd5e1",radiusRatio:.55,hoverDistance:14,showLabel:!0,showPercent:!0,labelFontSize:12,opacity:.7,showAura:!0,glowColor:"",labelLineColor:"auto",labelLineWidth:1},a={...V,...S.config},E=h.ref(null),C=h.ref(null);let L=null,k=0,_=0,Y=1,p=0,u=0,g=0,M=0,
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("vue"),pt=require("../GBranched-BtF7heMk.js"),vt={class:"g-pie3d-tooltip__default"},gt={class:"g-pie3d-tooltip__name"},yt={class:"g-pie3d-tooltip__value"},mt=260,xt=h.defineComponent({name:"GPie3D",__name:"index",props:{data:{default:()=>[]},config:{default:()=>({})},animation:{type:Boolean,default:!0}},emits:["slice-click"],setup(N,{emit:at}){const S=N,lt=at,V={alpha:55,depth:26,startAngle:0,colors:["#22d3ee","#3b82f6","#8b5cf6","#06b6d4","#0ea5e9","#a855f7","#14b8a6"],textColor:"#cbd5e1",radiusRatio:.55,hoverDistance:14,showLabel:!0,showPercent:!0,labelFontSize:12,opacity:.7,showAura:!0,glowColor:"",labelLineColor:"auto",labelLineWidth:1},a={...V,...S.config},E=h.ref(null),C=h.ref(null);let L=null,k=0,_=0,Y=1,p=0,u=0,g=0,M=0,b=[],D=S.animation?0:1,F=null,q=S.animation,I=null,X=0;const $=h.ref(-1),z=h.ref(!1),J=h.ref(0),K=h.ref(0),R=h.ref(null),G=h.ref(0),Q=t=>t*Math.PI/180,O=(t,l=0,n=0)=>({x:p+l+g*Math.cos(t),y:u+n+M*Math.sin(t)}),j=(t,l=0,n=0)=>({x:p+l+g*Math.cos(t),y:u+n+M*Math.sin(t)+a.depth}),W=()=>{if(!C.value||!E.value)return;const t=E.value,l=C.value;Y=window.devicePixelRatio||1,k=t.clientWidth,_=t.clientHeight,l.width=k*Y,l.height=_*Y,l.style.width=k+"px",l.style.height=_+"px",L=l.getContext("2d"),L&&L.setTransform(Y,0,0,Y,0,0),p=k/2,u=_/2-a.depth/2;const n=a.showLabel?60:10,s=Math.min(k,_-a.depth-n)/2*a.radiusRatio*1.6;g=Math.max(20,s),M=g*Math.cos(Q(a.alpha)),it(),q?st():U()},it=()=>{b=[];const t=S.data.reduce((n,s)=>n+(s.value||0),0);if(t<=0)return;let l=-Math.PI/2+Q(a.startAngle);S.data.forEach((n,s)=>{const i=n.value/t,d=i*Math.PI*2;b.push({data:n,index:s,color:n.color||a.colors[s%a.colors.length],startA:l,endA:l+d,midA:l+d/2,percent:i,hover:!1,hoverProgress:0}),l+=d})},st=()=>{D=0;const t=800,l=performance.now(),n=s=>{const i=Math.min(1,(s-l)/t);D=1-Math.pow(1-i,3),U(),i<1?F=requestAnimationFrame(n):(q=!1,F=null)};F=requestAnimationFrame(n)},rt=t=>1-Math.pow(1-t,3),Z=t=>{const l=X===0?16:t-X;X=t;const n=l/mt;let s=!1;for(const i of b){const d=i.hover?1:0;if(i.hoverProgress===d)continue;const v=d>i.hoverProgress?1:-1;i.hoverProgress+=v*n,(v>0&&i.hoverProgress>=d||v<0&&i.hoverProgress<=d)&&(i.hoverProgress=d),i.hoverProgress!==d&&(s=!0)}U(),s?I=requestAnimationFrame(Z):(I=null,X=0)},tt=()=>{I==null&&(X=0,I=requestAnimationFrame(Z))},T=(t,l)=>{let n=t.replace("#","");n.length===3&&(n=n.split("").map(v=>v+v).join(""));const s=parseInt(n.slice(0,2),16),i=parseInt(n.slice(2,4),16),d=parseInt(n.slice(4,6),16);return`rgba(${s},${i},${d},${l})`},U=()=>{if(!L)return;const t=L;if(t.clearRect(0,0,k,_),!b.length)return;const l=b[0]?.startA??0,n=Math.PI*2*D,s=l+n,i=b.map(e=>{const c=e.startA,f=Math.min(e.endA,s),y=f>c,x=rt(Math.max(0,Math.min(1,e.hoverProgress))),A=Math.cos(e.midA)*a.hoverDistance*x,P=Math.sin(e.midA)*a.hoverDistance*x;return{...e,startA:c,endA:f,valid:y,ox:A,oy:P,hp:x}});if(a.showAura){const e=t.createRadialGradient(p,u+a.depth,g*.1,p,u+a.depth,g*1.5);e.addColorStop(0,"rgba(6,182,212,0.15)"),e.addColorStop(.4,"rgba(59,130,246,0.08)"),e.addColorStop(.8,"rgba(139,92,246,0.03)"),e.addColorStop(1,"rgba(0,0,0,0)"),t.beginPath(),t.ellipse(p,u+a.depth,g*1.5,M*.9,0,0,Math.PI*2),t.fillStyle=e,t.fill(),t.strokeStyle="rgba(56,189,248,0.08)",t.lineWidth=1;for(let c=3;c>=1;c--){const f=g*(.3+c*.25);t.beginPath(),t.ellipse(p,u+a.depth,f,f*(M/g),0,0,Math.PI*2),t.stroke()}}const d=(e,c)=>{const f=a.glowColor||e.color,y={x:p+e.ox,y:u+e.oy},x={x:y.x,y:y.y+a.depth},A=O(c,e.ox,e.oy),P=j(c,e.ox,e.oy);t.fillStyle=T(f,a.opacity*.5),t.beginPath(),t.moveTo(y.x,y.y),t.lineTo(A.x,A.y),t.lineTo(P.x,P.y),t.lineTo(x.x,x.y),t.closePath(),t.fill(),t.strokeStyle=T(f,.8),t.lineWidth=.8,t.beginPath(),t.moveTo(A.x,A.y),t.lineTo(P.x,P.y),t.stroke()};for(const e of i)e.valid&&(Math.sin(e.startA)<=.001&&d(e,e.startA),Math.sin(e.endA)<=.001&&d(e,e.endA));const v=Math.PI/120;for(const e of i){if(!e.valid)continue;let c=e.startA;const f=a.glowColor||e.color;for(;c<e.endA;){const y=Math.min(c+v,e.endA),x=(c+y)/2;if(Math.sin(x)>0){const A=O(c,e.ox,e.oy),P=O(y,e.ox,e.oy),o=j(y,e.ox,e.oy),m=j(c,e.ox,e.oy);t.fillStyle=T(f,a.opacity*.4),t.beginPath(),t.moveTo(A.x,A.y),t.lineTo(P.x,P.y),t.lineTo(o.x,o.y),t.lineTo(m.x,m.y),t.closePath(),t.fill(),t.strokeStyle=T(f,.7),t.lineWidth=.8,t.beginPath(),t.moveTo(m.x,m.y),t.lineTo(o.x,o.y),t.stroke()}c=y}}for(const e of i)e.valid&&(Math.sin(e.startA)>.001&&d(e,e.startA),Math.sin(e.endA)>.001&&d(e,e.endA));for(const e of i){if(!e.valid)continue;const c=a.glowColor||e.color;e.hp>.01&&(t.save(),t.shadowColor=c,t.shadowBlur=12*e.hp,t.beginPath(),t.moveTo(p+e.ox,u+e.oy),t.ellipse(p+e.ox,u+e.oy,g,M,0,e.startA,e.endA),t.closePath(),t.fillStyle=T(c,.08*e.hp),t.fill(),t.restore()),t.beginPath(),t.moveTo(p+e.ox,u+e.oy),t.ellipse(p+e.ox,u+e.oy,g,M,0,e.startA,e.endA),t.closePath();const f=t.createRadialGradient(p+e.ox-g*.2,u+e.oy-M*.2,0,p+e.ox,u+e.oy,g*1.05);f.addColorStop(0,T(c,a.opacity*.95)),f.addColorStop(.6,T(c,a.opacity*.8)),f.addColorStop(1,T(c,a.opacity*.6)),t.fillStyle=f,t.fill(),t.strokeStyle=T(c,.95),t.lineWidth=.8+.6*e.hp,t.stroke()}if(a.showLabel&&D>=.999){t.font=`${a.labelFontSize}px Arial, sans-serif`,t.textBaseline="middle";const e=[],c=[],f=a.labelFontSize+6,y=14,x=4;for(const o of i){if(!o.valid)continue;const m=Math.cos(o.midA)>=0,w=p+o.ox+g*1.02*Math.cos(o.midA),r=u+o.oy+M*1.02*Math.sin(o.midA),H=u+o.oy+M*1.18*Math.sin(o.midA),dt=a.showPercent?`${o.data.name} ${(o.percent*100).toFixed(1)}%`:`${o.data.name}`,ft=!a.labelLineColor||a.labelLineColor==="auto"?a.glowColor||o.color:a.labelLineColor,ut={slice:o,text:dt,isRight:m,anchorX:w,anchorY:r,targetY:H,y:H,color:ft};(m?c:e).push(ut)}const A=o=>{if(!o.length)return;o.sort((r,H)=>r.targetY-H.targetY);const m=x+a.labelFontSize/2,w=_-x-a.labelFontSize/2;for(let r=0;r<o.length;r++)r===0?o[r].y=Math.max(m,o[r].targetY):o[r].y=Math.max(o[r].targetY,o[r-1].y+f);if(o[o.length-1].y>w){o[o.length-1].y=w;for(let r=o.length-2;r>=0;r--)o[r].y>o[r+1].y-f&&(o[r].y=o[r+1].y-f)}for(let r=0;r<o.length;r++)o[r].y<m&&(o[r].y=m)};A(e),A(c),t.lineWidth=a.labelLineWidth;const P=[...e,...c];for(const o of P){const m=t.measureText(o.text).width;let w;if(o.isRight){const r=Math.min(Math.max(o.anchorX+6,o.anchorX+Math.abs(o.targetY-o.y)*.2+6),k-x-m-y);w=r+y,t.strokeStyle=o.color,t.beginPath(),t.moveTo(o.anchorX,o.anchorY),t.lineTo(r,o.y),t.lineTo(w,o.y),t.stroke(),t.fillStyle=a.textColor,t.textAlign="left",t.fillText(o.text,w+2,o.y)}else{const r=Math.max(Math.min(o.anchorX-6,o.anchorX-Math.abs(o.targetY-o.y)*.2-6),x+m+y);w=r-y,t.strokeStyle=o.color,t.beginPath(),t.moveTo(o.anchorX,o.anchorY),t.lineTo(r,o.y),t.lineTo(w,o.y),t.stroke(),t.fillStyle=a.textColor,t.textAlign="right",t.fillText(o.text,w-2,o.y)}}}},et=(t,l)=>{for(let n=0;n<b.length;n++){const s=b[n],i=(t-p)/g,d=(l-u)/M;if(i*i+d*d>1)continue;let v=Math.atan2((l-u)/M,(t-p)/g);for(;v<s.startA;)v+=Math.PI*2;for(;v>s.startA+Math.PI*2;)v-=Math.PI*2;if(v>=s.startA&&v<=s.endA)return n}return-1},ot=t=>{const l=C.value,n=l.getBoundingClientRect(),s=n.width/(l.clientWidth||n.width)||1,i=n.height/(l.clientHeight||n.height)||1;return{mx:(t.clientX-n.left)/s,my:(t.clientY-n.top)/i}},ct=t=>{if(!C.value)return;const{mx:l,my:n}=ot(t),s=et(l,n);if(s!==$.value&&($.value=s,b.forEach((i,d)=>i.hover=d===s),tt()),s>=0){const i=b[s];z.value=!0,R.value=i.data,G.value=i.percent;const d=E.value?.clientWidth||0,v=E.value?.clientHeight||0,e=Math.min(l+12,d-140),c=Math.min(n+12,v-60);J.value=Math.max(0,e),K.value=Math.max(0,c)}else z.value=!1,R.value=null},ht=()=>{$.value!==-1&&($.value=-1,b.forEach(t=>t.hover=!1),tt()),z.value=!1,R.value=null},nt=t=>{if(!C.value)return;const{mx:l,my:n}=ot(t),s=et(l,n);s>=0&<("slice-click",b[s].data,s)};return h.watch(()=>S.data,()=>{Object.assign(a,V,S.config),q=S.animation,W()},{deep:!0}),h.watch(()=>S.config,()=>{Object.assign(a,V,S.config),W()},{deep:!0}),h.onMounted(()=>{W(),window.addEventListener("resize",W),C.value?.addEventListener("click",nt)}),h.onUnmounted(()=>{window.removeEventListener("resize",W),C.value?.removeEventListener("click",nt),F&&cancelAnimationFrame(F),I&&cancelAnimationFrame(I)}),(t,l)=>(h.openBlock(),h.createElementBlock("div",{class:"g-pie3d-container",ref_key:"containerRef",ref:E},[h.createElementVNode("canvas",{ref_key:"canvasRef",ref:C,onMousemove:ct,onMouseleave:ht},null,544),z.value?(h.openBlock(),h.createElementBlock("div",{key:0,class:"g-pie3d-tooltip",style:h.normalizeStyle({left:`${J.value}px`,top:`${K.value}px`})},[h.renderSlot(t.$slots,"tooltip",{data:R.value,percent:G.value},()=>[h.createElementVNode("div",vt,[h.createElementVNode("p",gt,h.toDisplayString(R.value?.name),1),h.createElementVNode("p",yt,h.toDisplayString(R.value?.value)+" ("+h.toDisplayString((G.value*100).toFixed(1))+"%) ",1)])],!0)],4)):h.createCommentVNode("",!0)],512))}}),B=pt._export_sfc(xt,[["__scopeId","data-v-79c4179b"]]);B.install=N=>{N.component(B.name,B)};exports.GPie3D=B;exports.default=B;
|