ts-glitter 17.8.1 → 17.8.2

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/lowcode/Entry.js CHANGED
@@ -89,7 +89,7 @@ export class Entry {
89
89
  }
90
90
  window.renderClock = (_b = window.renderClock) !== null && _b !== void 0 ? _b : clockF();
91
91
  console.log(`Entry-time:`, window.renderClock.stop());
92
- glitter.share.editerVersion = 'V_17.8.1';
92
+ glitter.share.editerVersion = 'V_17.8.2';
93
93
  glitter.share.start = new Date();
94
94
  const vm = {
95
95
  appConfig: [],
package/lowcode/Entry.ts CHANGED
@@ -90,7 +90,7 @@ export class Entry {
90
90
  }
91
91
  (window as any).renderClock = (window as any).renderClock ?? clockF();
92
92
  console.log(`Entry-time:`, (window as any).renderClock.stop());
93
- glitter.share.editerVersion = 'V_17.8.1';
93
+ glitter.share.editerVersion = 'V_17.8.2';
94
94
  glitter.share.start = new Date();
95
95
  const vm: {
96
96
  appConfig: any;
@@ -1817,6 +1817,7 @@ export class ShoppingProductSetting {
1817
1817
  enterId: Tool.randomString(7),
1818
1818
  };
1819
1819
  let keyboard = '';
1820
+ let saveKeyEvent = undefined;
1820
1821
  return html `
1821
1822
  <div class="bg-white w-100">
1822
1823
  ${[
@@ -1835,10 +1836,11 @@ export class ShoppingProductSetting {
1835
1836
  })}"
1836
1837
  />
1837
1838
  </div>`,
1838
- gvc.bindView({
1839
- bind: vm.viewId,
1840
- view: () => {
1841
- return html `
1839
+ gvc.bindView(() => {
1840
+ return {
1841
+ bind: vm.viewId,
1842
+ view: () => {
1843
+ return html `
1842
1844
  <div class="w-100" style="background-color:white !important;margin-top: 8px;">選項
1843
1845
  (輸入完請按enter)
1844
1846
  </div>
@@ -1849,9 +1851,9 @@ export class ShoppingProductSetting {
1849
1851
  <div class="d-flex align-items-center"
1850
1852
  style="gap: 10px; flex-wrap: wrap;background-color:white !important;">
1851
1853
  ${(() => {
1852
- const tempHTML = [];
1853
- temp.option.map((data, index) => {
1854
- tempHTML.push(html `
1854
+ const tempHTML = [];
1855
+ temp.option.map((data, index) => {
1856
+ tempHTML.push(html `
1855
1857
  <div
1856
1858
  class="d-flex align-items-center"
1857
1859
  style="height: 24px;border-radius: 5px;background: #F2F2F2;display: flex;padding: 1px 6px;justify-content: center;align-items: center;gap: 4px;"
@@ -1860,76 +1862,87 @@ export class ShoppingProductSetting {
1860
1862
  class="fa-solid fa-xmark ms-1 fs-5"
1861
1863
  style="font-size: 12px;cursor: pointer;"
1862
1864
  onclick="${gvc.event(() => {
1863
- temp.option.splice(index, 1);
1864
- gvc.notifyDataChange(vm.viewId);
1865
- })}"
1865
+ temp.option.splice(index, 1);
1866
+ gvc.notifyDataChange(vm.viewId);
1867
+ })}"
1866
1868
  ></i>
1867
1869
  </div>
1868
1870
  `);
1869
- });
1870
- tempHTML.push(html `<input
1871
+ });
1872
+ tempHTML.push(html `<input
1871
1873
  id="${vm.enterId}"
1872
1874
  class="flex-fill d-flex align-items-center border specInput-${vm.enterId} h-100 p-2"
1873
1875
  value=""
1874
1876
  style="background-color:white !important;"
1875
1877
  placeholder="${temp.option.length > 0 ? '請繼續輸入' : ''}"
1876
1878
  />`);
1877
- return tempHTML.join('');
1878
- })()}
1879
+ return tempHTML.join('');
1880
+ })()}
1879
1881
  </div>
1880
1882
  <div
1881
1883
  class="d-flex align-items-center ${temp.option.length > 0 ? 'd-none' : ''} ps-2"
1882
1884
  style="color: #8D8D8D;width: 100%;height:100%;position: absolute;left: 18px;top: 0;"
1883
1885
  onclick="${gvc.event((e) => {
