@salla.sa/twilight-components 1.0.6 → 1.0.7

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 (65) hide show
  1. package/dist/cjs/{index-e9451c82.js → index-23da2c6b.js} +159 -4
  2. package/dist/cjs/index.cjs.js +3 -3
  3. package/dist/cjs/loader.cjs.js +2 -2
  4. package/dist/cjs/multi-warehouse_3.cjs.entry.js +155 -0
  5. package/dist/cjs/order-rating.cjs.entry.js +227 -0
  6. package/dist/cjs/salla-button.cjs.entry.js +56 -0
  7. package/dist/cjs/salla-localization.cjs.entry.js +49 -0
  8. package/dist/cjs/{salla-login-3ec94029.js → salla-login-476fb312.js} +1 -1
  9. package/dist/cjs/{salla-search-2b1d67e4.js → salla-search-b9403062.js} +7 -7
  10. package/dist/cjs/salla-search.cjs.entry.js +2 -2
  11. package/dist/cjs/twilight-components.cjs.js +2 -2
  12. package/dist/collection/collection-manifest.json +7 -4
  13. package/dist/collection/components/multi-warehouse/multi-warehouse.js +239 -0
  14. package/dist/collection/components/order-rating/order-rating.css +3 -0
  15. package/dist/collection/components/order-rating/order-rating.js +288 -0
  16. package/dist/collection/components/salla-button/salla-button.css +3 -0
  17. package/dist/collection/components/salla-button/salla-button.js +167 -0
  18. package/dist/collection/components/salla-localization/salla-localization.js +106 -0
  19. package/dist/collection/components/{login → salla-login}/salla-login.js +0 -0
  20. package/dist/collection/components/{modal → salla-modal}/salla-modal.js +115 -18
  21. package/dist/collection/components/{search → salla-search}/salla-search.js +21 -21
  22. package/dist/collection/index.js +2 -2
  23. package/dist/collection/plugins/tailwind-theme/generator.js +1 -1
  24. package/dist/esm/{index-8919a244.js → index-643344dc.js} +159 -4
  25. package/dist/esm/index.js +3 -3
  26. package/dist/esm/loader.js +2 -2
  27. package/dist/esm/multi-warehouse_3.entry.js +149 -0
  28. package/dist/esm/order-rating.entry.js +223 -0
  29. package/dist/esm/salla-button.entry.js +52 -0
  30. package/dist/esm/salla-localization.entry.js +45 -0
  31. package/dist/esm/{salla-login-4aa5bb90.js → salla-login-0e85b2d8.js} +1 -1
  32. package/dist/esm/{salla-search-bd2f71b3.js → salla-search-5d4a6f1a.js} +7 -7
  33. package/dist/esm/salla-search.entry.js +2 -2
  34. package/dist/esm/twilight-components.js +2 -2
  35. package/dist/twilight-components/index.esm.js +1 -1
  36. package/dist/twilight-components/{p-41dc89e6.js → p-36c87e2e.js} +1 -1
  37. package/dist/twilight-components/p-4b137380.js +1 -0
  38. package/dist/twilight-components/p-4cc11ee2.entry.js +1 -0
  39. package/dist/twilight-components/p-60f0446f.entry.js +1 -0
  40. package/dist/twilight-components/p-b490f9e0.entry.js +1 -0
  41. package/dist/twilight-components/p-b72e6cfa.entry.js +1 -0
  42. package/dist/twilight-components/p-baeca520.entry.js +1 -0
  43. package/dist/twilight-components/p-d1ef2268.js +1 -0
  44. package/dist/twilight-components/twilight-components.esm.js +1 -1
  45. package/dist/types/components/multi-warehouse/multi-warehouse.d.ts +23 -0
  46. package/dist/types/components/order-rating/order-rating.d.ts +16 -0
  47. package/dist/types/components/salla-button/salla-button.d.ts +15 -0
  48. package/dist/types/components/salla-localization/salla-localization.d.ts +10 -0
  49. package/dist/types/components/{login → salla-login}/salla-login.d.ts +0 -0
  50. package/dist/types/components/{modal → salla-modal}/salla-modal.d.ts +6 -2
  51. package/dist/types/components/{search → salla-search}/salla-search.d.ts +0 -0
  52. package/dist/types/components.d.ts +78 -11
  53. package/dist/types/index.d.ts +2 -2
  54. package/package.json +10 -6
  55. package/dist/cjs/salla-currency-language.cjs.entry.js +0 -46
  56. package/dist/cjs/salla-login_2.cjs.entry.js +0 -57
  57. package/dist/collection/components/currency-language/salla-currency-language.js +0 -97
  58. package/dist/esm/salla-currency-language.entry.js +0 -42
  59. package/dist/esm/salla-login_2.entry.js +0 -52
  60. package/dist/twilight-components/p-1abaafe4.entry.js +0 -1
  61. package/dist/twilight-components/p-58b1afae.js +0 -1
  62. package/dist/twilight-components/p-840f0daa.entry.js +0 -1
  63. package/dist/twilight-components/p-9f9af3e0.js +0 -1
  64. package/dist/twilight-components/p-b134c95d.entry.js +0 -1
  65. package/dist/types/components/currency-language/salla-currency-language.d.ts +0 -10
