clickgo 6.1.3 → 6.1.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clickgo",
3
- "version": "6.1.3",
3
+ "version": "6.1.5",
4
4
  "description": "Background interface, software interface, mobile phone APP interface operation library.",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -0,0 +1,70 @@
1
+ // Run: node test/form-native-style.mjs
2
+ import assert from 'node:assert/strict';
3
+ import { readFile } from 'node:fs/promises';
4
+ import { JSDOM } from 'jsdom';
5
+
6
+ const dom = new JSDOM('<!doctype html><html><head></head><body></body></html>');
7
+ for (const name of ['window', 'document', 'Element', 'SVGElement', 'Node', 'HTMLElement']) {
8
+ globalThis[name] = dom.window[name];
9
+ }
10
+ const { createApp, compile, nextTick } = await import('vue');
11
+ const template = await readFile(new URL('../dist/sources/control/form/layout.html', import.meta.url), 'utf8');
12
+ const render = compile(template);
13
+ const theme = document.createElement('style');
14
+ theme.textContent = `
15
+ .wrap { border: 3px solid black !important; border-radius: 24px !important; box-shadow: 0 0 8px black !important; }
16
+ .wrap > .inner, .wrap > .inner > .header, .wrap > .inner > .content { border-radius: 24px !important; }
17
+ .child-control { border: 1px solid blue; border-radius: 12px; }
18
+ `;
19
+ document.head.append(theme);
20
+
21
+ for (const nativeFirst of [true, false]) {
22
+ for (const border of ['normal', 'thin', 'plain', 'none']) {
23
+ const host = document.createElement('div');
24
+ document.body.append(host);
25
+ const app = createApp({
26
+ render,
27
+ data: () => ({
28
+ border, isNativeNoFrameFirst: nativeFirst, flashTimer: undefined,
29
+ stateMinData: false, stateMaxData: false, taskPosition: 'bottom',
30
+ isShow: true, isInside: false, formFocus: false, widthData: 500,
31
+ heightData: 400, leftData: 0, topData: 0, zIndex: 1,
32
+ isMask: false, isResize: false, iconDataUrl: '', title: 'Notepad',
33
+ isMin: true, isMax: true, isClose: true, direction: 'v',
34
+ background: '', padding: '', stepShowData: false, stepData: [],
35
+ stepValue: '', isLoading: false,
36
+ }),
37
+ methods: { moveMethod() {}, minMethod() {}, maxMethod() {}, closeMethod() {}, stepDown() {} },
38
+ });
39
+ app.component('cg-step', { render: () => null });
40
+ app.component('cg-loading', { render: () => null });
41
+ const form = app.mount(host);
42
+ const wrap = host.querySelector('.wrap');
43
+ const inner = host.querySelector('.inner');
44
+ const content = host.querySelector('.content');
45
+ const header = host.querySelector('.header');
46
+ assert.equal(Boolean(header), border === 'normal' || border === 'thin');
47
+ const child = document.createElement('div');
48
+ child.className = 'child-control';
49
+ content.append(child);
50
+ for (const focused of [false, true]) {
51
+ form.formFocus = focused;
52
+ form.stateMaxData = focused;
53
+ await nextTick();
54
+ for (const el of [wrap, inner, content, header].filter(Boolean)) {
55
+ assert.equal(el.style.getPropertyPriority('border-radius'), nativeFirst ? 'important' : '');
56
+ assert.equal(dom.window.getComputedStyle(el).borderRadius, nativeFirst ? '0' : '24px');
57
+ }
58
+ for (const property of ['border', 'box-shadow']) {
59
+ assert.equal(wrap.style.getPropertyPriority(property), nativeFirst ? 'important' : '');
60
+ }
61
+ assert.equal(dom.window.getComputedStyle(wrap).boxShadow, nativeFirst ? 'none' : '0 0 8px black');
62
+ assert.equal(dom.window.getComputedStyle(wrap).borderTopWidth, nativeFirst ? '0px' : '3px');
63
+ assert.equal(dom.window.getComputedStyle(child).borderRadius, '12px');
64
+ assert.equal(dom.window.getComputedStyle(child).borderTopWidth, '1px');
65
+ }
66
+ app.unmount();
67
+ host.remove();
68
+ }
69
+ }
70
+ console.log('Native first-Form styling, theme overrides and ordinary Form isolation checks passed.');
@@ -0,0 +1,68 @@
1
+ // Run after TypeScript compilation: node --experimental-vm-modules test/form-native.mjs
2
+ import assert from 'node:assert/strict';
3
+ import { readFile } from 'node:fs/promises';
4
+ import { SourceTextModule, SyntheticModule } from 'node:vm';
5
+
6
+ const listeners = {};
7
+ const minimums = [];
8
+ let ended = 0;
9
+ let cancelled = true;
10
+ class AbstractControl {
11
+ constructor() {
12
+ this.parent = { controlName: 'root', isNativeNoFrameFirst: true };
13
+ this.formId = 'form';
14
+ this.element = {};
15
+ this.watches = {};
16
+ }
17
+ watch(name, callback, options) {
18
+ this.watches[name] = callback;
19
+ if (options?.immediate) { callback(); }
20
+ }
21
+ propInt(name) { return parseInt(this.props[name]); }
22
+ propBoolean(name) { return Boolean(this.props[name]); }
23
+ emit(name, event) {
24
+ if (name === 'close') {
25
+ assert.equal(event.detail.event, null);
26
+ if (cancelled) { event.preventDefault(); }
27
+ }
28
+ }
29
+ }
30
+ const clickgo = new SyntheticModule(['control', 'native', 'dom', 'tool', 'task'], function() {
31
+ this.setExport('control', { AbstractControl });
32
+ this.setExport('native', {
33
+ on(current, name, handler) { listeners[name] = handler; },
34
+ async minSize(current, w, h) { minimums.push([w, h]); },
35
+ async maximizable() {},
36
+ });
37
+ this.setExport('dom', { watchSize() {} });
38
+ this.setExport('tool', { getBoolean: Boolean });
39
+ this.setExport('task', { async end() { ++ended; } });
40
+ });
41
+ const mod = new SourceTextModule(await readFile(new URL('../dist/sources/control/form/code.js', import.meta.url), 'utf8'));
42
+ await mod.link(() => clickgo);
43
+ await mod.evaluate();
44
+ const Form = mod.namespace.default;
45
+ const form = new Form();
46
+ form.onMounted();
47
+ assert.deepEqual(minimums.at(-1), [200, 100]);
48
+ form.props.minWidth = '360';
49
+ form.watches.minWidth();
50
+ assert.deepEqual(minimums.at(-1), [360, 100]);
51
+ form.props.minHeight = 240;
52
+ form.watches.minHeight();
53
+ assert.deepEqual(minimums.at(-1), [360, 240]);
54
+ listeners['close-request']();
55
+ assert.equal(ended, 0);
56
+ cancelled = false;
57
+ listeners['close-request']();
58
+ assert.equal(ended, 1);
59
+ form.props.close = false;
60
+ listeners['close-request']();
61
+ assert.equal(ended, 1);
62
+
63
+ const web = new Form();
64
+ web.parent.isNativeNoFrameFirst = false;
65
+ const before = minimums.length;
66
+ web.onMounted();
67
+ assert.equal(minimums.length, before);
68
+ console.log('Form native minimum-size and cancellable close-event checks passed.');