1884
- e.classList.add('d-none');
1885
- setTimeout(() => {
1886
- document.querySelector(`.specInput-${vm.enterId}`).focus();
1887
- }, 100);
1888
- })}"
1886
+ e.classList.add('d-none');
1887
+ setTimeout(() => {
1888
+ document.querySelector(`.specInput-${vm.enterId}`).focus();
1889
+ }, 100);
1890
+ })}"
1889
1891
  >
1890
1892
  例如 : 黑色、S號
1891
1893
  </div>
1892
1894
  </div>
1893
1895
  `;
1894
- },
1895
- divCreate: {
1896
- class: 'w-100 bg-white',
1897
- style: 'display: flex;gap: 8px;flex-direction: column;',
1898
- },
1899
- onCreate: () => {
1900
- var _b;
1901
- let enterPass = true;
1902
- const inputElement = document.getElementById(vm.enterId);
1903
- gvc.glitter.share.keyDownEvent = (_b = gvc.glitter.share.keyDownEvent) !== null && _b !== void 0 ? _b : {};
1904
- keyboard === 'Enter' && inputElement && inputElement.focus();
1905
- inputElement.addEventListener('compositionupdate', function () {
1906
- enterPass = false;
1907
- });
1908
- inputElement.addEventListener('compositionend', function () {
1909
- enterPass = true;
1910
- });
1911
- document.removeEventListener('keydown', gvc.glitter.share.keyDownEvent[vm.enterId]);
1912
- gvc.glitter.share.keyDownEvent[vm.enterId] = (event) => {
1913
- keyboard = event.key;
1914
- if (enterPass && inputElement && inputElement.value.length > 0 && event.key === 'Enter') {
1915
- setTimeout(() => {
1916
- temp.option.push({
1917
- title: inputElement.value,
1918
- });
1919
- inputElement.value = '';
1920
- temp.option = temp.option.reduce((acc, current) => {
1921
- const isTitleExist = acc.find((item) => item.title === current.title);
1922
- if (!isTitleExist) {
1923
- acc.push(current);
1896
+ },
1897
+ divCreate: {
1898
+ class: 'w-100 bg-white',
1899
+ style: 'display: flex;gap: 8px;flex-direction: column;',
1900
+ },
1901
+ onCreate: () => {
1902
+ var _b;
1903
+ let enterPass = true;
1904
+ const inputElement = document.getElementById(vm.enterId);
1905
+ gvc.glitter.share.keyDownEvent = (_b = gvc.glitter.share.keyDownEvent) !== null && _b !== void 0 ? _b : {};
1906
+ keyboard === 'Enter' && inputElement && inputElement.focus();
1907
+ inputElement.addEventListener('compositionupdate', function () {
1908
+ enterPass = false;
1909
+ });
1910
+ inputElement.addEventListener('compositionend', function () {
1911
+ enterPass = true;
1912
+ });
1913
+ saveKeyEvent = () => {
1914
+ return new Promise((resolve, reject) => {
1915
+ setTimeout(() => {
1916
+ if (!inputElement.value) {
1917
+ resolve(true);
1918
+ return;
1924
1919
  }
1925
- return acc;
1926
- }, []);
1927
- gvc.notifyDataChange(vm.viewId);
1928
- }, 30);
1929
- }
1930
- };
1931
- document.addEventListener('keydown', gvc.glitter.share.keyDownEvent[vm.enterId]);
1932
- },
1920
+ temp.option.push({
1921
+ title: inputElement.value,
1922
+ });
1923
+ inputElement.value = '';
1924
+ temp.option = temp.option.reduce((acc, current) => {
1925
+ const isTitleExist = acc.find((item) => item.title === current.title);
1926
+ if (!isTitleExist) {
1927
+ acc.push(current);
1928
+ }
1929
+ return acc;
1930
+ }, []);
1931
+ resolve(true);
1932
+ gvc.notifyDataChange(vm.viewId);
1933
+ }, 30);
1934
+ });
1935
+ };
1936
+ document.removeEventListener('keydown', gvc.glitter.share.keyDownEvent[vm.enterId]);
1937
+ gvc.glitter.share.keyDownEvent[vm.enterId] = (event) => {
1938
+ keyboard = event.key;
1939
+ if (enterPass && inputElement && inputElement.value.length > 0 && event.key === 'Enter') {
1940
+ saveKeyEvent();
1941
+ }
1942
+ };
1943
+ document.addEventListener('keydown', gvc.glitter.share.keyDownEvent[vm.enterId]);
1944
+ },
1945
+ };
1933
1946
  }),
1934
1947
  html `
