@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
@@ -19,7 +19,17 @@ const plt = {
19
19
  ce: (eventName, opts) => new CustomEvent(eventName, opts),
20
20
  };
21
21
  const promiseResolve = (v) => Promise.resolve(v);
22
+ const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
23
+ try {
24
+ new CSSStyleSheet();
25
+ return typeof new CSSStyleSheet().replace === 'function';
26
+ }
27
+ catch (e) { }
28
+ return false;
29
+ })()
30
+ ;
22
31
  const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
32
+ const XLINK_NS = 'http://www.w3.org/1999/xlink';
23
33
  const createTime = (fnName, tagName = '') => {
24
34
  {
25
35
  return () => {
@@ -34,6 +44,59 @@ const uniqueTime = (key, measureText) => {
34
44
  };
35
45
  }
36
46
  };
47
+ const rootAppliedStyles = new WeakMap();
48
+ const registerStyle = (scopeId, cssText, allowCS) => {
49
+ let style = styles.get(scopeId);
50
+ if (supportsConstructibleStylesheets && allowCS) {
51
+ style = (style || new CSSStyleSheet());
52
+ style.replace(cssText);
53
+ }
54
+ else {
55
+ style = cssText;
56
+ }
57
+ styles.set(scopeId, style);
58
+ };
59
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
60
+ let scopeId = getScopeId(cmpMeta);
61
+ let style = styles.get(scopeId);
62
+ // if an element is NOT connected then getRootNode() will return the wrong root node
63
+ // so the fallback is to always use the document for the root node in those cases
64
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
65
+ if (style) {
66
+ if (typeof style === 'string') {
67
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
68
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
69
+ let styleElm;
70
+ if (!appliedStyles) {
71
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
72
+ }
73
+ if (!appliedStyles.has(scopeId)) {
74
+ {
75
+ {
76
+ styleElm = doc.createElement('style');
77
+ styleElm.innerHTML = style;
78
+ }
79
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
80
+ }
81
+ if (appliedStyles) {
82
+ appliedStyles.add(scopeId);
83
+ }
84
+ }
85
+ }
86
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
87
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
88
+ }
89
+ }
90
+ return scopeId;
91
+ };
92
+ const attachStyles = (hostRef) => {
93
+ const cmpMeta = hostRef.$cmpMeta$;
94
+ const elm = hostRef.$hostElement$;
95
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
96
+ addStyle(elm.getRootNode(), cmpMeta);
97
+ endAttachStyles();
98
+ };
99
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
37
100
  /**
38
101
  * Default style mode id
39
102
  */
