@next-core/brick-kit-v3 0.1.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.
@@ -0,0 +1,604 @@
1
+ import _extends from '@babel/runtime/helpers/esm/extends';
2
+ import _objectSpread from '@babel/runtime/helpers/objectSpread2';
3
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
4
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
5
+
6
+ var Pagination = {
7
+ // Options.jsx
8
+ items_per_page: '条/页',
9
+ jump_to: '跳至',
10
+ jump_to_confirm: '确定',
11
+ page: '页',
12
+ // Pagination.jsx
13
+ prev_page: '上一页',
14
+ next_page: '下一页',
15
+ prev_5: '向前 5 页',
16
+ next_5: '向后 5 页',
17
+ prev_3: '向前 3 页',
18
+ next_3: '向后 3 页'
19
+ };
20
+
21
+ var locale$2 = {
22
+ locale: 'zh_CN',
23
+ today: '今天',
24
+ now: '此刻',
25
+ backToToday: '返回今天',
26
+ ok: '确定',
27
+ timeSelect: '选择时间',
28
+ dateSelect: '选择日期',
29
+ weekSelect: '选择周',
30
+ clear: '清除',
31
+ month: '月',
32
+ year: '年',
33
+ previousMonth: '上个月 (翻页上键)',
34
+ nextMonth: '下个月 (翻页下键)',
35
+ monthSelect: '选择月份',
36
+ yearSelect: '选择年份',
37
+ decadeSelect: '选择年代',
38
+ yearFormat: 'YYYY年',
39
+ dayFormat: 'D日',
40
+ dateFormat: 'YYYY年M月D日',
41
+ dateTimeFormat: 'YYYY年M月D日 HH时mm分ss秒',
42
+ previousYear: '上一年 (Control键加左方向键)',
43
+ nextYear: '下一年 (Control键加右方向键)',
44
+ previousDecade: '上一年代',
45
+ nextDecade: '下一年代',
46
+ previousCentury: '上一世纪',
47
+ nextCentury: '下一世纪'
48
+ };
49
+
50
+ var locale$1 = {
51
+ placeholder: '请选择时间',
52
+ rangePlaceholder: ['开始时间', '结束时间']
53
+ };
54
+ var TimePicker = locale$1;
55
+
56
+ var locale = {
57
+ lang: _extends({
58
+ placeholder: '请选择日期',
59
+ yearPlaceholder: '请选择年份',
60
+ quarterPlaceholder: '请选择季度',
61
+ monthPlaceholder: '请选择月份',
62
+ weekPlaceholder: '请选择周',
63
+ rangePlaceholder: ['开始日期', '结束日期'],
64
+ rangeYearPlaceholder: ['开始年份', '结束年份'],
65
+ rangeMonthPlaceholder: ['开始月份', '结束月份'],
66
+ rangeWeekPlaceholder: ['开始周', '结束周']
67
+ }, locale$2),
68
+ timePickerLocale: _extends({}, TimePicker)
69
+ }; // should add whitespace between char in Button
70
+
71
+ locale.lang.ok = '确 定'; // All settings at:
72
+ // https://github.com/ant-design/ant-design/blob/master/components/date-picker/locale/example.json
73
+
74
+ var DatePicker = locale;
75
+
76
+ /* eslint-disable no-template-curly-in-string */
77
+ var typeTemplate = '${label}不是一个有效的${type}';
78
+ var localeValues = {
79
+ locale: 'zh-cn',
80
+ Pagination: Pagination,
81
+ DatePicker: DatePicker,
82
+ TimePicker: TimePicker,
83
+ Calendar: DatePicker,
84
+ // locales for all components
85
+ global: {
86
+ placeholder: '请选择'
87
+ },
88
+ Table: {
89
+ filterTitle: '筛选',
90
+ filterConfirm: '确定',
91
+ filterReset: '重置',
92
+ filterEmptyText: '无筛选项',
93
+ selectAll: '全选当页',
94
+ selectInvert: '反选当页',
95
+ selectNone: '清空所有',
96
+ selectionAll: '全选所有',
97
+ sortTitle: '排序',
98
+ expand: '展开行',
99
+ collapse: '关闭行',
100
+ triggerDesc: '点击降序',
101
+ triggerAsc: '点击升序',
102
+ cancelSort: '取消排序'
103
+ },
104
+ Modal: {
105
+ okText: '确定',
106
+ cancelText: '取消',
107
+ justOkText: '知道了'
108
+ },
109
+ Popconfirm: {
110
+ cancelText: '取消',
111
+ okText: '确定'
112
+ },
113
+ Transfer: {
114
+ searchPlaceholder: '请输入搜索内容',
115
+ itemUnit: '项',
116
+ itemsUnit: '项',
117
+ remove: '删除',
118
+ selectCurrent: '全选当页',
119
+ removeCurrent: '删除当页',
120
+ selectAll: '全选所有',
121
+ removeAll: '删除全部',
122
+ selectInvert: '反选当页'
123
+ },
124
+ Upload: {
125
+ uploading: '文件上传中',
126
+ removeFile: '删除文件',
127
+ uploadError: '上传错误',
128
+ previewFile: '预览文件',
129
+ downloadFile: '下载文件'
130
+ },
131
+ Empty: {
132
+ description: '暂无数据'
133
+ },
134
+ Icon: {
135
+ icon: '图标'
136
+ },
137
+ Text: {
138
+ edit: '编辑',
139
+ copy: '复制',
140
+ copied: '复制成功',
141
+ expand: '展开'
142
+ },
143
+ PageHeader: {
144
+ back: '返回'
145
+ },
146
+ Form: {
147
+ optional: '(可选)',
148
+ defaultValidateMessages: {
149
+ "default": '字段验证错误${label}',
150
+ required: '请输入${label}',
151
+ "enum": '${label}必须是其中一个[${enum}]',
152
+ whitespace: '${label}不能为空字符',
153
+ date: {
154
+ format: '${label}日期格式无效',
155
+ parse: '${label}不能转换为日期',
156
+ invalid: '${label}是一个无效日期'
157
+ },
158
+ types: {
159
+ string: typeTemplate,
160
+ method: typeTemplate,
161
+ array: typeTemplate,
162
+ object: typeTemplate,
163
+ number: typeTemplate,
164
+ date: typeTemplate,
165
+ "boolean": typeTemplate,
166
+ integer: typeTemplate,
167
+ "float": typeTemplate,
168
+ regexp: typeTemplate,
169
+ email: typeTemplate,
170
+ url: typeTemplate,
171
+ hex: typeTemplate
172
+ },
173
+ string: {
174
+ len: '${label}须为${len}个字符',
175
+ min: '${label}最少${min}个字符',
176
+ max: '${label}最多${max}个字符',
177
+ range: '${label}须在${min}-${max}字符之间'
178
+ },
179
+ number: {
180
+ len: '${label}必须等于${len}',
181
+ min: '${label}最小值为${min}',
182
+ max: '${label}最大值为${max}',
183
+ range: '${label}须在${min}-${max}之间'
184
+ },
185
+ array: {
186
+ len: '须为${len}个${label}',
187
+ min: '最少${min}个${label}',
188
+ max: '最多${max}个${label}',
189
+ range: '${label}数量须在${min}-${max}之间'
190
+ },
191
+ pattern: {
192
+ mismatch: '${label}与模式不匹配${pattern}'
193
+ }
194
+ }
195
+ },
196
+ Image: {
197
+ preview: '预览'
198
+ }
199
+ };
200
+ var localeValues$1 = localeValues;
201
+
202
+ function warnNativeHtmlElementProperty(key, options) {
203
+ // Testing env is ignored to simplify dependents testing.
204
+ // istanbul ignore if
205
+ if (key in HTMLElement.prototype && !(options !== null && options !== void 0 && options.__deprecated_and_for_compatibility_only)) {
206
+ var message = "\"".concat(key, "\" is a native HTMLElement property, and is deprecated to be used as a brick property.");
207
+ // istanbul ignore if
208
+ if (process.env.NODE_ENV === "test") {
209
+ // Allow existed properties to work.
210
+ // But throw error at test, to avoid new conflicted properties.
211
+ throw new Error(message);
212
+ }
213
+ // eslint-disable-next-line no-console
214
+ console.warn(message);
215
+ }
216
+ }
217
+
218
+ // Inspired by [LitElement](https://github.com/Polymer/lit-element)
219
+
220
+ // About the (most likely) related version of decorator proposal:
221
+ // https://github.com/tc39/proposal-decorators/blob/691d95e67052e125239a725d2756cb8a039c5fb9/previous/METAPROGRAMMING.md
222
+
223
+ /**
224
+ * 构件属性装饰器。
225
+ *
226
+ * @example
227
+ *
228
+ * ```ts
229
+ * class MyBrickElement extends UpdatingElement {
230
+ * @property()
231
+ * myStringProp: string;
232
+ *
233
+ * @property({ type: Number })
234
+ * myNumberProp: number;
235
+ *
236
+ * @property({ type: Boolean })
237
+ * myBooleanProperty: boolean;
238
+ *
239
+ * @property({ attribute: false })
240
+ * myComplexProperty: MyComplexInterface;
241
+ * }
242
+ * ```
243
+ *
244
+ * @param options - 构件属性的选项。
245
+ */
246
+ function property(options) {
247
+ return function decorateProperty(element) {
248
+ if (options !== null && options !== void 0 && options.__unstable_doNotDecorate) {
249
+ return element;
250
+ }
251
+ if (element.kind !== "field" || typeof element.key !== "string") {
252
+ throw new Error("`@property()` only support decorate class string property");
253
+ }
254
+ if (typeof element.initializer === "function" && (options === null || options === void 0 ? void 0 : options.attribute) !== false) {
255
+ throw new Error("`@property()` currently not support initialize value");
256
+ }
257
+ warnNativeHtmlElementProperty(element.key, options);
258
+
259
+ // createProperty() takes care of defining the property, but we still
260
+ // must return some kind of descriptor, so return a descriptor for an
261
+ // unused prototype field. The finisher calls createProperty().
262
+ return {
263
+ kind: "field",
264
+ key: Symbol(),
265
+ placement: "own",
266
+ descriptor: {},
267
+ initializer() {
268
+ if (typeof element.initializer === "function") {
269
+ this[element.key] = element.initializer.call(this);
270
+ }
271
+ },
272
+ finisher(Class) {
273
+ Class.createProperty(element.key, options);
274
+ }
275
+ };
276
+ };
277
+ }
278
+
279
+ /**
280
+ * 构件事件装饰器。
281
+ *
282
+ * @example
283
+ *
284
+ * ```ts
285
+ * class MyBrickElement extends UpdatingElement {
286
+ * @event({
287
+ * type: "my-brick.my-event",
288
+ * })
289
+ * private _myEventEmitter: EventEmitter<number>;
290
+ *
291
+ * private _triggerMyEvent = (): void => {
292
+ * this._myEventEmitter.emit(123);
293
+ * };
294
+ * }
295
+ * ```
296
+ *
297
+ * @param options - 构件事件的选项。
298
+ */
299
+ function event(options) {
300
+ return function decorateEvent(element) {
301
+ if (element.kind !== "field" || typeof element.key !== "string") {
302
+ throw new Error("`@event()` only support decorate class string property");
303
+ }
304
+ if (typeof element.initializer === "function") {
305
+ throw new Error("`@event()` currently not support initialize value");
306
+ }
307
+ warnNativeHtmlElementProperty(element.key);
308
+ return {
309
+ kind: "field",
310
+ key: Symbol(),
311
+ placement: "own",
312
+ descriptor: {},
313
+ finisher(Class) {
314
+ Class.createEventEmitter(element.key, options);
315
+ }
316
+ };
317
+ };
318
+ }
319
+
320
+ /**
321
+ * 构件方法装饰器。
322
+ *
323
+ * @example
324
+ *
325
+ * ```ts
326
+ * class MyBrickElement extends UpdatingElement {
327
+ * @method()
328
+ * myMethod(): void {
329
+ * // Do something.
330
+ * }
331
+ * }
332
+ * ```
333
+ */
334
+ function method() {
335
+ return function decorateMethod(element) {
336
+ if (element.kind !== "method" || typeof element.key !== "string") {
337
+ throw new Error("`@method()` only support decorate class string method");
338
+ }
339
+ warnNativeHtmlElementProperty(element.key);
340
+ return _objectSpread(_objectSpread({}, element), {}, {
341
+ finisher(Class) {
342
+ Class.createMethod(element.key);
343
+ }
344
+ });
345
+ };
346
+ }
347
+
348
+ var _excluded = ["type"];
349
+ // Inspired by [LitElement](https://github.com/Polymer/lit-element)
350
+
351
+ /**
352
+ * Converts property values to and from attribute values.
353
+ */
354
+
355
+ /**
356
+ * Defines options for a property accessor.
357
+ */
358
+
359
+ var defaultConverter = {
360
+ toAttribute(value, type) {
361
+ switch (type) {
362
+ case Boolean:
363
+ return value ? "" : null;
364
+ }
365
+ return value;
366
+ },
367
+ fromAttribute(value, type) {
368
+ switch (type) {
369
+ case Boolean:
370
+ return value !== null;
371
+ case Number:
372
+ return value === null ? null : Number(value);
373
+ }
374
+ return value;
375
+ }
376
+ };
377
+ /**
378
+ * Change function that returns true if `value` is different from `oldValue`.
379
+ * This method is used as the default for a property's `hasChanged` function.
380
+ */
381
+ var notEqual = (value, old) => {
382
+ // This ensures (old==NaN, value==NaN) always returns false
383
+ return old !== value && (old === old || value === value);
384
+ };
385
+ var defaultPropertyDeclaration = {
386
+ attribute: true,
387
+ type: String,
388
+ converter: defaultConverter,
389
+ reflect: true,
390
+ hasChanged: notEqual
391
+ };
392
+ function attributeNameForProperty(name, options) {
393
+ var attribute = options.attribute;
394
+ return attribute === false ? undefined : typeof attribute === "string" ? attribute : typeof name === "string" ? name.replace(/[A-Z]/g, char => "-".concat(char.toLowerCase())) : undefined;
395
+ }
396
+
397
+ /**
398
+ * 构件事件的选项。
399
+ */
400
+
401
+ /**
402
+ * 普通构件的抽象基类。
403
+ *
404
+ * @example
405
+ *
406
+ * ```ts
407
+ * class MyBrickElement extends UpdatingElement {
408
+ * @property()
409
+ * myProp: string;
410
+ *
411
+ * _render() {
412
+ * if (this.isConnected) {
413
+ * // ...
414
+ * }
415
+ * }
416
+ * }
417
+ * ```
418
+ */
419
+ class UpdatingElement extends HTMLElement {
420
+ constructor() {
421
+ super(...arguments);
422
+ _defineProperty(this, "_hasRequestedRender", false);
423
+ }
424
+ /** @internal */
425
+ static get observedAttributes() {
426
+ this._ensureObservedAttributes();
427
+ return Array.from(this._observedAttributes);
428
+ }
429
+
430
+ /** @internal */
431
+ static get _dev_only_definedProperties() {
432
+ this._ensureDefinedProperties();
433
+ return Array.from(this.__dev_only_definedProperties);
434
+ }
435
+
436
+ /** @internal */
437
+ static get _dev_only_definedMethods() {
438
+ this._ensureDefinedMethods();
439
+ return Array.from(this.__dev_only_definedMethods);
440
+ }
441
+
442
+ /** @internal */
443
+ static get _dev_only_definedEvents() {
444
+ this._ensureDefinedEvents();
445
+ return Array.from(this.__dev_only_definedEvents);
446
+ }
447
+
448
+ /** @internal */
449
+ get $$typeof() {
450
+ return "brick";
451
+ }
452
+
453
+ /** @internal */
454
+ attributeChangedCallback(name, old, value) {
455
+ if (old !== value) {
456
+ this._enqueueRender();
457
+ }
458
+ }
459
+
460
+ // Enure multiple property settings will trigger rendering only once.
461
+ _enqueueRender() {
462
+ // If the element is not connected,
463
+ // let `connectedCallback()` do the job of rendering.
464
+ if (this.isConnected && !this._hasRequestedRender) {
465
+ this._hasRequestedRender = true;
466
+ Promise.resolve().then(() => {
467
+ this._hasRequestedRender = false;
468
+ this._render();
469
+ });
470
+ }
471
+ }
472
+ static _ensureObservedAttributes() {
473
+ // eslint-disable-next-line no-prototype-builtins
474
+ if (!this.hasOwnProperty("_observedAttributes")) {
475
+ var superClass = Object.getPrototypeOf(this);
476
+ this._observedAttributes = new Set(
477
+ // eslint-disable-next-line no-prototype-builtins
478
+ superClass.hasOwnProperty("_observedAttributes") ? superClass._observedAttributes : null);
479
+ }
480
+ }
481
+ static _ensureDefinedProperties() {
482
+ // eslint-disable-next-line no-prototype-builtins
483
+ if (!this.hasOwnProperty("__dev_only_definedProperties")) {
484
+ var superClass = Object.getPrototypeOf(this);
485
+ this.__dev_only_definedProperties = new Set(
486
+ // eslint-disable-next-line no-prototype-builtins
487
+ superClass.hasOwnProperty("__dev_only_definedProperties") ? superClass.__dev_only_definedProperties : null);
488
+ }
489
+ }
490
+ static _ensureDefinedMethods() {
491
+ // eslint-disable-next-line no-prototype-builtins
492
+ if (!this.hasOwnProperty("__dev_only_definedMethods")) {
493
+ var superClass = Object.getPrototypeOf(this);
494
+ this.__dev_only_definedMethods = new Set(
495
+ // eslint-disable-next-line no-prototype-builtins
496
+ superClass.hasOwnProperty("__dev_only_definedMethods") ? superClass.__dev_only_definedMethods : null);
497
+ }
498
+ }
499
+ static _ensureDefinedEvents() {
500
+ // eslint-disable-next-line no-prototype-builtins
501
+ if (!this.hasOwnProperty("__dev_only_definedEvents")) {
502
+ var superClass = Object.getPrototypeOf(this);
503
+ this.__dev_only_definedEvents = new Set(
504
+ // eslint-disable-next-line no-prototype-builtins
505
+ superClass.hasOwnProperty("__dev_only_definedEvents") ? superClass.__dev_only_definedEvents : null);
506
+ }
507
+ }
508
+
509
+ /** @internal */
510
+ static createProperty(name, options) {
511
+ this._ensureObservedAttributes();
512
+ this._ensureDefinedProperties();
513
+ options = Object.assign({}, defaultPropertyDeclaration, options);
514
+
515
+ // eslint-disable-next-line no-prototype-builtins
516
+ if (options.noAccessor || this.prototype.hasOwnProperty(name)) {
517
+ return;
518
+ }
519
+ this.__dev_only_definedProperties.add(name);
520
+ var attr = attributeNameForProperty(name, options);
521
+ if (attr === undefined) {
522
+ // Create a non-enumerable symbol property to delegate the property.
523
+ var delegatedPropSymbol = Symbol("delegatedProp:".concat(name));
524
+ Object.defineProperty(this.prototype, name, {
525
+ get() {
526
+ return this[delegatedPropSymbol];
527
+ },
528
+ set(value) {
529
+ var oldValue = this[name];
530
+ if (options.hasChanged(value, oldValue)) {
531
+ this[delegatedPropSymbol] = value;
532
+ this._enqueueRender();
533
+ }
534
+ },
535
+ enumerable: true
536
+ });
537
+ return;
538
+ }
539
+ this._observedAttributes.add(attr);
540
+ Object.defineProperty(this.prototype, name, {
541
+ get() {
542
+ return options.converter.fromAttribute(this.getAttribute(attr), options.type);
543
+ },
544
+ set(value) {
545
+ var oldValue = this[name];
546
+ if (options.hasChanged(value, oldValue)) {
547
+ var attrValue = options.converter.toAttribute(value, options.type);
548
+ if (attrValue === undefined) {
549
+ return;
550
+ }
551
+ if (attrValue === null) {
552
+ this.removeAttribute(attr);
553
+ } else {
554
+ this.setAttribute(attr, attrValue);
555
+ }
556
+ }
557
+ },
558
+ enumerable: true
559
+ });
560
+ }
561
+
562
+ /** @internal */
563
+ static createMethod(name) {
564
+ this._ensureDefinedMethods();
565
+ this.__dev_only_definedMethods.add(name);
566
+ }
567
+
568
+ /** @internal */
569
+ static createEventEmitter(name, options) {
570
+ this._ensureDefinedEvents();
571
+
572
+ // eslint-disable-next-line no-prototype-builtins
573
+ if (this.prototype.hasOwnProperty(name)) {
574
+ return;
575
+ }
576
+ var {
577
+ type
578
+ } = options,
579
+ eventInit = _objectWithoutProperties(options, _excluded);
580
+ this.__dev_only_definedEvents.add(type);
581
+
582
+ // Make event emitter readonly.
583
+ Object.defineProperty(this.prototype, name, {
584
+ get() {
585
+ return Object.freeze({
586
+ emit: detail => this.dispatchEvent(new CustomEvent(type, _objectSpread(_objectSpread({}, eventInit), {}, {
587
+ detail
588
+ })))
589
+ });
590
+ }
591
+ });
592
+ }
593
+
594
+ /**
595
+ * 当构件的属性改变时,将自动调用 `this._render()` 方法。
596
+ */
597
+ }
598
+ _defineProperty(UpdatingElement, "_observedAttributes", new Set());
599
+ _defineProperty(UpdatingElement, "__dev_only_definedProperties", new Set());
600
+ _defineProperty(UpdatingElement, "__dev_only_definedMethods", new Set());
601
+ _defineProperty(UpdatingElement, "__dev_only_definedEvents", new Set());
602
+
603
+ export { UpdatingElement, localeValues$1 as antdLocaleEnUS, event, method, property };
604
+ //# sourceMappingURL=index.esm.js.map