1935
1948
  <div class="d-flex w-100 justify-content-end align-items-center w-100 bg-white"
@@ -1938,7 +1951,9 @@ export class ShoppingProductSetting {
1938
1951
  cb.cancel();
1939
1952
  }))}
1940
1953
  ${BgWidget.save(gvc.event(() => {
1941
- cb.save();
1954
+ saveKeyEvent().then(() => {
1955
+ cb.save();
1956
+ });
1942
1957
  }), '完成')}
1943
1958
  </div>`,
1944
1959
  ].join('')}
@@ -2074,6 +2074,7 @@ export class ShoppingProductSetting {
2074
2074
  enterId: Tool.randomString(7),
2075
2075
  };
2076
2076
  let keyboard = '';
2077
+ let saveKeyEvent:any=undefined
2077
2078
  return html`
2078
2079
  <div class="bg-white w-100">
2079
2080
  ${[
@@ -2091,10 +2092,13 @@ export class ShoppingProductSetting {
2091
2092
  })}"
2092
2093
  />
2093
2094
  </div>`,
2094
- gvc.bindView({
2095
- bind: vm.viewId,
2096
- view: () => {
2097
- return html`
2095
+ gvc.bindView(
2096
+ ()=>{
2097
+
2098
+ return {
2099
+ bind: vm.viewId,
2100
+ view: () => {
2101
+ return html`
2098
2102
  <div class="w-100" style="background-color:white !important;margin-top: 8px;">選項
2099
2103
  (輸入完請按enter)
2100
2104
  </div>
@@ -2117,9 +2121,9 @@ export class ShoppingProductSetting {
2117
2121
  class="fa-solid fa-xmark ms-1 fs-5"
2118
2122
  style="font-size: 12px;cursor: pointer;"
2119
2123
  onclick="${gvc.event(() => {
2120
- temp.option.splice(index, 1);
2121
- gvc.notifyDataChange(vm.viewId);
2122
- })}"
2124
+ temp.option.splice(index, 1);
2125
+ gvc.notifyDataChange(vm.viewId);
2126
+ })}"
2123
2127
  ></i>
2124
2128
  </div>
2125
2129
  `
@@ -2139,69 +2143,82 @@ export class ShoppingProductSetting {
2139
2143
  class="d-flex align-items-center ${temp.option.length > 0 ? 'd-none' : ''} ps-2"
2140
2144
  style="color: #8D8D8D;width: 100%;height:100%;position: absolute;left: 18px;top: 0;"
2141
2145
  onclick="${gvc.event((e) => {
2142
- e.classList.add('d-none');
2143
- setTimeout(() => {
2144
- (document.querySelector(`.specInput-${vm.enterId}`) as HTMLButtonElement)!.focus();
2145
- }, 100);
2146
- })}"
2146
+ e.classList.add('d-none');
2147
+ setTimeout(() => {
2148
+ (document.querySelector(`.specInput-${vm.enterId}`) as HTMLButtonElement)!.focus();
2149
+ }, 100);
2150
+ })}"
2147
2151
  >
2148
2152
  例如 : 黑色、S號
2149
2153
  </div>
2150
2154
  </div>