@@ -60,6 +123,7 @@ const isComplexType = (o) => {
60
123
  // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
61
124
  const h = (nodeName, vnodeData, ...children) => {
62
125
  let child = null;
126
+ let key = null;
63
127
  let slotName = null;
64
128
  let simple = false;
65
129
  let lastSimple = false;
@@ -88,6 +152,10 @@ const h = (nodeName, vnodeData, ...children) => {
88
152
  };
89
153
  walk(children);
90
154
  if (vnodeData) {
155
+ // normalize class / classname attributes
156
+ if (vnodeData.key) {
157
+ key = vnodeData.key;
158
+ }
91
159
  if (vnodeData.name) {
92
160
  slotName = vnodeData.name;
93
161
  }
@@ -108,6 +176,9 @@ const h = (nodeName, vnodeData, ...children) => {
108
176
  if (vNodeChildren.length > 0) {
109
177
  vnode.$children$ = vNodeChildren;
110
178
  }
179
+ {
180
+ vnode.$key$ = key;
181
+ }
111
182
  {
112
183
  vnode.$name$ = slotName;
113
184
  }
@@ -124,6 +195,9 @@ const newVNode = (tag, text) => {
124
195
  {
125
196
  vnode.$attrs$ = null;
126
197
  }
198
+ {
199
+ vnode.$key$ = null;
200
+ }
127
201
  {
128
202
  vnode.$name$ = null;
129
203
  }
@@ -175,6 +249,14 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
175
249
  }
176
250
  }
177
251
  }
252
+ else if (memberName === 'key')
253
+ ;
254
+ else if (memberName === 'ref') {
255
+ // minifier will clean this up
256
+ if (newValue) {
257
+ newValue(elm);
258
+ }
259
+ }
178
260
  else if ((!isProp ) &&
179
261
  memberName[0] === 'o' &&
180
262
  memberName[1] === 'n') {
@@ -236,16 +318,36 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
236
318
  }
237
319
  catch (e) { }
238
320
  }
321
+ /**
322
+ * Need to manually update attribute if:
323
+ * - memberName is not an attribute
324
+ * - if we are rendering the host element in order to reflect attribute
325
+ * - if it's a SVG, since properties might not work in <svg>
326
+ * - if the newValue is null/undefined or 'false'.
327
+ */
328
+ let xlink = false;
329
+ {
330
+ if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
331
+ memberName = ln;
332
+ xlink = true;
333
+ }
334
+ }
239
335
  if (newValue == null || newValue === false) {
240
336
  if (newValue !== false || elm.getAttribute(memberName) === '') {
241
- {
337
+ if (xlink) {
338
+ elm.removeAttributeNS(XLINK_NS, memberName);
339
+ }
340
+ else {
242
341
  elm.removeAttribute(memberName);
243
342
  }
244
343
  }
245
344
  }
246
345
  else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
247
346
  newValue = newValue === true ? '' : newValue;
248
- {
347
+ if (xlink) {
348
+ elm.setAttributeNS(XLINK_NS, memberName, newValue);
349
+ }
350
+ else {
249
351
  elm.setAttribute(memberName, newValue);
250
352
  }
251
353
  }
@@ -385,6 +487,7 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
385
487
  for (; startIdx <= endIdx; ++startIdx) {
386
488
  if ((vnode = vnodes[startIdx])) {
387
489
  elm = vnode.$elm$;
490
+ callNodeRefs(vnode);
388
491
  {
389
492
  // we're removing this element
390
493
  // so it's possible we need to show slot fallback content now
@@ -407,6 +510,8 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
407
510
  const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
408
511
  let oldStartIdx = 0;
409
512
  let newStartIdx = 0;
513
+ let idxInOld = 0;
514
+ let i = 0;
410
515
  let oldEndIdx = oldCh.length - 1;
411
516
  let oldStartVnode = oldCh[0];
412
517
  let oldEndVnode = oldCh[oldEndIdx];
@@ -414,6 +519,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
414
519
  let newStartVnode = newCh[0];
415
520
  let newEndVnode = newCh[newEndIdx];
416
521
  let node;
522
+ let elmToMove;
417
523
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
418
524
  if (oldStartVnode == null) {
419
525
  // Vnode might have been moved left
@@ -459,7 +565,29 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
459
565
  newStartVnode = newCh[++newStartIdx];
460
566
  }
461
567
  else {
568
+ // createKeyToOldIdx
569
+ idxInOld = -1;
462
570
  {
571
+ for (i = oldStartIdx; i <= oldEndIdx; ++i) {
572
+ if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
573
+ idxInOld = i;
574
+ break;
575
+ }
576
+ }
577
+ }
578
+ if (idxInOld >= 0) {
579
+ elmToMove = oldCh[idxInOld];
580
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) {
581
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
582
+ }
583
+ else {
584
+ patch(elmToMove, newStartVnode);
585
+ oldCh[idxInOld] = undefined;
586
+ node = elmToMove.$elm$;
587
+ }
588
+ newStartVnode = newCh[++newStartIdx];
589
+ }
590
+ else {
463
591
  // new element
464
592
  node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
465
593
  newStartVnode = newCh[++newStartIdx];
@@ -485,7 +613,9 @@ const isSameVnode = (vnode1, vnode2) => {
485
613
  if (vnode1.$tag$ === 'slot') {
486
614
  return vnode1.$name$ === vnode2.$name$;
487
615
  }
488
- return true;
616
+ {
617
+ return vnode1.$key$ === vnode2.$key$;
618
+ }
489
619
  }
490
620
  return false;
491
621
  };
@@ -675,6 +805,12 @@ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
675
805
  }
676
806
  return slotNameAttr === '';
677
807
  };
808
+ const callNodeRefs = (vNode) => {
809
+ {
810
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
811
+ vNode.$children$ && vNode.$children$.map(callNodeRefs);
812
+ }
813
+ };
678
814
  const renderVdom = (hostRef, renderFnResults) => {
679
815
  const hostElm = hostRef.$hostElement$;
680
816
  const cmpMeta = hostRef.$cmpMeta$;
@@ -830,13 +966,17 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
830
966
  }
831
967
  }