@@ -41,7 +41,17 @@ const plt = {
41
41
  ce: (eventName, opts) => new CustomEvent(eventName, opts),
42
42
  };
43
43
  const promiseResolve = (v) => Promise.resolve(v);
44
+ const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
45
+ try {
46
+ new CSSStyleSheet();
47
+ return typeof new CSSStyleSheet().replace === 'function';
48
+ }
49
+ catch (e) { }
50
+ return false;
51
+ })()
52
+ ;
44
53
  const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
54
+ const XLINK_NS = 'http://www.w3.org/1999/xlink';
45
55
  const createTime = (fnName, tagName = '') => {
46
56
  {
47
57
  return () => {
@@ -56,6 +66,59 @@ const uniqueTime = (key, measureText) => {
56
66
  };
57
67
  }
58
68
  };
69
+ const rootAppliedStyles = new WeakMap();
70
+ const registerStyle = (scopeId, cssText, allowCS) => {
71
+ let style = styles.get(scopeId);
72
+ if (supportsConstructibleStylesheets && allowCS) {
73
+ style = (style || new CSSStyleSheet());
74
+ style.replace(cssText);
75
+ }
76
+ else {
77
+ style = cssText;
78
+ }
79
+ styles.set(scopeId, style);
80
+ };
81
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
82
+ let scopeId = getScopeId(cmpMeta);
83
+ let style = styles.get(scopeId);
84
+ // if an element is NOT connected then getRootNode() will return the wrong root node
85
+ // so the fallback is to always use the document for the root node in those cases
86
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
87
+ if (style) {
88
+ if (typeof style === 'string') {
89
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
90
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
91
+ let styleElm;
92
+ if (!appliedStyles) {
93
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
94
+ }
95
+ if (!appliedStyles.has(scopeId)) {
96
+ {
97
+ {
98
+ styleElm = doc.createElement('style');
99
+ styleElm.innerHTML = style;
100
+ }
101
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
102
+ }
103
+ if (appliedStyles) {
104
+ appliedStyles.add(scopeId);
105
+ }
106
+ }
107
+ }
108
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
109
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
110
+ }
111
+ }
112
+ return scopeId;
113
+ };
114
+ const attachStyles = (hostRef) => {
115
+ const cmpMeta = hostRef.$cmpMeta$;
116
+ const elm = hostRef.$hostElement$;
117
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
118
+ addStyle(elm.getRootNode(), cmpMeta);
119
+ endAttachStyles();
120
+ };
121
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
59
122
  /**
60
123
  * Default style mode id
61
124
  */