2151
2155
  `;
2152
- },
2153
- divCreate: {
2154
- class: 'w-100 bg-white',
2155
- style: 'display: flex;gap: 8px;flex-direction: column;',
2156
- },
2157
- onCreate: () => {
2158
- let enterPass = true;
2159
- const inputElement = document.getElementById(vm.enterId) as any;
2160
- gvc.glitter.share.keyDownEvent = gvc.glitter.share.keyDownEvent ?? {};
2161
-
2162
- keyboard === 'Enter' && inputElement && inputElement.focus();
2163
-
2164
- inputElement.addEventListener('compositionupdate', function () {
2165
- enterPass = false;
2166
- });
2156
+ },
2157
+ divCreate: {
2158
+ class: 'w-100 bg-white',
2159
+ style: 'display: flex;gap: 8px;flex-direction: column;',
2160
+ },
2161
+ onCreate: () => {
2162
+ let enterPass = true;
2163
+ const inputElement = document.getElementById(vm.enterId) as any;
2164
+ gvc.glitter.share.keyDownEvent = gvc.glitter.share.keyDownEvent ?? {};
2167
2165
 
2168
- inputElement.addEventListener('compositionend', function () {
2169
- enterPass = true;
2170
- });
2166
+ keyboard === 'Enter' && inputElement && inputElement.focus();
2171
2167
 
2172
- document.removeEventListener('keydown', gvc.glitter.share.keyDownEvent[vm.enterId]);
2168
+ inputElement.addEventListener('compositionupdate', function () {
2169
+ enterPass = false;
2170
+ });
2173
2171
 
2174
- gvc.glitter.share.keyDownEvent[vm.enterId] = (event: any) => {
2175
- keyboard = event.key;
2176
- if (enterPass && inputElement && inputElement.value.length > 0 && event.key === 'Enter') {
2177
- setTimeout(() => {
2178
- temp.option.push({
2179
- title: inputElement.value,
2172
+ inputElement.addEventListener('compositionend', function () {
2173
+ enterPass = true;
2180
2174
  });
2181
- inputElement.value = '';
2182
- temp.option = temp.option.reduce(
2183
- (
2184
- acc: { title: string }[],
2185
- current: {
2186
- title: string;
2187
- }
2188
- ) => {
2189
- const isTitleExist = acc.find((item) => item.title === current.title);
2190
- if (!isTitleExist) {
2191
- acc.push(current);
2175
+
2176
+ saveKeyEvent=()=>{
2177
+ return new Promise((resolve, reject)=>{
2178
+ setTimeout(() => {
2179
+ if(!inputElement.value){
2180
+ resolve(true);
2181
+ return
2192
2182
  }
2193
- return acc;
2194
- },
2195
- []
2196
- );
2197
- gvc.notifyDataChange(vm.viewId);
2198
- }, 30);
2199
- }
2200
- };
2183
+ temp.option.push({
2184
+ title: inputElement.value,
2185
+ });
2186
+ inputElement.value = '';
2187
+ temp.option = temp.option.reduce(
2188
+ (
2189
+ acc: { title: string }[],
2190
+ current: {
2191
+ title: string;
2192
+ }
2193
+ ) => {
2194
+ const isTitleExist = acc.find((item) => item.title === current.title);
2195
+ if (!isTitleExist) {
2196
+ acc.push(current);
2197
+ }
2198
+ return acc;
2199
+ },
2200
+ []
2201
+ );
2202
+ resolve(true)
2203
+ gvc.notifyDataChange(vm.viewId);
2204
+ }, 30);
2205
+ })
2206
+
2207
+ }
2208
+ document.removeEventListener('keydown', gvc.glitter.share.keyDownEvent[vm.enterId]);
2209
+
2210
+
2211
+ gvc.glitter.share.keyDownEvent[vm.enterId] = (event: any) => {
2212
+ keyboard = event.key;
2213
+ if (enterPass && inputElement && inputElement.value.length > 0 && event.key === 'Enter') {
2214
+ saveKeyEvent()
2215
+ }
2216
+ };
2201
2217
 
2202
- document.addEventListener('keydown', gvc.glitter.share.keyDownEvent[vm.enterId]);
2203
- },
2204
- }),
2218
+ document.addEventListener('keydown', gvc.glitter.share.keyDownEvent[vm.enterId]);
2219
+ },
2220
+ }
2221
+ }),
2205
2222
  html`
2206
2223
  <div class="d-flex w-100 justify-content-end align-items-center w-100 bg-white"
2207
2224
  style="gap:14px; margin-top: 12px;">
@@ -2212,7 +2229,9 @@ export class ShoppingProductSetting {
2212
2229
  )}
2213
2230
  ${BgWidget.save(
2214
2231
  gvc.event(() => {
2215
- cb.save();
2232
+ saveKeyEvent().then(()=>{
2233
+ cb.save();
2234
+ });
2216
2235
  }),
2217
2236
  '完成'
2218
2237
  )}