832
968
  endSchedule();
833
- return then(promise, () => updateComponent(hostRef, instance));
969
+ return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
834
970
  };
835
971
  const updateComponent = async (hostRef, instance, isInitialLoad) => {
836
972
  // updateComponent
837
973
  const elm = hostRef.$hostElement$;
838
974
  const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
839
975
  const rc = elm['s-rc'];
976
+ if (isInitialLoad) {
977
+ // DOM WRITE!
978
+ attachStyles(hostRef);
979
+ }
840
980
  const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
841
981
  {
842
982
  callRender(hostRef, instance);
@@ -965,6 +1105,10 @@ const parsePropertyValue = (propValue, propType) => {
965
1105
  // but we'll cheat here and say that the string "false" is the boolean false
966
1106
  return propValue === 'false' ? false : propValue === '' || !!propValue;
967
1107
  }
1108
+ if (propType & 2 /* Number */) {
1109
+ // force it to be a number
1110
+ return parseFloat(propValue);
1111
+ }
968
1112
  if (propType & 1 /* String */) {
969
1113
  // could have been passed as a number or boolean
970
1114
  // but we still want it as a string
@@ -1165,6 +1309,16 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1165
1309
  }
1166
1310
  endNewInstance();
1167
1311
  }
1312
+ if (Cstr.style) {
1313
+ // this component has styles but we haven't registered them yet
1314
+ let style = Cstr.style;
1315
+ const scopeId = getScopeId(cmpMeta);
1316
+ if (!styles.has(scopeId)) {
1317
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1318
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1319
+ endRegisterStyles();
1320
+ }
1321
+ }
1168
1322
  }
1169
1323
  // we've successfully created a lazy instance
1170
1324
  const ancestorComponent = hostRef.$ancestorComponent$;
@@ -1372,6 +1526,7 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1372
1526
  return importedModule[exportName];
1373
1527
  }, consoleError);
1374
1528
  };
1529
+ const styles = new Map();
1375
1530
  const queueDomReads = [];
1376
1531
  const queueDomWrites = [];