@@ -82,6 +145,7 @@ const isComplexType = (o) => {
82
145
  // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
83
146
  const h = (nodeName, vnodeData, ...children) => {
84
147
  let child = null;
148
+ let key = null;
85
149
  let slotName = null;
86
150
  let simple = false;
87
151
  let lastSimple = false;
@@ -110,6 +174,10 @@ const h = (nodeName, vnodeData, ...children) => {
110
174
  };
111
175
  walk(children);
112
176
  if (vnodeData) {
177
+ // normalize class / classname attributes
178
+ if (vnodeData.key) {
179
+ key = vnodeData.key;
180
+ }
113
181
  if (vnodeData.name) {
114
182
  slotName = vnodeData.name;
115
183
  }
@@ -130,6 +198,9 @@ const h = (nodeName, vnodeData, ...children) => {
130
198
  if (vNodeChildren.length > 0) {
131
199
  vnode.$children$ = vNodeChildren;
132
200
  }
201
+ {
202
+ vnode.$key$ = key;
203
+ }
133
204
  {
134
205
  vnode.$name$ = slotName;
135
206
  }
@@ -146,6 +217,9 @@ const newVNode = (tag, text) => {
146
217
  {
147
218
  vnode.$attrs$ = null;
148
219
  }
220
+ {
221
+ vnode.$key$ = null;
222
+ }
149
223
  {
150
224
  vnode.$name$ = null;
151
225
  }
@@ -197,6 +271,14 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
197
271
  }
198
272
  }
199
273
  }
274
+ else if (memberName === 'key')
275
+ ;
276
+ else if (memberName === 'ref') {
277
+ // minifier will clean this up
278
+ if (newValue) {
279
+ newValue(elm);
280
+ }
281
+ }
200
282
  else if ((!isProp ) &&
201
283
  memberName[0] === 'o' &&
202
284
  memberName[1] === 'n') {
@@ -258,16 +340,36 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
258
340
  }
259
341
  catch (e) { }
260
342
  }
343
+ /**
344
+ * Need to manually update attribute if:
345
+ * - memberName is not an attribute
346
+ * - if we are rendering the host element in order to reflect attribute
347
+ * - if it's a SVG, since properties might not work in <svg>
348
+ * - if the newValue is null/undefined or 'false'.
349
+ */
350
+ let xlink = false;
351
+ {
352
+ if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
353
+ memberName = ln;
354
+ xlink = true;
355
+ }
356
+ }
261
357
  if (newValue == null || newValue === false) {
262
358
  if (newValue !== false || elm.getAttribute(memberName) === '') {
263
- {
359
+ if (xlink) {
360
+ elm.removeAttributeNS(XLINK_NS, memberName);
361
+ }
362
+ else {
264
363
  elm.removeAttribute(memberName);
265
364
  }
266
365
  }
267
366
  }
268
367
  else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
269
368
  newValue = newValue === true ? '' : newValue;
270
- {
369
+ if (xlink) {
370
+ elm.setAttributeNS(XLINK_NS, memberName, newValue);
371
+ }
372
+ else {
271
373
  elm.setAttribute(memberName, newValue);
272
374
  }
273
375
  }
@@ -407,6 +509,7 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
407
509
  for (; startIdx <= endIdx; ++startIdx) {
408
510
  if ((vnode = vnodes[startIdx])) {
409
511
  elm = vnode.$elm$;
512
+ callNodeRefs(vnode);
410
513
  {
411
514
  // we're removing this element
412
515
  // so it's possible we need to show slot fallback content now
@@ -429,6 +532,8 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
429
532
  const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
430
533
  let oldStartIdx = 0;
431
534
  let newStartIdx = 0;
535
+ let idxInOld = 0;
536
+ let i = 0;
432
537
  let oldEndIdx = oldCh.length - 1;
433
538
  let oldStartVnode = oldCh[0];
434
539
  let oldEndVnode = oldCh[oldEndIdx];
@@ -436,6 +541,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
436
541
  let newStartVnode = newCh[0];
437
542
  let newEndVnode = newCh[newEndIdx];
438
543
  let node;
544
+ let elmToMove;
439
545
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
440
546
  if (oldStartVnode == null) {
441
547
  // Vnode might have been moved left
@@ -481,7 +587,29 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
481
587
  newStartVnode = newCh[++newStartIdx];
482
588
  }
483
589
  else {
590
+ // createKeyToOldIdx
591
+ idxInOld = -1;
484
592
  {
593
+ for (i = oldStartIdx; i <= oldEndIdx; ++i) {
594
+ if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
595
+ idxInOld = i;
596
+ break;
597
+ }
598
+ }
599
+ }
600
+ if (idxInOld >= 0) {
601
+ elmToMove = oldCh[idxInOld];
602
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) {
603
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
604
+ }
605
+ else {
606
+ patch(elmToMove, newStartVnode);
607
+ oldCh[idxInOld] = undefined;
608
+ node = elmToMove.$elm$;
609
+ }
610
+ newStartVnode = newCh[++newStartIdx];
611
+ }
612
+ else {
485
613
  // new element
486
614
  node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
487
615
  newStartVnode = newCh[++newStartIdx];
@@ -507,7 +635,9 @@ const isSameVnode = (vnode1, vnode2) => {
507
635
  if (vnode1.$tag$ === 'slot') {
508
636
  return vnode1.$name$ === vnode2.$name$;
509
637
  }
510
- return true;
638
+ {
639
+ return vnode1.$key$ === vnode2.$key$;
640
+ }
511
641
  }
512
642
  return false;
513
643
  };
@@ -697,6 +827,12 @@ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
697
827
  }
698
828
  return slotNameAttr === '';
699
829
  };
830
+ const callNodeRefs = (vNode) => {
831
+ {
832
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
833
+ vNode.$children$ && vNode.$children$.map(callNodeRefs);
834
+ }
835
+ };
700
836
  const renderVdom = (hostRef, renderFnResults) => {
701
837
  const hostElm = hostRef.$hostElement$;
702
838
  const cmpMeta = hostRef.$cmpMeta$;
@@ -852,13 +988,17 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
852
988
  }
853
989
  }