@@ -21,7 +21,11 @@ export class ShoppingSettingAdvance {
21
21
  const vm = obj.vm2;
22
22
  const shipment_config = obj.shipment_config;
23
23
  const variantsViewID = gvc.glitter.getUUID();
24
+ const start = gvc.glitter.ut.clock();
24
25
  function updateVariants() {
26
+ postMD.specs = postMD.specs.filter((dd) => {
27
+ return dd.option && dd.option.length;
28
+ });
25
29
  const specs = {};
26
30
  function getCombinations(specs) {
27
31
  const keys = Object.keys(specs);
@@ -132,6 +136,8 @@ export class ShoppingSettingAdvance {
132
136
  return dd;
133
137
  });
134
138
  obj.vm.replaceData = postMD;
139
+ console.log(`end-time`, start.stop());
140
+ console.log(`postMD.variants=>`, postMD.variants);
135
141
  obj.gvc.notifyDataChange(variantsViewID);
136
142
  }
137
143
  updateVariants();
@@ -28,8 +28,11 @@ export class ShoppingSettingAdvance {
28
28
  const vm = obj.vm2;
29
29
  const shipment_config = obj.shipment_config;
30
30
  const variantsViewID = gvc.glitter.getUUID();
31
-
31
+ const start = gvc.glitter.ut.clock()
32
32
  function updateVariants() {
33
+ postMD.specs=postMD.specs.filter((dd)=>{
34
+ return dd.option && dd.option.length
35
+ })
33
36
  const specs: any = {};
34
37
 
35
38
  function getCombinations(specs: any) {
@@ -148,6 +151,16 @@ export class ShoppingSettingAdvance {
148
151
  return dd;
149
152
  });
150
153
  obj.vm.replaceData = postMD;
154
+ console.log(`end-time`, start.stop())
155
+ console.log(`postMD.variants=>`,postMD.variants)
156
+ // if((postMD.specs.length) && postMD.variants.length===1){
157
+ // postMD.specs=[]
158
+ // const dialog=new ShareDialog(gvc.glitter)
159
+ // dialog.errorMessage({
160
+ // text:'設定規格必須包含兩種以上的組合!'
161
+ // })
162
+ // return
163
+ // }
151
164
  obj.gvc.notifyDataChange(variantsViewID);
152
165
  }
153
166
 
@@ -35,7 +35,9 @@ export class ShoppingSettingBasic {
35
35
  }
36
36
  const start = gvc.glitter.ut.clock();
37
37
  function updateVariants() {
38
- console.log(`start-time`, start.stop());
38
+ postMD.specs = postMD.specs.filter((dd) => {
39
+ return dd.option && dd.option.length;
40
+ });
39
41
  const specs = {};
40
42
  function getCombinations(specs) {
41
43
  const keys = Object.keys(specs);
@@ -47,7 +47,9 @@ export class ShoppingSettingBasic {
47
47
  const start = gvc.glitter.ut.clock()
48
48
 
49
49
  function updateVariants() {
50
- console.log(`start-time`, start.stop())
50
+ postMD.specs=postMD.specs.filter((dd)=>{
51
+ return dd.option && dd.option.length
52
+ })
51
53
  const specs: any = {};
52
54
 
53
55
  function getCombinations(specs: any) {
@@ -168,6 +170,14 @@ export class ShoppingSettingBasic {
168
170
  obj.vm.replaceData = postMD;
169
171
  console.log(`end-time`, start.stop())
170
172
  console.log(`postMD.variants=>`,postMD.variants)
173
+ // if((postMD.specs.length) && postMD.variants.length===1){
174
+ // postMD.specs=[]
175
+ // const dialog=new ShareDialog(gvc.glitter)
176
+ // dialog.errorMessage({
177
+ // text:'設定規格必須包含兩種以上的組合!'
178
+ // })
179
+ // return
180
+ // }
171
181
  obj.gvc.notifyDataChange(variantsViewID);
172
182
  }
173
183
 
@@ -389,7 +389,7 @@ ${dd.title}</a></li>`;
389
389
  class="me-auto t_39_normal border-end px-4 d-none d-sm-flex align-items-center justify-content-center"
390
390
  style="height: 56px;cursor: pointer;"
391
391
  onclick="${gvc.event(() => {
392
- gvc.glitter.openNewTab('https://shopnex.tw/blog-home-page');
392
+ gvc.glitter.openNewTab('https://shopnex.tw/blogs');
393
393
  })}"
394
394
  >
395
395
  教學文章
@@ -388,7 +388,7 @@ ${dd.title}</a></li>`
388
388
  class="me-auto t_39_normal border-end px-4 d-none d-sm-flex align-items-center justify-content-center"
389
389
  style="height: 56px;cursor: pointer;"
390
390
  onclick="${gvc.event(() => {
391
- gvc.glitter.openNewTab('https://shopnex.tw/blog-home-page');
391
+ gvc.glitter.openNewTab('https://shopnex.tw/blogs');
392
392
  })}"
393
393
  >
394
394
  教學文章
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-glitter",
3
- "version": "17.8.1",
3
+ "version": "17.8.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {