@gzmjs/ui-basic 0.1.0 → 0.2.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.
@@ -1011,6 +1011,105 @@ window.addEventListener("storage", (event) => {
1011
1011
  document.documentElement.setAttribute(htmlThemeAttr, event.newValue);
1012
1012
  }
1013
1013
  });
1014
+ var __create$3 = Object.create;
1015
+ var __defProp$3 = Object.defineProperty;
1016
+ var __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor;
1017
+ var __knownSymbol$3 = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
1018
+ var __typeError$3 = (msg) => {
1019
+ throw TypeError(msg);
1020
+ };
1021
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1022
+ var __name$3 = (target, value) => __defProp$3(target, "name", { value, configurable: true });
1023
+ var __decoratorStart$3 = (base) => [, , , __create$3(base?.[__knownSymbol$3("metadata")] ?? null)];
1024
+ var __decoratorStrings$3 = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
1025
+ var __expectFn$3 = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError$3("Function expected") : fn;
1026
+ var __decoratorContext$3 = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings$3[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError$3("Already initialized") : fns.push(__expectFn$3(fn || null)) });
1027
+ var __decoratorMetadata$3 = (array, target) => __defNormalProp$3(target, __knownSymbol$3("metadata"), array[3]);
1028
+ var __runInitializers$3 = (array, flags, self, value) => {
1029
+ for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);
1030
+ return value;
1031
+ };
1032
+ var __decorateElement$3 = (array, flags, name, decorators, target, extra) => {
1033
+ var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);
1034
+ var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings$3[k + 5];
1035
+ var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);
1036
+ var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc$3(k < 4 ? target : { get [name]() {
1037
+ return __privateGet$3(this, extra);
1038
+ }, set [name](x) {
1039
+ return __privateSet$3(this, extra, x);
1040
+ } }, name));
1041
+ k ? p && k < 4 && __name$3(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name$3(target, name);
1042
+ for (var i = decorators.length - 1; i >= 0; i--) {
1043
+ ctx = __decoratorContext$3(k, name, done = {}, array[3], extraInitializers);
1044
+ if (k) {
1045
+ ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn$3(target, x) : (x) => name in x };
1046
+ if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet$3 : __privateMethod$3)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];
1047
+ if (k > 2) access.set = p ? (x, y) => __privateSet$3(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;
1048
+ }
1049
+ it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;
1050
+ if (k ^ 4 || it === void 0) __expectFn$3(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);
1051
+ else if (typeof it !== "object" || it === null) __typeError$3("Object expected");
1052
+ else __expectFn$3(fn = it.get) && (desc.get = fn), __expectFn$3(fn = it.set) && (desc.set = fn), __expectFn$3(fn = it.init) && initializers.unshift(fn);
1053
+ }
1054
+ return k || __decoratorMetadata$3(array, target), desc && __defProp$3(target, name, desc), p ? k ^ 4 ? extra : desc : target;
1055
+ };
1056
+ var __accessCheck$3 = (obj, member, msg) => member.has(obj) || __typeError$3("Cannot " + msg);
1057
+ var __privateIn$3 = (member, obj) => Object(obj) !== obj ? __typeError$3('Cannot use the "in" operator on this value') : member.has(obj);
1058
+ var __privateGet$3 = (obj, member, getter) => (__accessCheck$3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
1059
+ var __privateAdd$3 = (obj, member, value) => member.has(obj) ? __typeError$3("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1060
+ var __privateSet$3 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
1061
+ var __privateMethod$3 = (obj, member, method) => (__accessCheck$3(obj, member, "access private method"), method);
1062
+ var _corner_dec$1, _badge_dec, _a$3, _Badge_decorators, _init$3, _badge, _corner$1;
1063
+ const tagName$3 = "GZM-BADGE";
1064
+ const styleSheet$2 = createStyleSheet({
1065
+ ":host": `
1066
+ height: 1rem;
1067
+ border-radius: 50%;
1068
+ padding: 0 0.25rem !important;
1069
+
1070
+ color: var(--gzm-badge-txt-color);
1071
+ background: var(--gzm-badge-background);
1072
+
1073
+ line-height: 1rem;
1074
+
1075
+ font-family: PingFang SC, Microsoft YaHei, Hiragino Sans GB, Heiti SC, sans-serif;
1076
+ font-size: 0.75rem;
1077
+ font-weight: bolder;
1078
+ `
1079
+ });
1080
+ const cornerStyleSheet$1 = createStyleSheet({
1081
+ ":host": `
1082
+ transform: translate(33%, -33%);
1083
+ position: absolute;
1084
+ top: 0px;
1085
+ right: 0px;
1086
+ z-index: 1;
1087
+ `
1088
+ });
1089
+ const mutableAttributes$3 = ["badge", "corner"];
1090
+ _Badge_decorators = [defineElement({ tagName: tagName$3, mutableAttributes: mutableAttributes$3 })];
1091
+ class Badge extends (_a$3 = HTMLElement, _badge_dec = [strAttr], _corner_dec$1 = [boolAttr], _a$3) {
1092
+ constructor() {
1093
+ super();
1094
+ __privateAdd$3(this, _badge, __runInitializers$3(_init$3, 8, this)), __runInitializers$3(_init$3, 11, this);
1095
+ __privateAdd$3(this, _corner$1, __runInitializers$3(_init$3, 12, this)), __runInitializers$3(_init$3, 15, this);
1096
+ const sr = this.attachShadow({ mode: "open" });
1097
+ sr.adoptedStyleSheets = [baseStyle, styleSheet$2];
1098
+ }
1099
+ _badge_set(badge) {
1100
+ this.shadowRoot.innerHTML = badge ?? "";
1101
+ }
1102
+ _corner_set() {
1103
+ this.shadowRoot.adoptedStyleSheets = this.corner ? [baseStyle, styleSheet$2, cornerStyleSheet$1] : [baseStyle, styleSheet$2];
1104
+ }
1105
+ }
1106
+ _init$3 = __decoratorStart$3(_a$3);
1107
+ _badge = /* @__PURE__ */ new WeakMap();
1108
+ _corner$1 = /* @__PURE__ */ new WeakMap();
1109
+ __decorateElement$3(_init$3, 4, "badge", _badge_dec, Badge, _badge);
1110
+ __decorateElement$3(_init$3, 4, "corner", _corner_dec$1, Badge, _corner$1);
1111
+ Badge = __decorateElement$3(_init$3, 0, "Badge", _Badge_decorators, Badge);
1112
+ __runInitializers$3(_init$3, 1, Badge);
1014
1113
  var __create$2 = Object.create;
1015
1114
  var __defProp$2 = Object.defineProperty;
1016
1115
  var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
@@ -1059,57 +1158,56 @@ var __privateGet$2 = (obj, member, getter) => (__accessCheck$2(obj, member, "rea
1059
1158
  var __privateAdd$2 = (obj, member, value) => member.has(obj) ? __typeError$2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1060
1159
  var __privateSet$2 = (obj, member, value, setter) => (__accessCheck$2(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
1061
1160
  var __privateMethod$2 = (obj, member, method) => (__accessCheck$2(obj, member, "access private method"), method);
1062
- var _corner_dec$1, _badge_dec, _a$2, _Badge_decorators, _init$2, _badge, _corner$1;
1063
- const tagName$2 = "GZM-BADGE";
1161
+ var _corner_dec, _a$2, _CloseBtn_decorators, _init$2, _corner;
1162
+ const tagName$2 = "GZM-CLOSE-BTN";
1064
1163
  const styleSheet$1 = createStyleSheet({
1065
1164
  ":host": `
1066
- height: 1rem;
1067
- border-radius: 50%;
1068
- padding: 0 0.25rem !important;
1069
-
1070
- color: var(--gzm-badge-txt-color);
1071
- background: var(--gzm-badge-background);
1072
-
1073
- line-height: 1rem;
1074
-
1075
- font-family: PingFang SC, Microsoft YaHei, Hiragino Sans GB, Heiti SC, sans-serif;
1165
+ font-family: ui-sans-serif, system-ui, sans-serif;
1076
1166
  font-size: 0.75rem;
1077
- font-weight: bolder;
1078
- `
1167
+ font-weight: bold;
1168
+ line-height: 1rem;
1169
+ display: inline-block;
1170
+ `,
1171
+ div: `
1172
+ border-radius: 9999px;
1173
+ padding-inline: 0.25rem;
1174
+ padding-block: 0px;
1175
+ `,
1176
+ [`div:hover`]: {
1177
+ color: "var(--gzm-badge-txt-color)",
1178
+ background: "var(--gzm-badge-background)",
1179
+ cursor: "pointer"
1180
+ }
1079
1181
  });
1080
- const cornerStyleSheet$1 = createStyleSheet({
1182
+ const cornerStyleSheet = createStyleSheet({
1081
1183
  ":host": `
1082
- transform: translate(33%, -33%);
1083
1184
  position: absolute;
1084
- top: 0px;
1085
1185
  right: 0px;
1086
- z-index: 1;
1186
+ top: 0px;
1087
1187
  `
1088
1188
  });
1089
- const mutableAttributes$2 = ["badge", "corner"];
1090
- _Badge_decorators = [defineElement({ tagName: tagName$2, mutableAttributes: mutableAttributes$2 })];
1091
- class Badge extends (_a$2 = HTMLElement, _badge_dec = [strAttr], _corner_dec$1 = [boolAttr], _a$2) {
1189
+ const mutableAttributes$2 = ["corner"];
1190
+ _CloseBtn_decorators = [defineElement({ tagName: tagName$2, mutableAttributes: mutableAttributes$2 })];
1191
+ class CloseBtn extends (_a$2 = HTMLElement, _corner_dec = [boolAttr], _a$2) {
1092
1192
  constructor() {
1093
1193
  super();
1094
- __privateAdd$2(this, _badge, __runInitializers$2(_init$2, 8, this)), __runInitializers$2(_init$2, 11, this);
1095
- __privateAdd$2(this, _corner$1, __runInitializers$2(_init$2, 12, this)), __runInitializers$2(_init$2, 15, this);
1096
- const sr = this.attachShadow({ mode: "open" });
1097
- sr.adoptedStyleSheets = [baseStyle, styleSheet$1];
1098
- }
1099
- _badge_set(badge) {
1100
- this.shadowRoot.innerHTML = badge ?? "";
1194
+ __privateAdd$2(this, _corner, __runInitializers$2(_init$2, 8, this)), __runInitializers$2(_init$2, 11, this);
1195
+ const root = this.attachShadow({ mode: "open" });
1196
+ root.adoptedStyleSheets = [baseStyle, styleSheet$1];
1197
+ root.innerHTML = "<div>╳</div>";
1101
1198
  }
1199
+ // #region 属性
1102
1200
  _corner_set() {
1103
- this.shadowRoot.adoptedStyleSheets = this.corner ? [baseStyle, styleSheet$1, cornerStyleSheet$1] : [baseStyle, styleSheet$1];
1201
+ this.shadowRoot.adoptedStyleSheets = this.corner ? [baseStyle, styleSheet$1, cornerStyleSheet] : [baseStyle, styleSheet$1];
1104
1202
  }
1203
+ // #endregion
1105
1204
  }
1106
1205
  _init$2 = __decoratorStart$2(_a$2);
1107
- _badge = /* @__PURE__ */ new WeakMap();
1108
- _corner$1 = /* @__PURE__ */ new WeakMap();
1109
- __decorateElement$2(_init$2, 4, "badge", _badge_dec, Badge, _badge);
1110
- __decorateElement$2(_init$2, 4, "corner", _corner_dec$1, Badge, _corner$1);
1111
- Badge = __decorateElement$2(_init$2, 0, "Badge", _Badge_decorators, Badge);
1112
- __runInitializers$2(_init$2, 1, Badge);
1206
+ _corner = /* @__PURE__ */ new WeakMap();
1207
+ __decorateElement$2(_init$2, 4, "corner", _corner_dec, CloseBtn, _corner);
1208
+ CloseBtn = __decorateElement$2(_init$2, 0, "CloseBtn", _CloseBtn_decorators, CloseBtn);
1209
+ __runInitializers$2(_init$2, 1, CloseBtn);
1210
+ const iconCache = {};
1113
1211
  var __create$1 = Object.create;
1114
1212
  var __defProp$1 = Object.defineProperty;
1115
1213
  var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
@@ -1158,56 +1256,80 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
1158
1256
  var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1159
1257
  var __privateSet$1 = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
1160
1258
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
1161
- var _corner_dec, _a$1, _CloseBtn_decorators, _init$1, _corner;
1162
- const tagName$1 = "GZM-CLOSE-BTN";
1163
- const styleSheet = createStyleSheet({
1259
+ var _icon_dec, _a$1, _Icon_decorators, _Icon_instances, showStr_fn, showCache_fn, showUnicode_fn, _init$1, _icon;
1260
+ const style = createStyleSheet({
1261
+ //防止网页中没有定义这些字体。如'⚙'在没有 Emoji 字体加持的情况下,显示非常难看。
1262
+ //默认不要 inline-block,选中一行包含 icon 的文字时,可以看出明显区别。
1164
1263
  ":host": `
1165
- font-family: ui-sans-serif, system-ui, sans-serif;
1166
- font-size: 0.75rem;
1167
- font-weight: bold;
1168
- line-height: 1rem;
1169
- display: inline-block;
1170
- `,
1171
- div: `
1172
- border-radius: 9999px;
1173
- padding-inline: 0.25rem;
1174
- padding-block: 0px;
1264
+ /*display: inline-block;*/
1265
+ font-family: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
1175
1266
  `,
1176
- [`div:hover`]: {
1177
- color: "var(--gzm-badge-txt-color)",
1178
- background: "var(--gzm-badge-background)",
1179
- cursor: "pointer"
1180
- }
1181
- });
1182
- const cornerStyleSheet = createStyleSheet({
1183
- ":host": `
1184
- position: absolute;
1185
- right: 0px;
1186
- top: 0px;
1267
+ //height - 相对于父元素的字体高度,这是关键!
1268
+ "img, svg": `
1269
+ width: 1em;
1270
+ height: 1em;
1271
+ vertical-align: middle;
1272
+ color: inherit;
1187
1273
  `
1188
1274
  });
1189
- const mutableAttributes$1 = ["corner"];
1190
- _CloseBtn_decorators = [defineElement({ tagName: tagName$1, mutableAttributes: mutableAttributes$1 })];
1191
- class CloseBtn extends (_a$1 = HTMLElement, _corner_dec = [boolAttr], _a$1) {
1275
+ const tagName$1 = "GZM-ICON";
1276
+ const mutableAttributes$1 = ["icon"];
1277
+ _Icon_decorators = [defineElement({ tagName: tagName$1, mutableAttributes: mutableAttributes$1 })];
1278
+ class Icon extends (_a$1 = HTMLElement, _icon_dec = [strAttr], _a$1) {
1192
1279
  constructor() {
1193
1280
  super();
1194
- __privateAdd$1(this, _corner, __runInitializers$1(_init$1, 8, this)), __runInitializers$1(_init$1, 11, this);
1195
- const root = this.attachShadow({ mode: "open" });
1196
- root.adoptedStyleSheets = [baseStyle, styleSheet];
1197
- root.innerHTML = "<div>╳</div>";
1281
+ __privateAdd$1(this, _Icon_instances);
1282
+ __privateAdd$1(this, _icon, __runInitializers$1(_init$1, 8, this)), __runInitializers$1(_init$1, 11, this);
1283
+ const sr = this.attachShadow({ mode: "open" });
1284
+ sr.adoptedStyleSheets = [baseStyle, style];
1285
+ }
1286
+ setImg(icon) {
1287
+ if (icon.startsWith("data:image/") || icon.includes(".") && icon.includes("/")) {
1288
+ this.shadowRoot.innerHTML = `<img src="${icon}" alt="icon">`;
1289
+ return true;
1290
+ }
1291
+ return false;
1292
+ }
1293
+ setSvg(icon) {
1294
+ if (icon.startsWith("<svg ")) {
1295
+ this.shadowRoot.innerHTML = icon;
1296
+ return true;
1297
+ }
1298
+ return false;
1198
1299
  }
1199
1300
  // #region 属性
1200
- _corner_set() {
1201
- this.shadowRoot.adoptedStyleSheets = this.corner ? [baseStyle, styleSheet, cornerStyleSheet] : [baseStyle, styleSheet];
1301
+ _icon_set(icon) {
1302
+ if (icon) {
1303
+ void (__privateMethod$1(this, _Icon_instances, showStr_fn).call(this, icon) || __privateMethod$1(this, _Icon_instances, showCache_fn).call(this, icon) || __privateMethod$1(this, _Icon_instances, showUnicode_fn).call(this, icon));
1304
+ } else {
1305
+ this.shadowRoot.innerHTML = "";
1306
+ }
1202
1307
  }
1203
1308
  // #endregion
1204
1309
  }
1205
1310
  _init$1 = __decoratorStart$1(_a$1);
1206
- _corner = /* @__PURE__ */ new WeakMap();
1207
- __decorateElement$1(_init$1, 4, "corner", _corner_dec, CloseBtn, _corner);
1208
- CloseBtn = __decorateElement$1(_init$1, 0, "CloseBtn", _CloseBtn_decorators, CloseBtn);
1209
- __runInitializers$1(_init$1, 1, CloseBtn);
1210
- const iconCache = {};
1311
+ _Icon_instances = /* @__PURE__ */ new WeakSet();
1312
+ showStr_fn = function(icon) {
1313
+ return this.setSvg(icon) || this.setImg(icon);
1314
+ };
1315
+ showCache_fn = function(p) {
1316
+ const cache = iconCache[p];
1317
+ if (!cache) return false;
1318
+ if (typeof cache === "string") {
1319
+ return __privateMethod$1(this, _Icon_instances, showStr_fn).call(this, cache);
1320
+ }
1321
+ if (cache instanceof HTMLImageElement) {
1322
+ return this.setImg(cache.src);
1323
+ }
1324
+ return false;
1325
+ };
1326
+ showUnicode_fn = function(icon) {
1327
+ this.shadowRoot.textContent = icon;
1328
+ };
1329
+ _icon = /* @__PURE__ */ new WeakMap();
1330
+ __decorateElement$1(_init$1, 4, "icon", _icon_dec, Icon, _icon);
1331
+ Icon = __decorateElement$1(_init$1, 0, "Icon", _Icon_decorators, Icon);
1332
+ __runInitializers$1(_init$1, 1, Icon);
1211
1333
  var __create = Object.create;
1212
1334
  var __defProp = Object.defineProperty;
1213
1335
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1250,100 +1372,445 @@ var __decorateElement = (array, flags, name, decorators, target, extra) => {
1250
1372
  }
1251
1373
  return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
1252
1374
  };
1375
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
1253
1376
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
1254
1377
  var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the "in" operator on this value') : member.has(obj);
1255
1378
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
1256
1379
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1257
1380
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
1258
1381
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
1259
- var _icon_dec, _a, _Icon_decorators, _Icon_instances, showStr_fn, showCache_fn, showUnicode_fn, _init, _icon;
1260
- const style = createStyleSheet({
1261
- //防止网页中没有定义这些字体。如'⚙'在没有 Emoji 字体加持的情况下,显示非常难看。
1262
- //默认不要 inline-block,选中一行包含 icon 的文字时,可以看出明显区别。
1263
- ":host": `
1264
- /*display: inline-block;*/
1265
- font-family: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
1266
- `,
1267
- //height - 相对于父元素的字体高度,这是关键!
1268
- "img, svg": `
1269
- width: 1em;
1270
- height: 1em;
1271
- vertical-align: middle;
1272
- color: inherit;
1273
- `
1274
- });
1275
- const tagName = "GZM-ICON";
1276
- const mutableAttributes = ["icon"];
1277
- _Icon_decorators = [defineElement({ tagName, mutableAttributes })];
1278
- class Icon extends (_a = HTMLElement, _icon_dec = [strAttr], _a) {
1382
+ var _duration_dec, _size_dec, _a, _CheckCircle_decorators, _CheckCircle_instances, notInline_fn, init_fn, _init, _size, _duration;
1383
+ const svg = `
1384
+ <svg width="100%" height="100%" viewBox="0 0 400 400">
1385
+ <circle fill="none" stroke="#68e534" stroke-width="20" cy="200" cx="200" r="190" stroke-linecap="round" transform="rotate(-90 200 200)"></circle>
1386
+ <polyline fill="none" stroke="#68e534" stroke-width="24" points="88,214 173,284 304,138" stroke-linecap="round" stroke-linejoin="round"/>
1387
+ </svg>
1388
+ `;
1389
+ const circleLength = 1194;
1390
+ const polylineLength = 350;
1391
+ const tagName = "GZM-CHECK-CIRCLE";
1392
+ const mutableAttributes = ["size"];
1393
+ _CheckCircle_decorators = [defineElement({ tagName, mutableAttributes })];
1394
+ class CheckCircle extends (_a = HTMLElement, _size_dec = [strAttr], _duration_dec = [intAttr], _a) {
1279
1395
  constructor() {
1280
- super();
1281
- __privateAdd(this, _Icon_instances);
1282
- __privateAdd(this, _icon, __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this);
1283
- const sr = this.attachShadow({ mode: "open" });
1284
- sr.adoptedStyleSheets = [baseStyle, style];
1285
- }
1286
- setImg(icon) {
1287
- if (icon.startsWith("data:image/") || icon.includes(".") && icon.includes("/")) {
1288
- this.shadowRoot.innerHTML = `<img src="${icon}" alt="icon">`;
1289
- return true;
1290
- }
1291
- return false;
1292
- }
1293
- setSvg(icon) {
1294
- if (icon.startsWith("<svg ")) {
1295
- this.shadowRoot.innerHTML = icon;
1296
- return true;
1396
+ super(...arguments);
1397
+ __privateAdd(this, _CheckCircle_instances);
1398
+ __publicField(this, "$circle");
1399
+ __publicField(this, "$polyline");
1400
+ __privateAdd(this, _size, __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this);
1401
+ __privateAdd(this, _duration, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this);
1402
+ }
1403
+ connectedCallback() {
1404
+ __privateMethod(this, _CheckCircle_instances, notInline_fn).call(this);
1405
+ this.innerHTML = svg;
1406
+ this.$circle = this.querySelector("circle");
1407
+ this.$polyline = this.querySelector("polyline");
1408
+ __privateMethod(this, _CheckCircle_instances, init_fn).call(this);
1409
+ }
1410
+ play() {
1411
+ const d = 3e3;
1412
+ let dur = this.duration ?? d;
1413
+ if (dur <= 0) {
1414
+ dur = d;
1297
1415
  }
1298
- return false;
1416
+ const durCircle = Math.floor(dur / (circleLength + polylineLength) * circleLength);
1417
+ const durPolyline = dur - durCircle;
1418
+ const $c = this.$circle;
1419
+ $c.style.transitionDuration = `${durCircle}ms`;
1420
+ const $p = this.$polyline;
1421
+ $p.style.transitionDuration = `${durPolyline}ms`;
1422
+ return new Promise((resolve) => {
1423
+ void window.getComputedStyle($c).strokeDashoffset;
1424
+ $c.style.strokeDashoffset = (circleLength * 2).toString();
1425
+ $c.ontransitionend = () => {
1426
+ $p.style.strokeDashoffset = "0";
1427
+ $p.ontransitionend = () => {
1428
+ resolve(void 0);
1429
+ };
1430
+ };
1431
+ });
1299
1432
  }
1300
- // #region 属性
1301
- _icon_set(icon) {
1302
- if (icon) {
1303
- void (__privateMethod(this, _Icon_instances, showStr_fn).call(this, icon) || __privateMethod(this, _Icon_instances, showCache_fn).call(this, icon) || __privateMethod(this, _Icon_instances, showUnicode_fn).call(this, icon));
1304
- } else {
1305
- this.shadowRoot.innerHTML = "";
1306
- }
1433
+ _size_set(nv) {
1434
+ nv = nv ?? "";
1435
+ this.style.width = nv;
1436
+ this.style.height = nv;
1437
+ this.style.aspectRatio = "1 / 1";
1307
1438
  }
1308
1439
  // #endregion
1309
1440
  }
1310
1441
  _init = __decoratorStart(_a);
1311
- _Icon_instances = /* @__PURE__ */ new WeakSet();
1312
- showStr_fn = function(icon) {
1313
- return this.setSvg(icon) || this.setImg(icon);
1314
- };
1315
- showCache_fn = function(p) {
1316
- const cache = iconCache[p];
1317
- if (!cache) return false;
1318
- if (typeof cache === "string") {
1319
- return __privateMethod(this, _Icon_instances, showStr_fn).call(this, cache);
1442
+ _CheckCircle_instances = /* @__PURE__ */ new WeakSet();
1443
+ notInline_fn = function() {
1444
+ const computedStyle = window.getComputedStyle(this);
1445
+ if (computedStyle.display === "inline") {
1446
+ this.style.display = "inline-block";
1320
1447
  }
1321
- if (cache instanceof HTMLImageElement) {
1322
- return this.setImg(cache.src);
1323
- }
1324
- return false;
1325
1448
  };
1326
- showUnicode_fn = function(icon) {
1327
- this.shadowRoot.textContent = icon;
1449
+ init_fn = function() {
1450
+ const $c = this.$circle;
1451
+ $c.style.strokeDasharray = circleLength.toString();
1452
+ $c.style.strokeDashoffset = circleLength.toString();
1453
+ $c.style.transitionProperty = "stroke-dashoffset";
1454
+ const $p = this.$polyline;
1455
+ $p.style.strokeDasharray = polylineLength.toString();
1456
+ $p.style.strokeDashoffset = polylineLength.toString();
1457
+ $p.style.transitionProperty = "stroke-dashoffset";
1328
1458
  };
1329
- _icon = /* @__PURE__ */ new WeakMap();
1330
- __decorateElement(_init, 4, "icon", _icon_dec, Icon, _icon);
1331
- Icon = __decorateElement(_init, 0, "Icon", _Icon_decorators, Icon);
1332
- __runInitializers(_init, 1, Icon);
1459
+ _size = /* @__PURE__ */ new WeakMap();
1460
+ _duration = /* @__PURE__ */ new WeakMap();
1461
+ __decorateElement(_init, 4, "size", _size_dec, CheckCircle, _size);
1462
+ __decorateElement(_init, 4, "duration", _duration_dec, CheckCircle, _duration);
1463
+ CheckCircle = __decorateElement(_init, 0, "CheckCircle", _CheckCircle_decorators, CheckCircle);
1464
+ __runInitializers(_init, 1, CheckCircle);
1465
+ function createDialog(options) {
1466
+ const $dlg = document.createElement("dialog");
1467
+ $dlg.className = "gzm-frame gzm-dlg";
1468
+ if (!options.reusable) {
1469
+ removeWhenClose($dlg);
1470
+ }
1471
+ if (options.resizable) {
1472
+ $dlg.setAttribute("resize", "");
1473
+ }
1474
+ if (options.title) {
1475
+ const $header = setDefaultHeader($dlg, options.title);
1476
+ if (options.movable) {
1477
+ setHeaderMovable($dlg, $header);
1478
+ }
1479
+ }
1480
+ if (options.okHandler) {
1481
+ setDefaultFooter($dlg, options.okHandler);
1482
+ }
1483
+ if (options.$body) {
1484
+ setBody($dlg, options.$body);
1485
+ }
1486
+ if (options.width) {
1487
+ $dlg.style.width = options.width;
1488
+ }
1489
+ if (options.height) {
1490
+ $dlg.style.height = options.height;
1491
+ }
1492
+ document.body.appendChild($dlg);
1493
+ return $dlg;
1494
+ }
1495
+ function showDockRightModalDlg(options) {
1496
+ const $dlg = createDialog(options);
1497
+ dockRight($dlg);
1498
+ $dlg.showModal();
1499
+ return $dlg;
1500
+ }
1501
+ function dockRight($dlg) {
1502
+ $dlg.setAttribute("dock", "right");
1503
+ Reflect.set($dlg, "slideOut", slideOutRight);
1504
+ $dlg.onkeydown = (e) => {
1505
+ if (e.key === "Escape") {
1506
+ e.preventDefault();
1507
+ slideOutRight.apply($dlg);
1508
+ }
1509
+ };
1510
+ $dlg.ontoggle = (e) => {
1511
+ if (e.newState === "open") {
1512
+ $dlg.style.transform = "translateX(0)";
1513
+ }
1514
+ };
1515
+ }
1516
+ function slideOutRight() {
1517
+ this.style.transform = "translateX(100%)";
1518
+ this.ontransitionend = () => {
1519
+ this.close();
1520
+ this.ontransitionend = null;
1521
+ };
1522
+ }
1523
+ function removeWhenClose($dlg) {
1524
+ $dlg.onclose = () => {
1525
+ $dlg.remove();
1526
+ };
1527
+ }
1528
+ function setDefaultHeader($dlg, dlgTitle) {
1529
+ let $header = $dlg.querySelector("header");
1530
+ if (!$header) {
1531
+ $header = document.createElement("header");
1532
+ $header.className = "gzm-header";
1533
+ $dlg.appendChild($header);
1534
+ }
1535
+ $header.innerHTML = `<strong>${dlgTitle}</strong><div class='gzm-txt-btn'>✕</div>`;
1536
+ const $closeBtn = $header.querySelector(".gzm-txt-btn");
1537
+ $closeBtn.onclick = () => closeDlg($dlg);
1538
+ return $header;
1539
+ }
1540
+ function setDefaultFooter($dlg, okHandler) {
1541
+ let $footer = $dlg.querySelector("footer");
1542
+ if (!$footer) {
1543
+ $footer = document.createElement("footer");
1544
+ $dlg.appendChild($footer);
1545
+ } else {
1546
+ $footer.innerHTML = "";
1547
+ }
1548
+ const $cancelBtn = document.createElement("button");
1549
+ $cancelBtn.textContent = GT.cancel;
1550
+ $cancelBtn.onclick = () => closeDlg($dlg);
1551
+ const $okBtn = document.createElement("button");
1552
+ $okBtn.textContent = GT.ok;
1553
+ $okBtn.onclick = () => okHandler($dlg);
1554
+ $footer.append($cancelBtn, $okBtn);
1555
+ }
1556
+ function setHeaderMovable($dlg, $header) {
1557
+ $header.style.cursor = "move";
1558
+ let userSelect;
1559
+ const firstMove = () => {
1560
+ if (userSelect) {
1561
+ return;
1562
+ }
1563
+ const style2 = window.getComputedStyle($dlg);
1564
+ userSelect = style2.getPropertyValue("user-select");
1565
+ $dlg.style.userSelect = "none";
1566
+ $dlg.style.margin = "0";
1567
+ };
1568
+ $header.onmousedown = (e) => {
1569
+ const $t = e.target;
1570
+ if ($t.classList.contains("gzm-txt-btn")) return;
1571
+ const rect = $dlg.getBoundingClientRect();
1572
+ const offsetX = e.clientX - rect.left;
1573
+ const offsetY = e.clientY - rect.top;
1574
+ const move = (me) => {
1575
+ firstMove();
1576
+ let left = me.clientX - offsetX;
1577
+ left = Math.max(0, left);
1578
+ left = Math.min(document.documentElement.clientWidth - rect.width, left);
1579
+ let top = me.clientY - offsetY;
1580
+ top = Math.max(0, top);
1581
+ top = Math.min(document.documentElement.clientHeight - rect.height, top);
1582
+ $dlg.style.left = left + "px";
1583
+ $dlg.style.top = top + "px";
1584
+ };
1585
+ const up = () => {
1586
+ document.removeEventListener("mousemove", move);
1587
+ document.removeEventListener("mouseup", up);
1588
+ if (userSelect) {
1589
+ $dlg.style.userSelect = userSelect;
1590
+ userSelect = "";
1591
+ }
1592
+ };
1593
+ document.addEventListener("mousemove", move);
1594
+ document.addEventListener("mouseup", up);
1595
+ };
1596
+ }
1597
+ function setBody($dlg, $body) {
1598
+ $dlg.appendChild($body);
1599
+ }
1600
+ function closeDlg($dlg) {
1601
+ if ("slideOut" in $dlg && typeof $dlg.slideOut === "function") {
1602
+ $dlg.slideOut();
1603
+ return;
1604
+ }
1605
+ $dlg.close();
1606
+ }
1607
+ const className = ".gzm-dlg";
1608
+ const styleSheet = createStyleSheet({
1609
+ [className]: `
1610
+ max-width:100vw;
1611
+ max-height:100vh;
1612
+ margin:auto;
1613
+ padding:0.25rem;/*gzm-frame 中有 p-2,直接放在 .dlg 中不起作用!*/
1614
+ `,
1615
+ /* resize: attr(resize, "both"); 可惜不起作用,否则就可以设置元素的属性来控制 */
1616
+ [className + "[resize]"]: `
1617
+ resize: both;
1618
+ border-bottom-right-radius: 0;/*会在右下角显示调整尺寸的句柄*/
1619
+ `,
1620
+ [className + "[dock]"]: `
1621
+ transition-property:transform;
1622
+ transition-duration:750ms;
1623
+ margin:0;/*<dialog> 浏览器样式有 margin,会阻止 dock*/
1624
+ `,
1625
+ /*<dialog> open 才会显示,显示后才启用 grid,否则会阻止 <dialog> 关闭,因为关闭就是 display:none;*/
1626
+ [className + "[open]"]: `
1627
+ display: grid;
1628
+ grid-template-columns: 1fr;
1629
+ grid-template-rows: auto 1fr auto;
1630
+ gap: 0.25rem;
1631
+ overflow: hidden;
1632
+ outline-style: none; /*不要显示一圈黑框*/
1633
+ `,
1634
+ [className + "[dock=right]"]: `
1635
+ top: 0px;
1636
+ height: 100vh;
1637
+ left: auto;
1638
+ right: 0;
1639
+ transform: translateX(100%);
1640
+ `,
1641
+ [className + ">header"]: `
1642
+ grid-row: 1;
1643
+ border-radius: 0.5rem;
1644
+ gap: 1rem;
1645
+ padding-inline: 1rem;
1646
+ padding-block: 0.5rem;
1647
+ display: flex;
1648
+ align-items: center;
1649
+ `,
1650
+ /*对话框标题*/
1651
+ [className + ">header>strong"]: `
1652
+ flex: auto;
1653
+ white-space: nowrap;
1654
+ overflow: hidden;
1655
+ text-overflow: ellipsis;
1656
+ `,
1657
+ [className + ">footer"]: `
1658
+ grid-row: -1;
1659
+ border-top: var(--gzm-btn-border);
1660
+ padding-inline: 1rem;
1661
+ padding-block: 0.75rem;
1662
+ display: flex;
1663
+ justify-content: space-between;
1664
+ `,
1665
+ /*footer 中的确定取消按钮*/
1666
+ [className + ">footer>button"]: `
1667
+ font: inherit;
1668
+ line-height: inherit;
1669
+ color: var(--gzm-btn-txt-color);
1670
+ background: var(--gzm-btn-background);
1671
+ border: var(--gzm-btn-border);
1672
+ border-radius: 0.5rem;
1673
+ padding: 0.375rem 0.75rem;
1674
+ `,
1675
+ [className + ">footer>button:hover"]: `
1676
+ color: var(--gzm-h-btn-txt-color);
1677
+ background: var(--gzm-h-btn-background);
1678
+ border: var(--gzm-h-btn-border);
1679
+ `,
1680
+ [className + ">footer>button:active"]: `
1681
+ color: var(--gzm-a-btn-txt-color) !important;
1682
+ background: var(--gzm-a-btn-background) !important;
1683
+ border: var(--gzm-a-btn-border) !important;
1684
+ `
1685
+ });
1686
+ document.adoptedStyleSheets.push(styleSheet);
1687
+ const emojis = ["🕛", "🕐", "🕑", "🕒", "🕓", "🕔", "🕕", "🕖", "🕗", "🕘", "🕙", "🕚"];
1688
+ function showWaiting(title, msg) {
1689
+ const $p = document.createElement("p");
1690
+ $p.style.margin = "1rem";
1691
+ $p.style.fontSize = "xxx-large";
1692
+ $p.textContent = emojis[0];
1693
+ const $cap = document.createElement("figcaption");
1694
+ $cap.textContent = msg ?? GT.waiting;
1695
+ const $fig = document.createElement("figure");
1696
+ $fig.style.margin = "1rem";
1697
+ $fig.style.textAlign = "center";
1698
+ $fig.append($p, $cap);
1699
+ const $dlg = createDialog({
1700
+ title,
1701
+ movable: true,
1702
+ $body: $fig
1703
+ });
1704
+ $dlg.showModal();
1705
+ $fig.style.width = Math.floor($fig.offsetWidth / 0.618) + "px";
1706
+ let index = 0;
1707
+ const handle = window.setInterval(() => {
1708
+ if (index < 0 || !$dlg.parentElement) {
1709
+ window.clearInterval(handle);
1710
+ return;
1711
+ }
1712
+ index = (index + 1) % emojis.length;
1713
+ $p.textContent = emojis[index];
1714
+ }, 1e3);
1715
+ return {
1716
+ $dlg,
1717
+ async complete(msg2 = GT.completed) {
1718
+ $cap.textContent = msg2;
1719
+ this.setTitle(GT.completed);
1720
+ index = -1;
1721
+ const $cc = document.createElement(tagName);
1722
+ $cc.size = "100px";
1723
+ $cc.duration = 1500;
1724
+ $p.replaceWith($cc);
1725
+ await $cc.play();
1726
+ this.$dlg.close();
1727
+ },
1728
+ error(e = GT.error) {
1729
+ index = -1;
1730
+ $p.textContent = "👮";
1731
+ if (typeof e === "string") {
1732
+ $cap.textContent = e;
1733
+ } else if ("message" in e) {
1734
+ $cap.textContent = String(e.message);
1735
+ } else {
1736
+ $cap.textContent = String(e);
1737
+ }
1738
+ $cap.style.color = "var(--gzm-error-txt-color)";
1739
+ this.setTitle(GT.error);
1740
+ },
1741
+ alert(msg2) {
1742
+ index = -1;
1743
+ $p.textContent = "🙋";
1744
+ $cap.innerHTML = `<strong>${msg2}</strong>`;
1745
+ this.setTitle(GT.attention);
1746
+ },
1747
+ close() {
1748
+ this.$dlg.close();
1749
+ },
1750
+ setTitle(title2) {
1751
+ const $s = this.$dlg.querySelector(":scope > header:first-child > strong:first-child");
1752
+ if ($s) {
1753
+ $s.textContent = title2;
1754
+ }
1755
+ }
1756
+ };
1757
+ }
1758
+ function showError(errMsg) {
1759
+ const $p = document.createElement("p");
1760
+ $p.style.margin = "1rem";
1761
+ $p.style.fontSize = "xxx-large";
1762
+ $p.textContent = "👮";
1763
+ const $cap = document.createElement("figcaption");
1764
+ $cap.textContent = errMsg;
1765
+ $cap.style.color = "var(--gzm-error-txt-color)";
1766
+ const $fig = document.createElement("figure");
1767
+ $fig.style.margin = "1rem";
1768
+ $fig.style.textAlign = "center";
1769
+ $fig.append($p, $cap);
1770
+ const $dlg = createDialog({
1771
+ title: GT.error,
1772
+ movable: true,
1773
+ $body: $fig
1774
+ });
1775
+ $dlg.showModal();
1776
+ return $dlg;
1777
+ }
1778
+ function showAlert(msg) {
1779
+ const $p = document.createElement("p");
1780
+ $p.style.margin = "1rem";
1781
+ $p.style.fontSize = "xxx-large";
1782
+ $p.textContent = "🙋";
1783
+ const $cap = document.createElement("figcaption");
1784
+ $cap.innerHTML = `<strong>${msg}</strong>`;
1785
+ const $fig = document.createElement("figure");
1786
+ $fig.style.margin = "1rem";
1787
+ $fig.style.textAlign = "center";
1788
+ $fig.append($p, $cap);
1789
+ const $dlg = createDialog({
1790
+ title: GT.attention,
1791
+ movable: true,
1792
+ $body: $fig
1793
+ });
1794
+ $dlg.showModal();
1795
+ return $dlg;
1796
+ }
1333
1797
  export {
1334
1798
  Badge,
1335
1799
  CenterHelper,
1800
+ CheckCircle,
1336
1801
  CloseBtn,
1337
1802
  CornerHelper,
1338
1803
  GT,
1339
1804
  Icon,
1340
1805
  allThemes,
1341
1806
  attachBorderAttributeName,
1342
- tagName$2 as badgeTagName,
1807
+ tagName$3 as badgeTagName,
1343
1808
  baseStyle,
1344
1809
  boolAttr,
1345
1810
  borders,
1346
- tagName$1 as closeTagName,
1811
+ tagName as checkCircleTagName,
1812
+ tagName$2 as closeTagName,
1813
+ createDialog,
1347
1814
  createStyleSheet,
1348
1815
  createText,
1349
1816
  createTxtBtn,
@@ -1358,7 +1825,7 @@ export {
1358
1825
  gzmHeader,
1359
1826
  htmlThemeAttr,
1360
1827
  iconCache,
1361
- tagName as iconTagName,
1828
+ tagName$1 as iconTagName,
1362
1829
  intAttr,
1363
1830
  isLeftCorner,
1364
1831
  isTopCorner,
@@ -1366,6 +1833,10 @@ export {
1366
1833
  makeCorner,
1367
1834
  saAttr,
1368
1835
  setCurrentTheme,
1836
+ showAlert,
1837
+ showDockRightModalDlg,
1838
+ showError,
1839
+ showWaiting,
1369
1840
  strAttr,
1370
1841
  utilityStyle,
1371
1842
  xy