854
990
  endSchedule();
855
- return then(promise, () => updateComponent(hostRef, instance));
991
+ return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
856
992
  };
857
993
  const updateComponent = async (hostRef, instance, isInitialLoad) => {
858
994
  // updateComponent
859
995
  const elm = hostRef.$hostElement$;
860
996
  const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
861
997
  const rc = elm['s-rc'];
998
+ if (isInitialLoad) {
999
+ // DOM WRITE!
1000
+ attachStyles(hostRef);
1001
+ }
862
1002
  const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
863
1003
  {
864
1004
  callRender(hostRef, instance);
@@ -987,6 +1127,10 @@ const parsePropertyValue = (propValue, propType) => {
987
1127
  // but we'll cheat here and say that the string "false" is the boolean false
988
1128
  return propValue === 'false' ? false : propValue === '' || !!propValue;
989
1129
  }
1130
+ if (propType & 2 /* Number */) {
1131
+ // force it to be a number
1132
+ return parseFloat(propValue);
1133
+ }
990
1134
  if (propType & 1 /* String */) {
991
1135
  // could have been passed as a number or boolean
992
1136
  // but we still want it as a string
@@ -1187,6 +1331,16 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1187
1331
  }
1188
1332
  endNewInstance();
1189
1333
  }
1334
+ if (Cstr.style) {
1335
+ // this component has styles but we haven't registered them yet
1336
+ let style = Cstr.style;
1337
+ const scopeId = getScopeId(cmpMeta);
1338
+ if (!styles.has(scopeId)) {
1339
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1340
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1341
+ endRegisterStyles();
1342
+ }
1343
+ }
1190
1344
  }
1191
1345
  // we've successfully created a lazy instance
1192
1346
  const ancestorComponent = hostRef.$ancestorComponent$;
@@ -1394,6 +1548,7 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1394
1548
  return importedModule[exportName];
1395
1549
  }, consoleError);
1396
1550
  };
1551
+ const styles = new Map();
1397
1552
  const queueDomReads = [];
1398
1553
  const queueDomWrites = [];
