g-ui-core 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/cjs/app-globals-V2Kpy_OQ.js +5 -0
  2. package/dist/cjs/g-button.cjs.entry.js +8 -0
  3. package/dist/cjs/g-ui.cjs.js +25 -0
  4. package/dist/cjs/index-DOlVX1hU.js +1580 -0
  5. package/dist/cjs/index.cjs.js +94 -0
  6. package/dist/cjs/loader.cjs.js +13 -0
  7. package/dist/collection/collection-manifest.json +13 -0
  8. package/dist/collection/components/my-button/my-button.css +300 -0
  9. package/dist/collection/components/my-button/my-button.js +522 -0
  10. package/dist/collection/index.js +1 -0
  11. package/dist/components/g-button.d.ts +11 -0
  12. package/dist/components/g-button.js +1 -0
  13. package/dist/components/index.d.ts +35 -0
  14. package/dist/components/index.js +1 -0
  15. package/dist/esm/app-globals-DQuL1Twl.js +3 -0
  16. package/dist/esm/g-button.entry.js +2 -0
  17. package/dist/esm/g-ui.js +21 -0
  18. package/dist/esm/index-BVAZCj8P.js +1574 -0
  19. package/dist/esm/index.js +92 -0
  20. package/dist/esm/loader.js +11 -0
  21. package/dist/g-ui/g-ui.esm.js +1 -0
  22. package/dist/g-ui/index.esm.js +1 -0
  23. package/dist/g-ui/p-BVAZCj8P.js +2 -0
  24. package/dist/g-ui/p-DQuL1Twl.js +1 -0
  25. package/dist/g-ui/p-a0f43132.entry.js +1 -0
  26. package/dist/index.cjs.js +1 -0
  27. package/dist/index.js +1 -0
  28. package/dist/types/components/my-button/my-button.d.ts +32 -0
  29. package/dist/types/components.d.ts +205 -0
  30. package/dist/types/index.d.ts +2 -0
  31. package/dist/types/stencil-public-runtime.d.ts +1861 -0
  32. package/loader/cdn.js +1 -0
  33. package/loader/index.cjs.js +1 -0
  34. package/loader/index.d.ts +24 -0
  35. package/loader/index.es2017.js +1 -0
  36. package/loader/index.js +2 -0
  37. package/package.json +38 -0