1377
1532
  const queueTask = (queue, write) => (cb) => {
package/dist/esm/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { S as SallaLogin } from './salla-login-4aa5bb90.js';
2
- export { S as SallaSearch } from './salla-search-bd2f71b3.js';
3
- import './index-8919a244.js';
1
+ export { S as SallaLogin } from './salla-login-0e85b2d8.js';
2
+ export { S as SallaSearch } from './salla-search-5d4a6f1a.js';
3
+ import './index-643344dc.js';
@@ -1,4 +1,4 @@
1
- import { p as promiseResolve, b as bootstrapLazy } from './index-8919a244.js';
1
+ import { p as promiseResolve, b as bootstrapLazy } from './index-643344dc.js';
2
2
 
3
3
  /*
4
4
  Stencil Client Patch Esm v2.8.1 | MIT Licensed | https://stenciljs.com
@@ -10,7 +10,7 @@ const patchEsm = () => {
10
10
  const defineCustomElements = (win, options) => {
11
11
  if (typeof window === 'undefined') return Promise.resolve();
12
12
  return patchEsm().then(() => {
13
- return bootstrapLazy([["salla-login_2",[[0,"salla-login"],[4,"salla-modal",{"error":[4],"success":[4],"visible":[516],"subTitle":[1,"sub-title"],"icon":[1]}]]],["salla-currency-language",[[4,"salla-currency-language",{"show":[64],"hide":[64]}]]],["salla-search",[[4,"salla-search",{"searchPlaceholder":[1,"search-placeholder"],"noResultsText":[1,"no-results-text"],"searchTerm":[32],"results":[32],"fetchStatus":[32],"showResult":[32],"showModal":[32]}]]]], options);
13
+ return bootstrapLazy([["salla-localization",[[4,"salla-localization",{"show":[64],"hide":[64]}]]],["order-rating",[[0,"order-rating",{"order":[8]}]]],["salla-search",[[4,"salla-search",{"searchPlaceholder":[1,"search-placeholder"],"noResultsText":[1,"no-results-text"],"searchTerm":[32],"results":[32],"fetchStatus":[32],"showResult":[32],"showModal":[32]}]]],["salla-button",[[4,"salla-button",{"kind":[513],"loading":[516],"load":[64],"stop":[64],"disable":[64],"enable":[64]}]]],["multi-warehouse_3",[[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);
14
14
  });
15
15
  };
16
16
 
@@ -0,0 +1,149 @@
1
+ import { r as registerInstance, h, g as getElement, c as createEvent, H as Host } from './index-643344dc.js';
2
+ export { S as salla_login } from './salla-login-0e85b2d8.js';
3
+ import { H as Helper } from './Helper-23b2de40.js';
4
+
5
+ // import Helper from "../../Helpers/Helper";
6
+ let engine = require('store/src/store-engine');
7
+ let storages = require('store/storages/sessionStorage');
8
+ let sessionStore = engine.createStore(storages);
9
+ const MultiWarehouse = class {
10
+ constructor(hostRef) {
11
+ registerInstance(this, hostRef);
12
+ this.open = false;
13
+ this.isOpenedBefore = sessionStore.get("multi-warehouse-opened-before");
14
+ this.displayAs = 'default';
15
+ this.browseProductsFrom = 'all';
16
+ this.branches = [
17
+ { id: 1, name: 'فرع الرياض', open: true, available: true, limited: false, tag: 'متوفر' },
18
+ { id: 2, name: 'فرع جدة', open: false, available: false, limited: false, tag: 'غير متوفر' },
19
+ { id: 3, name: 'فرع مكة', open: true, available: true, limited: false, tag: 'متوفر' },
20
+ { id: 4, name: 'فرع المدينة', open: true, available: true, limited: false, tag: 'متوفر' },
21
+ { id: 5, name: 'فرع جازان', open: true, available: true, limited: true, tag: 'الكمية محدودة' }
22
+ ];
23
+ this.current = 1;
24
+ this.currentBranch = (prop) => {
25
+ return this.branches.filter((el) => el.id == this.current)[0][prop];
26
+ };
27
+ this.statusColor = (branch = null) => {
28
+ return branch ?
29
+ branch.limited ? 'text-red-400' : branch.available ? 'text-green-500' : 'text-gray-400'
30
+ :
31
+ this.currentBranch('limited') ? 'text-red-400' : this.currentBranch('available') ? 'text-green-500' : 'text-gray-400';
32
+ };
33
+ this.isChoiceable = () => {
34
+ return (this.browseProductsFrom !== 'all' && this.position == 'single') || this.position == 'header';
35
+ };
36
+ this.formTitle = () => {
37
+ return this.isChoiceable() ?
38
+ 'توفر المنتج في الفروع الآخرى'
39
+ : 'التسوق من فرع آخر';
40
+ };
41
+ salla.event.on('branches::show', () => this.show());
42
+ }
43
+ async show() {
44
+ return this.modal.show();
45
+ }
46
+ async hide() {
47
+ return this.modal.hide();
48
+ }
49
+ handelChange(event) {
50
+ this.selected = event.target.value;
51
+ }
52
+ handleSubmit() {
53
+ sessionStore.set("multi-warehouse-opened-before", true);
54
+ this.show();
55
+ setTimeout(() => {
56
+ this.current = this.selected;
57
+ }, 300);
58
+ }
59
+ render() {
60
+ return (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" }, h("slot", { name: "header" }, h("div", { slot: "header" })), h("div", null, h("div", { class: "text-right" }, h("div", { class: "flex items-center mb-8" }, h("div", { class: "flex-shrink-0 sm:mb-0 me-4" }, h("div", { class: "h-16 w-16 border border-gray-200 bg-white text-primary rounded-full flex justify-center items-center" }, h("span", { class: "sicon-store-alt" }))), h("div", null, 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"), h("h4", { class: "text-base" }, "\u0641\u0631\u0639 \u0627\u0644\u0631\u064A\u0627\u0636"))), h("fieldset", { class: "mt-4" }, h("h4", { class: "text-sm text-gray-600 mb-6" }, this.formTitle()), h("legend", { class: "sr-only" }, this.formTitle()), this.branches.length <= 5 ?
61
+ h("div", { class: "space-y-5" }, this.branches.map((branch) => h("div", { class: "flex items-center" }, 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: {
62
+ 'me-3 focus:ring-primary h-4 w-4 text-primary border-gray-300': true,
63
+ 'opacity-50': !branch.open,
64
+ 'hidden': !this.isChoiceable()
65
+ }, checked: this.current == branch.id }), h("label", { htmlFor: this.position + '_branch_' + branch.id, class: {
66
+ 'flex items-center justify-between text-sm font-medium text-gray-700 flex-grow': true,
67
+ 'cursor-pointer': this.isChoiceable()
68
+ } }, h("span", { class: { 'opacity-50': !branch.open } }, branch.name), this.isChoiceable() ?
69
+ h("small", { class: "text-red-400" }, branch.open ? '' : 'مُغلق')
70
+ :
71
+ h("span", { class: this.statusColor(branch) }, branch.tag)))))
72
+ :
73
+ 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 => (h("option", { value: branch.id, disabled: !branch.open, selected: this.selected == branch.id }, branch.name, " ", branch.open ? '' : '- مُغلق'))))))), this.isChoiceable() ?
74
+ h("p", { slot: "footer" }, h("slot", { name: "footer" }, 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'))))
75
+ : ''));
76
+ }
77
+ componentDidRender() {
78
+ }
79
+ get host() { return getElement(this); }
80
+ };
81
+
82
+ const SallaModal = class {
83
+ constructor(hostRef) {
84
+ registerInstance(this, hostRef);
85
+ this.ready = createEvent(this, "ready", 7);
86
+ this.close = createEvent(this, "close", 7);
87
+ this.error = false;
88
+ this.success = false;
89
+ this.isClosable = true;
90
+ this.modalWidth = 'w-96'; //todo use friendly names
91
+ this.visible = false;
92
+ this.subTitle = '';
93
+ this.icon = 'sicon-cancel';
94
+ salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.show());
95
+ salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.hide());
96
+ }
97
+ handleVisible(newValue) {
98
+ if (!newValue) {
99
+ this.toggleModal(false);
100
+ this.close.emit();
101
+ return;
102
+ }
103
+ this.host.classList.remove('hidden');
104
+ setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
105
+ this.ready.emit();
106
+ }
107
+ async show() {
108
+ this.host.setAttribute('visible', '');
109
+ return this.host;
110
+ }
111
+ async hide() {
112
+ this.host.removeAttribute('visible');
113
+ return this.host;
114
+ }
115
+ toggleModal(isOpen) {
116
+ Helper.toggleElement(this.host.querySelector('.s-modal-overlay'), 'ease-out duration-300 opacity-100', 'opacity-0', () => isOpen)
117
+ .toggleElement(this.host.querySelector('.s-modal-body'), 'ease-out duration-300 opacity-100 translate-y-0 sm:scale-100', //add these classes
118
+ 'opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95', //remove these classes
119
+ () => isOpen)
120
+ .toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
121
+ if (!isOpen) {
122
+ setTimeout(() => this.host.classList.add('hidden'), 350);
123
+ }
124
+ }
125
+ closeModal() {
126
+ if (!this.isClosable) {
127
+ return;
128
+ }
129
+ this.host.removeAttribute('visible');
130
+ }
131
+ render() {
132
+ this.host.id = this.host.id || 'salla-modal';
133
+ return (h(Host, { class: 's-modal-container hidden', "aria-modal": "true", role: "dialog" }, h("div", { class: "s-modal-wrapper" }, h("div", { class: "s-modal-overlay", onClick: () => this.closeModal() }), h("span", { class: "s-modal-spacer" }, "\u200B"), h("div", { class: 's-modal-body ' + this.modalWidth }, h("slot", { name: "header" }, h("div", { class: "s-modal-header" }, this.isClosable ?
134
+ h("button", { class: "s-modal-close cursor-pointer", onClick: () => this.closeModal(), type: "button" }, h("span", { class: "sicon-cancel" }))
135
+ : '', this.error || this.success
136
+ ? h("div", { class: { 's-modal-icon': true, 's-modal-bg-error': this.error, 's-modal-bg-success': this.success } }, h("i", { class: {
137
+ [this.icon]: true,
138
+ 's-modal-text-error': this.error,
139
+ 's-modal-text-success': this.success
140
+ } }))
141
+ : '', h("div", { class: "s-modal-title", innerHTML: this.host.title }), h("p", { class: "s-modal-sub-title", innerHTML: this.subTitle }))), h("slot", null), h("slot", { name: "footer" })))));
142
+ }
143
+ get host() { return getElement(this); }
144
+ static get watchers() { return {
145
+ "visible": ["handleVisible"]
146
+ }; }
147
+ };
148
+
149
+ export { MultiWarehouse as multi_warehouse, SallaModal as salla_modal };