1399
1554
  const queueTask = (queue, write) => (cb) => {
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const sallaLogin = require('./salla-login-3ec94029.js');
6
- const sallaSearch = require('./salla-search-2b1d67e4.js');
7
- require('./index-e9451c82.js');
5
+ const sallaLogin = require('./salla-login-476fb312.js');
6
+ const sallaSearch = require('./salla-search-b9403062.js');
7
+ require('./index-23da2c6b.js');
8
8
 
9
9
 
10
10
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-e9451c82.js');
5
+ const index = require('./index-23da2c6b.js');
6
6
 
7
7
  /*
8
8
  Stencil Client Patch Esm v2.8.1 | MIT Licensed | https://stenciljs.com
@@ -14,7 +14,7 @@ const patchEsm = () => {
14
14
  const defineCustomElements = (win, options) => {
15
15
  if (typeof window === 'undefined') return Promise.resolve();
16
16
  return patchEsm().then(() => {
17
- return index.bootstrapLazy([["salla-login_2.cjs",[[0,"salla-login"],[4,"salla-modal",{"error":[4],"success":[4],"visible":[516],"subTitle":[1,"sub-title"],"icon":[1]}]]],["salla-currency-language.cjs",[[4,"salla-currency-language",{"show":[64],"hide":[64]}]]],["salla-search.cjs",[[4,"salla-search",{"searchPlaceholder":[1,"search-placeholder"],"noResultsText":[1,"no-results-text"],"searchTerm":[32],"results":[32],"fetchStatus":[32],"showResult":[32],"showModal":[32]}]]]], options);
17
+ return index.bootstrapLazy([["salla-localization.cjs",[[4,"salla-localization",{"show":[64],"hide":[64]}]]],["order-rating.cjs",[[0,"order-rating",{"order":[8]}]]],["salla-search.cjs",[[4,"salla-search",{"searchPlaceholder":[1,"search-placeholder"],"noResultsText":[1,"no-results-text"],"searchTerm":[32],"results":[32],"fetchStatus":[32],"showResult":[32],"showModal":[32]}]]],["salla-button.cjs",[[4,"salla-button",{"kind":[513],"loading":[516],"load":[64],"stop":[64],"disable":[64],"enable":[64]}]]],["multi-warehouse_3.cjs",[[4,"multi-warehouse",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}],[0,"salla-login"],[4,"salla-modal",{"error":[4],"success":[4],"isClosable":[1028,"is-closable"],"modalWidth":[1,"modal-width"],"visible":[516],"subTitle":[1,"sub-title"],"icon":[1],"show":[64],"hide":[64]}]]]], options);
18
18
  });
19
19
  };
20
20
 
@@ -0,0 +1,155 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-23da2c6b.js');
6
+ const sallaLogin = require('./salla-login-476fb312.js');
7
+ const Helper = require('./Helper-8c75b6ac.js');
8
+
9
+ // import Helper from "../../Helpers/Helper";
10
+ let engine = require('store/src/store-engine');
11
+ let storages = require('store/storages/sessionStorage');
12
+ let sessionStore = engine.createStore(storages);
13
+ const MultiWarehouse = class {
14
+ constructor(hostRef) {
15
+ index.registerInstance(this, hostRef);
16
+ this.open = false;
17
+ this.isOpenedBefore = sessionStore.get("multi-warehouse-opened-before");
18
+ this.displayAs = 'default';
19
+ this.browseProductsFrom = 'all';
20
+ this.branches = [
21
+ { id: 1, name: 'فرع الرياض', open: true, available: true, limited: false, tag: 'متوفر' },
22
+ { id: 2, name: 'فرع جدة', open: false, available: false, limited: false, tag: 'غير متوفر' },
23
+ { id: 3, name: 'فرع مكة', open: true, available: true, limited: false, tag: 'متوفر' },
24
+ { id: 4, name: 'فرع المدينة', open: true, available: true, limited: false, tag: 'متوفر' },
25
+ { id: 5, name: 'فرع جازان', open: true, available: true, limited: true, tag: 'الكمية محدودة' }
26
+ ];
27
+ this.current = 1;
28
+ this.currentBranch = (prop) => {
29
+ return this.branches.filter((el) => el.id == this.current)[0][prop];
30
+ };
31
+ this.statusColor = (branch = null) => {
32
+ return branch ?
33
+ branch.limited ? 'text-red-400' : branch.available ? 'text-green-500' : 'text-gray-400'
34
+ :
35
+ this.currentBranch('limited') ? 'text-red-400' : this.currentBranch('available') ? 'text-green-500' : 'text-gray-400';
36
+ };
37
+ this.isChoiceable = () => {
38
+ return (this.browseProductsFrom !== 'all' && this.position == 'single') || this.position == 'header';
39
+ };
40
+ this.formTitle = () => {
41
+ return this.isChoiceable() ?
42
+ 'توفر المنتج في الفروع الآخرى'
43
+ : 'التسوق من فرع آخر';
44
+ };
45
+ salla.event.on('branches::show', () => this.show());
46
+ }
47
+ async show() {
48
+ return this.modal.show();
49
+ }
50
+ async hide() {
51
+ return this.modal.hide();
52
+ }
53
+ handelChange(event) {
54
+ this.selected = event.target.value;
55
+ }
56
+ handleSubmit() {
57
+ sessionStore.set("multi-warehouse-opened-before", true);
58
+ this.show();
59
+ setTimeout(() => {
60
+ this.current = this.selected;
61
+ }, 300);
62
+ }
63
+ render() {
64
+ return (index.h("salla-modal", { "is-closable": !this.isOpenedBefore && this.displayAs == 'popup' ? 'false' : 'true', ref: modal => this.modal = modal, "modal-width": "w-116", id: "multi-warehouse-modal", class: "hidden" }, index.h("slot", { name: "header" }, index.h("div", { slot: "header" })), index.h("div", null, index.h("div", { class: "text-right" }, index.h("div", { class: "flex items-center mb-8" }, index.h("div", { class: "flex-shrink-0 sm:mb-0 me-4" }, index.h("div", { class: "h-16 w-16 border border-gray-200 bg-white text-primary rounded-full flex justify-center items-center" }, index.h("span", { class: "sicon-store-alt" }))), index.h("div", null, index.h("p", { class: "mt-1 text-xs text-gray-400" }, "\u0623\u0646\u062A \u0627\u0644\u0622\u0646 \u062A\u062A\u0635\u0641\u062D \u0627\u0644\u0645\u062A\u062C\u0631 \u0645\u0646"), index.h("h4", { class: "text-base" }, "\u0641\u0631\u0639 \u0627\u0644\u0631\u064A\u0627\u0636"))), index.h("fieldset", { class: "mt-4" }, index.h("h4", { class: "text-sm text-gray-600 mb-6" }, this.formTitle()), index.h("legend", { class: "sr-only" }, this.formTitle()), this.branches.length <= 5 ?
65
+ index.h("div", { class: "space-y-5" }, this.branches.map((branch) => index.h("div", { class: "flex items-center" }, index.h("input", { id: this.position + '_branch_' + branch.id, disabled: !branch.open && this.isChoiceable(), name: "lang", type: "radio", value: branch.id, onChange: (event) => this.handelChange(event), class: {
66
+ 'me-3 focus:ring-primary h-4 w-4 text-primary border-gray-300': true,
67
+ 'opacity-50': !branch.open,
68
+ 'hidden': !this.isChoiceable()
69
+ }, checked: this.current == branch.id }), index.h("label", { htmlFor: this.position + '_branch_' + branch.id, class: {
70
+ 'flex items-center justify-between text-sm font-medium text-gray-700 flex-grow': true,
71
+ 'cursor-pointer': this.isChoiceable()
72
+ } }, index.h("span", { class: { 'opacity-50': !branch.open } }, branch.name), this.isChoiceable() ?
73
+ index.h("small", { class: "text-red-400" }, branch.open ? '' : 'مُغلق')
74
+ :
75
+ index.h("span", { class: this.statusColor(branch) }, branch.tag)))))
76
+ :
77
+ index.h("select", { class: "w-full h-10 transition-colors duration-300 focus:ring-transparent focus:border-primary sm:text-sm border-gray-200 rounded-md appearance-none visibility_condition px-4", onInput: (event) => this.handelChange(event) }, this.branches.map(branch => (index.h("option", { value: branch.id, disabled: !branch.open, selected: this.selected == branch.id }, branch.name, " ", branch.open ? '' : '- مُغلق'))))))), this.isChoiceable() ?
78
+ index.h("p", { slot: "footer" }, index.h("slot", { name: "footer" }, index.h("button", { type: "button", class: "mt-8 w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-primary text-base font-medium text-white transition-colors hover:bg-primary-d focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary sm:col-start-2 sm:text-sm", onClick: () => this.handleSubmit() }, salla.lang.get('common.elements.ok'))))
79
+ : ''));
80
+ }
81
+ componentDidRender() {
82
+ }
83
+ get host() { return index.getElement(this); }
84
+ };
85
+
86
+ const SallaModal = class {
87
+ constructor(hostRef) {
88
+ index.registerInstance(this, hostRef);
89
+ this.ready = index.createEvent(this, "ready", 7);
90
+ this.close = index.createEvent(this, "close", 7);
91
+ this.error = false;
92
+ this.success = false;
93
+ this.isClosable = true;
94
+ this.modalWidth = 'w-96'; //todo use friendly names
95
+ this.visible = false;
96
+ this.subTitle = '';
97
+ this.icon = 'sicon-cancel';
98
+ salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.show());
99
+ salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.hide());
100
+ }
101
+ handleVisible(newValue) {
102
+ if (!newValue) {
103
+ this.toggleModal(false);
104
+ this.close.emit();
105
+ return;
106
+ }
107
+ this.host.classList.remove('hidden');
108
+ setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
109
+ this.ready.emit();
110
+ }
111
+ async show() {
112
+ this.host.setAttribute('visible', '');
113
+ return this.host;
114
+ }
115
+ async hide() {
116
+ this.host.removeAttribute('visible');
117
+ return this.host;
118
+ }
119
+ toggleModal(isOpen) {
120
+ Helper.Helper.toggleElement(this.host.querySelector('.s-modal-overlay'), 'ease-out duration-300 opacity-100', 'opacity-0', () => isOpen)
121
+ .toggleElement(this.host.querySelector('.s-modal-body'), 'ease-out duration-300 opacity-100 translate-y-0 sm:scale-100', //add these classes
122
+ 'opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95', //remove these classes
123
+ () => isOpen)
124
+ .toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
125
+ if (!isOpen) {
126
+ setTimeout(() => this.host.classList.add('hidden'), 350);
127
+ }
128
+ }
129
+ closeModal() {
130
+ if (!this.isClosable) {
131
+ return;
132
+ }
133
+ this.host.removeAttribute('visible');
134
+ }
135
+ render() {
136
+ this.host.id = this.host.id || 'salla-modal';
137
+ return (index.h(index.Host, { class: 's-modal-container hidden', "aria-modal": "true", role: "dialog" }, index.h("div", { class: "s-modal-wrapper" }, index.h("div", { class: "s-modal-overlay", onClick: () => this.closeModal() }), index.h("span", { class: "s-modal-spacer" }, "\u200B"), index.h("div", { class: 's-modal-body ' + this.modalWidth }, index.h("slot", { name: "header" }, index.h("div", { class: "s-modal-header" }, this.isClosable ?
138
+ index.h("button", { class: "s-modal-close cursor-pointer", onClick: () => this.closeModal(), type: "button" }, index.h("span", { class: "sicon-cancel" }))
139
+ : '', this.error || this.success
140
+ ? index.h("div", { class: { 's-modal-icon': true, 's-modal-bg-error': this.error, 's-modal-bg-success': this.success } }, index.h("i", { class: {
141
+ [this.icon]: true,
142
+ 's-modal-text-error': this.error,
143
+ 's-modal-text-success': this.success
144
+ } }))
145
+ : '', index.h("div", { class: "s-modal-title", innerHTML: this.host.title }), index.h("p", { class: "s-modal-sub-title", innerHTML: this.subTitle }))), index.h("slot", null), index.h("slot", { name: "footer" })))));
146
+ }
147
+ get host() { return index.getElement(this); }
148
+ static get watchers() { return {
149
+ "visible": ["handleVisible"]
150
+ }; }
151
+ };
152
+
153
+ exports.salla_login = sallaLogin.SallaLogin;
154
+ exports.multi_warehouse = MultiWarehouse;
155
+ exports.salla_modal = SallaModal;