@@ -0,0 +1,94 @@
1
+ 'use strict';
2
+
3
+ var index = require('./index-DOlVX1hU.js');
4
+
5
+ const myButtonCss = () => `:host{display:inline-block}:host(:not(:first-child)){margin-left:12px}:host{--g-btn-color:#4f46e5;--g-btn-color-hover:#4338ca;--g-btn-color-active:#3730a3;--g-btn-text-color:#fff;--g-btn-plain-bg:#eef2ff}.btn{display:inline-flex;align-items:center;justify-content:center;gap:0.25em;border:1px solid var(--g-btn-color);border-radius:6px;font-family:inherit;font-weight:600;line-height:1;cursor:pointer;user-select:none;transition:all 0.2s ease;background-color:var(--g-btn-color);color:var(--g-btn-text-color);vertical-align:middle;text-decoration:none;white-space:nowrap}.btn:hover{background-color:var(--g-btn-color-hover);border-color:var(--g-btn-color-hover)}.btn:active{background-color:var(--g-btn-color-active);border-color:var(--g-btn-color-active)}.btn:disabled,.btn--disabled{opacity:0.5;cursor:not-allowed;pointer-events:none}.btn--sm{padding:0.375rem 0.75rem;font-size:0.875rem}.btn--md{padding:0.5rem 1rem;font-size:1rem}.btn--lg{padding:0.75rem 1.5rem;font-size:1.125rem}.btn--primary{--g-btn-color:#4f46e5;--g-btn-color-hover:#4338ca;--g-btn-color-active:#3730a3;--g-btn-plain-bg:#eef2ff}.btn--success{--g-btn-color:#10b981;--g-btn-color-hover:#059669;--g-btn-color-active:#047857;--g-btn-plain-bg:#d1fae5}.btn--warning{--g-btn-color:#f59e0b;--g-btn-color-hover:#d97706;--g-btn-color-active:#b45309;--g-btn-plain-bg:#fef3c7}.btn--danger{--g-btn-color:#ef4444;--g-btn-color-hover:#dc2626;--g-btn-color-active:#b91c1c;--g-btn-plain-bg:#fee2e2}.btn--info,.btn--secondary{--g-btn-color:#6b7280;--g-btn-color-hover:#4b5563;--g-btn-color-active:#374151;--g-btn-plain-bg:#f3f4f6}.btn--plain{background-color:transparent;color:var(--g-btn-color)}.btn--plain:hover{background-color:var(--g-btn-plain-bg);color:var(--g-btn-color-hover);border-color:var(--g-btn-color-hover)}.btn--plain:active{background-color:var(--g-btn-plain-bg);color:var(--g-btn-color-active);border-color:var(--g-btn-color-active)}.btn--text{border-color:transparent;background-color:transparent;color:var(--g-btn-color)}.btn--text:hover{background-color:transparent;color:var(--g-btn-color-hover);border-color:transparent}.btn--text:active{color:var(--g-btn-color-active)}.btn--text.btn--bg:hover{background-color:var(--g-btn-plain-bg)}.btn--link{border-color:transparent;background-color:transparent;color:var(--g-btn-color);padding:0;font-weight:400}.btn--link:hover{background-color:transparent;color:var(--g-btn-color-hover);border-color:transparent;text-decoration:underline}.btn--link:active{color:var(--g-btn-color-active)}.btn--round{border-radius:9999px}.btn--circle{border-radius:50%;padding:0.5rem;width:2.5rem;height:2.5rem}.btn--circle.btn--sm{width:2rem;height:2rem;padding:0.375rem}.btn--circle.btn--lg{width:3rem;height:3rem;padding:0.75rem}.btn--dashed{border-style:dashed;background-color:color-mix(in srgb, var(--g-btn-color) 10%, transparent)}.btn--dashed:hover{background-color:color-mix(in srgb, var(--g-btn-color) 20%, transparent)}.btn--loading{cursor:wait;opacity:0.8}.btn__loading-icon{display:inline-flex;animation:g-spin 1s linear infinite}@keyframes g-spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}.btn__icon{display:inline-flex;font-size:1.1em}.btn__label{display:inline-flex;align-items:center}.btn--dark{--g-btn-color:#818cf8;--g-btn-color-hover:#6366f1;--g-btn-color-active:#4f46e5;--g-btn-plain-bg:#1e1b4b;--g-btn-text-color:#0f0f0f}.btn--dark.btn--plain{background-color:transparent;color:var(--g-btn-color);border-color:var(--g-btn-color)}.btn--dark.btn--text,.btn--dark.btn--link{color:var(--g-btn-color)}:host([style*='--g-btn-color']) .btn{background-color:var(--g-btn-color);border-color:var(--g-btn-color);color:var(--g-btn-text-color, #fff)}:host([style*='--g-btn-color']) .btn.btn--plain{background-color:transparent;color:var(--g-btn-color)}:host([style*='--g-btn-color']) .btn.btn--text,:host([style*='--g-btn-color']) .btn.btn--link{background-color:transparent;border-color:transparent;color:var(--g-btn-color)}`;
6
+
7
+ const MyButton = class {
8
+ constructor(hostRef) {
9
+ index.registerInstance(this, hostRef);
10
+ this.type = 'primary';
11
+ this.size = 'md';
12
+ this.plain = false;
13
+ this.text = false;
14
+ this.bg = false;
15
+ this.link = false;
16
+ this.round = false;
17
+ this.circle = false;
18
+ this.dashed = false;
19
+ this.loading = false;
20
+ this.loadingIcon = '●';
21
+ this.disabled = false;
22
+ this.autofocus = false;
23
+ this.nativeType = 'button';
24
+ this.autoInsertSpace = false;
25
+ this.dark = false;
26
+ this.tag = 'button';
27
+ this.shouldAddSpace = false;
28
+ this.handleClick = (e) => {
29
+ if (this.loading || this.disabled) {
30
+ e.preventDefault();
31
+ e.stopPropagation();
32
+ }
33
+ };
34
+ }
35
+ checkAutoSpace() {
36
+ if (!this.autoInsertSpace || !this.label) {
37
+ this.shouldAddSpace = false;
38
+ return;
39
+ }
40
+ this.shouldAddSpace =
41
+ this.label.length === 2 &&
42
+ /^[\u4e00-\u9fa5]+$/.test(this.label);
43
+ }
44
+ componentWillLoad() {
45
+ this.checkAutoSpace();
46
+ }
47
+ get computedClass() {
48
+ const { type, size, plain, text, bg, link, round, circle, dashed, loading, disabled, dark } = this;
49
+ const classes = ['btn', `btn--${type}`, `btn--${size}`];
50
+ if (plain)
51
+ classes.push('btn--plain');
52
+ if (text)
53
+ classes.push('btn--text');
54
+ if (bg)
55
+ classes.push('btn--bg');
56
+ if (link)
57
+ classes.push('btn--link');
58
+ if (round)
59
+ classes.push('btn--round');
60
+ if (circle)
61
+ classes.push('btn--circle');
62
+ if (dashed)
63
+ classes.push('btn--dashed');
64
+ if (loading)
65
+ classes.push('btn--loading');
66
+ if (disabled)
67
+ classes.push('btn--disabled');
68
+ if (dark)
69
+ classes.push('btn--dark');
70
+ return classes.join(' ');
71
+ }
72
+ get customStyle() {
73
+ if (!this.color)
74
+ return {};
75
+ return { '--g-btn-color': this.color };
76
+ }
77
+ render() {
78
+ const { loading, disabled, autofocus, nativeType, icon, label, tag: Tag, loadingIcon, shouldAddSpace, } = this;
79
+ const displayLabel = shouldAddSpace ? label.split('').join('\u2009') : label;
80
+ const content = (index.h(index.h.Fragment, null, loading && index.h("span", { key: '46a08c10ad7cadc4952dcb771c4dd1a244f7f156', class: "btn__loading-icon" }, loadingIcon), !loading && icon && index.h("span", { key: 'afc8df2cb5f8a21d6bdbe19cea1d809f388b64b1', class: "btn__icon" }, icon), displayLabel && index.h("span", { key: '8d52ddc448732cfbd94aaef3953a6c491ea8f173', class: "btn__label" }, displayLabel), index.h("slot", { key: 'c7e6e16593967cb08580c6c7fd7aa3728d6f921b' })));
81
+ return (index.h(Tag, { key: '734ed9490a23e332e0628809df532aed1035e2c5', class: this.computedClass, disabled: Tag === 'button' ? (disabled || loading) : undefined, type: Tag === 'button' ? nativeType : undefined, autofocus: Tag === 'button' ? autofocus : undefined, style: this.customStyle, onClick: this.handleClick }, content));
82
+ }
83
+ static get watchers() { return {
84
+ "label": [{
85
+ "checkAutoSpace": 0
86
+ }],
87
+ "autoInsertSpace": [{
88
+ "checkAutoSpace": 0
89
+ }]
90
+ }; }
91
+ };
92
+ MyButton.style = myButtonCss();
93
+
94
+ exports.MyButton = MyButton;
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ var index = require('./index-DOlVX1hU.js');
4
+ var appGlobals = require('./app-globals-V2Kpy_OQ.js');
5
+
6
+ const defineCustomElements = async (win, options) => {
7
+ if (typeof window === 'undefined') return undefined;
8
+ await appGlobals.globalScripts();
9
+ return index.bootstrapLazy([["g-button.cjs",[[257,"g-button",{"type":[1],"size":[1],"plain":[4],"text":[4],"bg":[4],"link":[4],"round":[4],"circle":[4],"dashed":[4],"loading":[4],"loadingIcon":[1,"loading-icon"],"disabled":[4],"icon":[1],"autofocus":[4],"nativeType":[1,"native-type"],"autoInsertSpace":[4,"auto-insert-space"],"color":[1],"dark":[4],"tag":[1],"label":[1],"shouldAddSpace":[32]},null,{"label":[{"checkAutoSpace":0}],"autoInsertSpace":[{"checkAutoSpace":0}]}]]]], options);
10
+ };
11
+
12
+ exports.setNonce = index.setNonce;
13
+ exports.defineCustomElements = defineCustomElements;
@@ -0,0 +1,13 @@
1
+ {
2
+ "entries": [
3
+ "components/my-button/my-button.js"
4
+ ],
5
+ "mixins": [],
6
+ "compiler": {
7
+ "name": "@stencil/core",
8
+ "version": "4.43.5",
9
+ "typescriptVersion": "5.8.3"
10
+ },
11
+ "collections": [],
12
+ "bundles": []
13
+ }
@@ -0,0 +1,300 @@
1
+ /* ========================================
2
+ G-UI Button — 参照 Element Plus API
3
+ ======================================== */
4
+
5
+ :host {
6
+ display: inline-block;
7
+ }
8
+
9
+ /* 相邻按钮间距(第一个除外) */
10
+ :host(:not(:first-child)) {
11
+ margin-left: 12px;
12
+ }
13
+
14
+ /* ---------- color tokens ---------- */
15
+ :host {
16
+ --g-btn-color: #4f46e5;
17
+ --g-btn-color-hover: #4338ca;
18
+ --g-btn-color-active: #3730a3;
19
+ --g-btn-text-color: #fff;
20
+ --g-btn-plain-bg: #eef2ff;
21
+ }
22
+
23
+ /* ---------- base ---------- */
24
+ .btn {
25
+ display: inline-flex;
26
+ align-items: center;
27
+ justify-content: center;
28
+ gap: 0.25em;
29
+ border: 1px solid var(--g-btn-color);
30
+ border-radius: 6px;
31
+ font-family: inherit;
32
+ font-weight: 600;
33
+ line-height: 1;
34
+ cursor: pointer;
35
+ user-select: none;
36
+ transition: all 0.2s ease;
37
+ background-color: var(--g-btn-color);
38
+ color: var(--g-btn-text-color);
39
+ vertical-align: middle;
40
+ text-decoration: none;
41
+ white-space: nowrap;
42
+ }
43
+
44
+ .btn:hover {
45
+ background-color: var(--g-btn-color-hover);
46
+ border-color: var(--g-btn-color-hover);
47
+ }
48
+
49
+ .btn:active {
50
+ background-color: var(--g-btn-color-active);
51
+ border-color: var(--g-btn-color-active);
52
+ }
53
+
54
+ .btn:disabled,
55
+ .btn--disabled {
56
+ opacity: 0.5;
57
+ cursor: not-allowed;
58
+ pointer-events: none;
59
+ }
60
+
61
+ /* ---------- sizes ---------- */
62
+ .btn--sm {
63
+ padding: 0.375rem 0.75rem;
64
+ font-size: 0.875rem;
65
+ }
66
+
67
+ .btn--md {
68
+ padding: 0.5rem 1rem;
69
+ font-size: 1rem;
70
+ }
71
+
72
+ .btn--lg {
73
+ padding: 0.75rem 1.5rem;
74
+ font-size: 1.125rem;
75
+ }
76
+
77
+ /* ========================================
78
+ Type variants — color scheme
79
+ ======================================== */
80
+
81
+ .btn--primary {
82
+ --g-btn-color: #4f46e5;
83
+ --g-btn-color-hover: #4338ca;
84
+ --g-btn-color-active: #3730a3;
85
+ --g-btn-plain-bg: #eef2ff;
86
+ }
87
+
88
+ .btn--success {
89
+ --g-btn-color: #10b981;
90
+ --g-btn-color-hover: #059669;
91
+ --g-btn-color-active: #047857;
92
+ --g-btn-plain-bg: #d1fae5;
93
+ }
94
+
95
+ .btn--warning {
96
+ --g-btn-color: #f59e0b;
97
+ --g-btn-color-hover: #d97706;
98
+ --g-btn-color-active: #b45309;
99
+ --g-btn-plain-bg: #fef3c7;
100
+ }
101
+
102
+ .btn--danger {
103
+ --g-btn-color: #ef4444;
104
+ --g-btn-color-hover: #dc2626;
105
+ --g-btn-color-active: #b91c1c;
106
+ --g-btn-plain-bg: #fee2e2;
107
+ }
108
+
109
+ .btn--info,
110
+ .btn--secondary {
111
+ --g-btn-color: #6b7280;
112
+ --g-btn-color-hover: #4b5563;
113
+ --g-btn-color-active: #374151;
114
+ --g-btn-plain-bg: #f3f4f6;
115
+ }
116
+
117
+ /* ========================================
118
+ Plain — 朴素按钮
119
+ ======================================== */
120
+ .btn--plain {
121
+ background-color: transparent;
122
+ color: var(--g-btn-color);
123
+ }
124
+
125
+ .btn--plain:hover {
126
+ background-color: var(--g-btn-plain-bg);
127
+ color: var(--g-btn-color-hover);
128
+ border-color: var(--g-btn-color-hover);
129
+ }
130
+
131
+ .btn--plain:active {
132
+ background-color: var(--g-btn-plain-bg);
133
+ color: var(--g-btn-color-active);
134
+ border-color: var(--g-btn-color-active);
135
+ }
136
+
137
+ /* ========================================
138
+ Text — 文字按钮
139
+ ======================================== */
140
+ .btn--text {
141
+ border-color: transparent;
142
+ background-color: transparent;
143
+ color: var(--g-btn-color);
144
+ }
145
+
146
+ .btn--text:hover {
147
+ background-color: transparent;
148
+ color: var(--g-btn-color-hover);
149
+ border-color: transparent;
150
+ }
151
+
152
+ .btn--text:active {
153
+ color: var(--g-btn-color-active);
154
+ }
155
+
156
+ /* Text + bg — hover 时显示背景 */
157
+ .btn--text.btn--bg:hover {
158
+ background-color: var(--g-btn-plain-bg);
159
+ }
160
+
161
+ /* ========================================
162
+ Link — 链接按钮
163
+ ======================================== */
164
+ .btn--link {
165
+ border-color: transparent;
166
+ background-color: transparent;
167
+ color: var(--g-btn-color);
168
+ padding: 0;
169
+ font-weight: 400;
170
+ }
171
+
172
+ .btn--link:hover {
173
+ background-color: transparent;
174
+ color: var(--g-btn-color-hover);
175
+ border-color: transparent;
176
+ text-decoration: underline;
177
+ }
178
+
179
+ .btn--link:active {
180
+ color: var(--g-btn-color-active);
181
+ }
182
+
183
+ /* ========================================
184
+ Round / Circle — 形状修饰
185
+ ======================================== */
186
+ .btn--round {
187
+ border-radius: 9999px;
188
+ }
189
+
190
+ .btn--circle {
191
+ border-radius: 50%;
192
+ padding: 0.5rem;
193
+ width: 2.5rem;
194
+ height: 2.5rem;
195
+ }
196
+
197
+ .btn--circle.btn--sm {
198
+ width: 2rem;
199
+ height: 2rem;
200
+ padding: 0.375rem;
201
+ }
202
+
203
+ .btn--circle.btn--lg {
204
+ width: 3rem;
205
+ height: 3rem;
206
+ padding: 0.75rem;
207
+ }
208
+
209
+ /* ========================================
210
+ Dashed — 虚线边框 + 淡色背景
211
+ ======================================== */
212
+ .btn--dashed {
213
+ border-style: dashed;
214
+ background-color: color-mix(in srgb, var(--g-btn-color) 10%, transparent);
215
+ }
216
+
217
+ .btn--dashed:hover {
218
+ background-color: color-mix(in srgb, var(--g-btn-color) 20%, transparent);
219
+ }
220
+
221
+ /* ========================================
222
+ Loading — 加载中
223
+ ======================================== */
224
+ .btn--loading {
225
+ cursor: wait;
226
+ opacity: 0.8;
227
+ }
228
+
229
+ .btn__loading-icon {
230
+ display: inline-flex;
231
+ animation: g-spin 1s linear infinite;
232
+ }
233
+
234
+ @keyframes g-spin {
235
+ from {
236
+ transform: rotate(0deg);
237
+ }
238
+ to {
239
+ transform: rotate(360deg);
240
+ }
241
+ }
242
+
243
+ /* ========================================
244
+ Icon
245
+ ======================================== */
246
+ .btn__icon {
247
+ display: inline-flex;
248
+ font-size: 1.1em;
249
+ }
250
+
251
+ /* ========================================
252
+ Label
253
+ ======================================== */
254
+ .btn__label {
255
+ display: inline-flex;
256
+ align-items: center;
257
+ }
258
+
259
+ /* ========================================
260
+ Dark mode
261
+ ======================================== */
262
+ .btn--dark {
263
+ --g-btn-color: #818cf8;
264
+ --g-btn-color-hover: #6366f1;
265
+ --g-btn-color-active: #4f46e5;
266
+ --g-btn-plain-bg: #1e1b4b;
267
+ --g-btn-text-color: #0f0f0f;
268
+ }
269
+
270
+ .btn--dark.btn--plain {
271
+ background-color: transparent;
272
+ color: var(--g-btn-color);
273
+ border-color: var(--g-btn-color);
274
+ }
275
+
276
+ .btn--dark.btn--text,
277
+ .btn--dark.btn--link {
278
+ color: var(--g-btn-color);
279
+ }
280
+
281
+ /* ========================================
282
+ Custom color via CSS variable
283
+ ======================================== */
284
+ :host([style*='--g-btn-color']) .btn {
285
+ background-color: var(--g-btn-color);
286
+ border-color: var(--g-btn-color);
287
+ color: var(--g-btn-text-color, #fff);
288
+ }
289
+
290
+ :host([style*='--g-btn-color']) .btn.btn--plain {
291
+ background-color: transparent;
292
+ color: var(--g-btn-color);
293
+ }
294
+
295
+ :host([style*='--g-btn-color']) .btn.btn--text,
296
+ :host([style*='--g-btn-color']) .btn.btn--link {
297
+ background-color: transparent;
298
+ border-color: transparent;
299
+ color: var(--g-btn-color);
300
+ }