godown 2.6.0 → 2.6.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.
Files changed (133) hide show
  1. package/lib/directives.d.ts +2 -4
  2. package/lib/directives.d.ts.map +1 -1
  3. package/lib/directives.js.map +1 -1
  4. package/lib/event-collection.d.ts +1 -1
  5. package/lib/utils.d.ts +2 -0
  6. package/lib/utils.d.ts.map +1 -1
  7. package/lib/utils.js +11 -0
  8. package/lib/utils.js.map +1 -1
  9. package/package.json +4 -6
  10. package/react/index.d.ts +0 -3
  11. package/react/index.d.ts.map +1 -1
  12. package/react/index.js +0 -9
  13. package/react/index.js.map +1 -1
  14. package/root.d.ts.map +1 -1
  15. package/root.js +1 -0
  16. package/root.js.map +1 -1
  17. package/web-components/a/avatar-a.js +40 -40
  18. package/web-components/a/avatar-a.js.map +1 -1
  19. package/web-components/a/super-a.js +22 -22
  20. package/web-components/a/super-a.js.map +1 -1
  21. package/web-components/button/base-button.js +86 -86
  22. package/web-components/button/base-button.js.map +1 -1
  23. package/web-components/carousel/carousel-slider.d.ts +1 -1
  24. package/web-components/carousel/carousel-slider.d.ts.map +1 -1
  25. package/web-components/carousel/carousel-slider.js +70 -70
  26. package/web-components/carousel/carousel-slider.js.map +1 -1
  27. package/web-components/form/base-form.js +15 -15
  28. package/web-components/form/base-form.js.map +1 -1
  29. package/web-components/group/avatar-group.js +15 -15
  30. package/web-components/group/avatar-group.js.map +1 -1
  31. package/web-components/group/details-group.js +7 -7
  32. package/web-components/group/details-group.js.map +1 -1
  33. package/web-components/group/tab-group.js +45 -45
  34. package/web-components/group/tab-group.js.map +1 -1
  35. package/web-components/index.d.ts +0 -3
  36. package/web-components/index.d.ts.map +1 -1
  37. package/web-components/index.js +0 -3
  38. package/web-components/index.js.map +1 -1
  39. package/web-components/input/base-input.js +73 -73
  40. package/web-components/input/base-input.js.map +1 -1
  41. package/web-components/input/input.js +15 -15
  42. package/web-components/input/input.js.map +1 -1
  43. package/web-components/input/label-input.js +49 -49
  44. package/web-components/input/label-input.js.map +1 -1
  45. package/web-components/input/search-input.js +53 -53
  46. package/web-components/input/search-input.js.map +1 -1
  47. package/web-components/input/select-input.js +88 -88
  48. package/web-components/input/select-input.js.map +1 -1
  49. package/web-components/input/split-input.js +51 -51
  50. package/web-components/input/split-input.js.map +1 -1
  51. package/web-components/input/switch-input.js +36 -36
  52. package/web-components/input/switch-input.js.map +1 -1
  53. package/web-components/items/alert-item.js +32 -33
  54. package/web-components/items/alert-item.js.map +1 -1
  55. package/web-components/items/card-item.js +54 -54
  56. package/web-components/items/card-item.js.map +1 -1
  57. package/web-components/items/drag-box.js +8 -8
  58. package/web-components/items/drag-box.js.map +1 -1
  59. package/web-components/items/time-bar.js +8 -9
  60. package/web-components/items/time-bar.js.map +1 -1
  61. package/web-components/layout/divider-line.js +11 -11
  62. package/web-components/layout/divider-line.js.map +1 -1
  63. package/web-components/layout/flex-flow.js +7 -7
  64. package/web-components/layout/flex-flow.js.map +1 -1
  65. package/web-components/layout/nav-layout.d.ts +10 -3
  66. package/web-components/layout/nav-layout.d.ts.map +1 -1
  67. package/web-components/layout/nav-layout.js +31 -101
  68. package/web-components/layout/nav-layout.js.map +1 -1
  69. package/web-components/loading/loading-progress.d.ts +1 -1
  70. package/web-components/loading/loading-progress.d.ts.map +1 -1
  71. package/web-components/loading/loading-progress.js +28 -28
  72. package/web-components/loading/loading-progress.js.map +1 -1
  73. package/web-components/loading/skeleton-screen.js +19 -19
  74. package/web-components/loading/skeleton-screen.js.map +1 -1
  75. package/web-components/open/open-details.d.ts.map +1 -1
  76. package/web-components/open/open-details.js +73 -22
  77. package/web-components/open/open-details.js.map +1 -1
  78. package/web-components/open/open-dialog.d.ts +5 -16
  79. package/web-components/open/open-dialog.d.ts.map +1 -1
  80. package/web-components/open/open-dialog.js +92 -102
  81. package/web-components/open/open-dialog.js.map +1 -1
  82. package/web-components/open/open-offset.d.ts +0 -1
  83. package/web-components/open/open-offset.d.ts.map +1 -1
  84. package/web-components/open/open-offset.js +50 -53
  85. package/web-components/open/open-offset.js.map +1 -1
  86. package/web-components/open/open-tooltip.d.ts +2 -2
  87. package/web-components/open/open-tooltip.d.ts.map +1 -1
  88. package/web-components/open/open-tooltip.js +14 -15
  89. package/web-components/open/open-tooltip.js.map +1 -1
  90. package/web-components/open/open.d.ts +3 -2
  91. package/web-components/open/open.d.ts.map +1 -1
  92. package/web-components/open/open.js +13 -59
  93. package/web-components/open/open.js.map +1 -1
  94. package/web-components/text/clip-text.js +8 -8
  95. package/web-components/text/clip-text.js.map +1 -1
  96. package/web-components/text/overbreath-text.js +17 -17
  97. package/web-components/text/overbreath-text.js.map +1 -1
  98. package/web-components/text/typewriter-text.js +32 -32
  99. package/web-components/text/typewriter-text.js.map +1 -1
  100. package/web-components/view/route-view.d.ts +2 -2
  101. package/web-components/view/route-view.js +7 -7
  102. package/web-components/view/route-view.js.map +1 -1
  103. package/web-components/view/wrap-view.d.ts +1 -1
  104. package/web-components/view/wrap-view.js +15 -15
  105. package/web-components/view/wrap-view.js.map +1 -1
  106. package/nav-aside.d.ts +0 -2
  107. package/nav-aside.d.ts.map +0 -1
  108. package/nav-aside.js +0 -2
  109. package/nav-aside.js.map +0 -1
  110. package/open-list.d.ts +0 -2
  111. package/open-list.d.ts.map +0 -1
  112. package/open-list.js +0 -2
  113. package/open-list.js.map +0 -1
  114. package/scroll-x.d.ts +0 -2
  115. package/scroll-x.d.ts.map +0 -1
  116. package/scroll-x.js +0 -2
  117. package/scroll-x.js.map +0 -1
  118. package/web-components/layout/index.d.ts +0 -5
  119. package/web-components/layout/index.d.ts.map +0 -1
  120. package/web-components/layout/index.js +0 -6
  121. package/web-components/layout/index.js.map +0 -1
  122. package/web-components/layout/nav-aside.d.ts +0 -25
  123. package/web-components/layout/nav-aside.d.ts.map +0 -1
  124. package/web-components/layout/nav-aside.js +0 -70
  125. package/web-components/layout/nav-aside.js.map +0 -1
  126. package/web-components/open/open-list.d.ts +0 -20
  127. package/web-components/open/open-list.d.ts.map +0 -1
  128. package/web-components/open/open-list.js +0 -71
  129. package/web-components/open/open-list.js.map +0 -1
  130. package/web-components/view/scroll-x.d.ts +0 -25
  131. package/web-components/view/scroll-x.d.ts.map +0 -1
  132. package/web-components/view/scroll-x.js +0 -97
  133. package/web-components/view/scroll-x.js.map +0 -1
@@ -1,10 +1,10 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { css, html, property, query } from "../../deps.js";
3
- import { ifValue } from "../../lib/directives.js";
4
3
  import { htmlSlot, svgDeltaSmooth } from "../../lib/templates.js";
5
- import { define } from "../../root.js";
4
+ import { createScope, cssvarValues, define } from "../../root.js";
6
5
  import { OpenableElement } from "./open.js";
7
6
  const defineName = "open-details";
7
+ const cssvarScope = createScope(defineName);
8
8
  /**
9
9
  * OpenDetails similar to details.
10
10
  */
@@ -20,29 +20,11 @@ let OpenDetails = class OpenDetails extends OpenableElement {
20
20
  */
21
21
  this.reverse = false;
22
22
  }
23
- static { this.styles = [
24
- OpenableElement.styles,
25
- css `
26
- i {
27
- height: 1.2em;
28
- min-width: 1.2em;
29
- aspect-ratio: 1/1;
30
- display: flex;
31
- margin-left: auto;
32
- -webkit-backface-visibility: hidden;
33
- backface-visibility: hidden;
34
- }
35
-
36
- :host([open]) i {
37
- transform: rotate(-90deg) !important;
38
- }
39
- `,
40
- ]; }
41
23
  render() {
42
24
  return html `<dl>
43
- <dt @click="${this._handelClick}" style="flex-direction:row${ifValue(this.reverse, "-reverse")}">
25
+ <dt @click="${this._handelClick}">
44
26
  <span> ${this.summary || htmlSlot("summary")} </span>
45
- <i style="transform: rotate(${ifValue(this.reverse, "-18")}0deg);"> ${this.renderIcon()} </i>
27
+ <i>${this.renderIcon()}</i>
46
28
  </dt>
47
29
  <dd>
48
30
  <section>${htmlSlot()}</section>
@@ -61,6 +43,75 @@ let OpenDetails = class OpenDetails extends OpenableElement {
61
43
  }
62
44
  }
63
45
  };
46
+ OpenDetails.styles = [
47
+ OpenableElement.styles,
48
+ css `
49
+ :host {
50
+ color: var(${cssvarValues.text});
51
+ ${cssvarScope}--icon-deg-open: -90deg;
52
+ ${cssvarScope}--icon-deg: 0deg;
53
+ ${cssvarScope}--summary-direction: row;
54
+ }
55
+ span {
56
+ display: inline-flex;
57
+ align-items: center;
58
+ white-space: nowrap;
59
+ }
60
+
61
+ dl {
62
+ height: 100%;
63
+ position: relative;
64
+ overflow: hidden;
65
+ }
66
+
67
+ dt {
68
+ display: flex;
69
+ flex-wrap: nowrap;
70
+ justify-content: space-between;
71
+ background: inherit;
72
+ align-items: center;
73
+ height: 100%;
74
+ flex-direction: var(${cssvarScope}--summary-direction);
75
+ }
76
+
77
+ dd {
78
+ overflow: hidden;
79
+ display: grid;
80
+ grid-template-rows: 0fr;
81
+ }
82
+
83
+ * {
84
+ transition: inherit;
85
+ }
86
+
87
+ section {
88
+ min-height: 0;
89
+ overflow: hidden;
90
+ }
91
+
92
+ i {
93
+ height: 1em;
94
+ wdith: 1em;
95
+ display: flex;
96
+ -webkit-backface-visibility: hidden;
97
+ backface-visibility: hidden;
98
+ transform: rotate(var(${cssvarScope}--icon-deg));
99
+ }
100
+
101
+ :host([open]) dd {
102
+ grid-template-rows: 1fr;
103
+ }
104
+
105
+ :host([float]) dd {
106
+ top: 100%;
107
+ position: absolute;
108
+ }
109
+
110
+ :host([open]) i {
111
+ transform: rotate(var(${cssvarScope}--icon-deg-open));
112
+ }
113
+ `,
114
+ ];
64
115
  __decorate([
65
116
  property({ type: Boolean })
66
117
  ], OpenDetails.prototype, "fill", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"open-details.js","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/open/open-details.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAuB,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,QAAQ,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E,IAAI,EAAE,OAAO,EAAE,CAAC;4CAAiB;AAEhC;IAAZ,KAAK,CAAC,IAAI,CAAC;wCAA0B;AAV3B,WAAW;IADvB,MAAM,CAAC,UAAU,CAAC;GACN,WAAW,CAuDvB;;AAED,eAAe,WAAW,CAAC","sourcesContent":["import { css, type CSSResultGroup, html, property, query } from \"../../deps.js\";\nimport { ifValue } from \"../../lib/directives.js\";\nimport { htmlSlot, type HTMLTemplate, svgDeltaSmooth } from \"../../lib/templates.js\";\nimport { define } from \"../../root.js\";\nimport { OpenableElement } from \"./open.js\";\n\nconst defineName = \"open-details\";\n\n/**\n * OpenDetails similar to details.\n */\n@define(defineName)\nexport class OpenDetails extends OpenableElement {\n /**\n * If it is true, the summary event scope will fill the element.\n */\n @property({ type: Boolean }) fill = false;\n /**\n * Reverse summary.\n */\n @property({ type: Boolean }) reverse = false;\n\n @query(\"dd\") _dd: HTMLDataListElement;\n\n static styles = [\n OpenableElement.styles,\n css`\n i {\n height: 1.2em;\n min-width: 1.2em;\n aspect-ratio: 1/1;\n display: flex;\n margin-left: auto;\n -webkit-backface-visibility: hidden;\n backface-visibility: hidden;\n }\n\n :host([open]) i {\n transform: rotate(-90deg) !important;\n }\n `,\n ] as CSSResultGroup;\n\n protected render(): HTMLTemplate {\n return html`<dl>\n <dt @click=\"${this._handelClick}\" style=\"flex-direction:row${ifValue(this.reverse, \"-reverse\")}\">\n <span> ${this.summary || htmlSlot(\"summary\")} </span>\n <i style=\"transform: rotate(${ifValue(this.reverse, \"-18\")}0deg);\"> ${this.renderIcon()} </i>\n </dt>\n <dd>\n <section>${htmlSlot()}</section>\n </dd>\n </dl>`;\n }\n\n private renderIcon(): HTMLTemplate {\n if (this.querySelector(\"slot[name=icon]\")) {\n return htmlSlot(\"icon\");\n }\n return svgDeltaSmooth();\n }\n\n protected firstUpdated() {\n if (this.fill) {\n this.addEvent(this._dd, \"click\", () => this.toggle());\n }\n }\n}\n\nexport default OpenDetails;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"open-details\": OpenDetails;\n }\n}\n"]}
1
+ {"version":3,"file":"open-details.js","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/open/open-details.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAuB,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAqB,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,MAAM,UAAU,GAAG,cAAc,CAAC;AAElC,MAAM,WAAW,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;AAE5C;;GAEG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,eAAe;IAAzC;;QACL;;WAEG;QAC0B,SAAI,GAAG,KAAK,CAAC;QAC1C;;WAEG;QAC0B,YAAO,GAAG,KAAK,CAAC;IAkG/C,CAAC;IAxBW,MAAM;QACd,OAAO,IAAI,CAAA;oBACK,IAAI,CAAC,YAAY;iBACpB,IAAI,CAAC,OAAO,IAAI,QAAQ,CAAC,SAAS,CAAC;aACvC,IAAI,CAAC,UAAU,EAAE;;;mBAGX,QAAQ,EAAE;;UAEnB,CAAC;IACT,CAAC;IAEO,UAAU;QAChB,IAAI,IAAI,CAAC,aAAa,CAAC,iBAAiB,CAAC,EAAE,CAAC;YAC1C,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC1B,CAAC;QACD,OAAO,cAAc,EAAE,CAAC;IAC1B,CAAC;IAES,YAAY;QACpB,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;;AA7FM,kBAAM,GAAG;IACd,eAAe,CAAC,MAAM;IACtB,GAAG,CAAA;;qBAEc,YAAY,CAAC,IAAI;UAC5B,WAAW;UACX,WAAW;UACX,WAAW;;;;;;;;;;;;;;;;;;;;;8BAqBS,WAAW;;;;;;;;;;;;;;;;;;;;;;;;gCAwBT,WAAW;;;;;;;;;;;;;gCAaX,WAAW;;KAEtC;CACgB,AApEN,CAoEO;AA5ES;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;yCAAc;AAIb;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;4CAAiB;AAEhC;IAAZ,KAAK,CAAC,IAAI,CAAC;wCAA0B;AAV3B,WAAW;IADvB,MAAM,CAAC,UAAU,CAAC;GACN,WAAW,CA0GvB;;AAED,eAAe,WAAW,CAAC","sourcesContent":["import { css, type CSSResultGroup, html, property, query } from \"../../deps.js\";\nimport { htmlSlot, type HTMLTemplate, svgDeltaSmooth } from \"../../lib/templates.js\";\nimport { createScope, cssvarValues, define } from \"../../root.js\";\nimport { OpenableElement } from \"./open.js\";\n\nconst defineName = \"open-details\";\n\nconst cssvarScope = createScope(defineName);\n\n/**\n * OpenDetails similar to details.\n */\n@define(defineName)\nexport class OpenDetails extends OpenableElement {\n /**\n * If it is true, the summary event scope will fill the element.\n */\n @property({ type: Boolean }) fill = false;\n /**\n * Reverse summary.\n */\n @property({ type: Boolean }) reverse = false;\n\n @query(\"dd\") _dd: HTMLDataListElement;\n\n static styles = [\n OpenableElement.styles,\n css`\n :host {\n color: var(${cssvarValues.text});\n ${cssvarScope}--icon-deg-open: -90deg;\n ${cssvarScope}--icon-deg: 0deg;\n ${cssvarScope}--summary-direction: row;\n }\n span {\n display: inline-flex;\n align-items: center;\n white-space: nowrap;\n }\n\n dl {\n height: 100%;\n position: relative;\n overflow: hidden;\n }\n\n dt {\n display: flex;\n flex-wrap: nowrap;\n justify-content: space-between;\n background: inherit;\n align-items: center;\n height: 100%;\n flex-direction: var(${cssvarScope}--summary-direction);\n }\n\n dd {\n overflow: hidden;\n display: grid;\n grid-template-rows: 0fr;\n }\n\n * {\n transition: inherit;\n }\n\n section {\n min-height: 0;\n overflow: hidden;\n }\n\n i {\n height: 1em;\n wdith: 1em;\n display: flex;\n -webkit-backface-visibility: hidden;\n backface-visibility: hidden;\n transform: rotate(var(${cssvarScope}--icon-deg));\n }\n\n :host([open]) dd {\n grid-template-rows: 1fr;\n }\n\n :host([float]) dd {\n top: 100%;\n position: absolute;\n }\n\n :host([open]) i {\n transform: rotate(var(${cssvarScope}--icon-deg-open));\n }\n `,\n ] as CSSResultGroup;\n\n protected render(): HTMLTemplate {\n return html`<dl>\n <dt @click=\"${this._handelClick}\">\n <span> ${this.summary || htmlSlot(\"summary\")} </span>\n <i>${this.renderIcon()}</i>\n </dt>\n <dd>\n <section>${htmlSlot()}</section>\n </dd>\n </dl>`;\n }\n\n private renderIcon(): HTMLTemplate {\n if (this.querySelector(\"slot[name=icon]\")) {\n return htmlSlot(\"icon\");\n }\n return svgDeltaSmooth();\n }\n\n protected firstUpdated() {\n if (this.fill) {\n this.addEvent(this._dd, \"click\", () => this.toggle());\n }\n }\n}\n\nexport default OpenDetails;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"open-details\": OpenDetails;\n }\n}\n"]}
@@ -1,19 +1,15 @@
1
- import { type PropertyValueMap } from "../../deps.js";
1
+ import { CSSResultGroup } from "../../deps.js";
2
2
  import { type HTMLTemplate } from "../../lib/templates.js";
3
- import { GodownElement } from "../../root.js";
4
- type Direction5 = "left" | "center" | "right" | "top" | "bottom";
3
+ import OpenableElement, { Direction9 } from "./open.js";
5
4
  /**
6
5
  * OpenDialog similar to dialog.
7
6
  */
8
- export declare class OpenDialog extends GodownElement {
7
+ export declare class OpenDialog extends OpenableElement {
8
+ direction: Direction9;
9
9
  /**
10
10
  * Enable modal.
11
11
  */
12
12
  modal: boolean;
13
- /**
14
- * Whether this element is activated.
15
- */
16
- open: boolean;
17
13
  /**
18
14
  * Enable scale.
19
15
  */
@@ -26,18 +22,11 @@ export declare class OpenDialog extends GodownElement {
26
22
  * Exit key, which can be multiple.
27
23
  */
28
24
  key: string;
29
- /**
30
- * The direction in which it appears.
31
- */
32
- direction: Direction5;
33
25
  _div: HTMLDivElement;
34
- static styles: import("lit").CSSResult[];
26
+ static styles: CSSResultGroup;
35
27
  protected render(): HTMLTemplate;
36
28
  connectedCallback(): void;
37
- show(): void;
38
29
  showModal(): void;
39
- close(): void;
40
- protected updated(changedProperties: PropertyValueMap<this>): void;
41
30
  protected _handleWheel(e: any): void;
42
31
  protected _handleKeydown(e: KeyboardEvent): void;
43
32
  protected _handelSubmit(e: SubmitEvent): void;
@@ -1 +1 @@
1
- {"version":3,"file":"open-dialog.d.ts","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/open/open-dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,gBAAgB,EAAS,MAAM,eAAe,CAAC;AAClF,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAwB,aAAa,EAAE,MAAM,eAAe,CAAC;AAEpE,KAAK,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;AAIjE;;GAEG;AACH,qBACa,UAAW,SAAQ,aAAa;IAC3C;;OAEG;IACyC,KAAK,UAAS;IAC1D;;OAEG;IACyC,IAAI,UAAS;IACzD;;OAEG;IAC0B,KAAK,UAAS;IAC3C;;OAEG;IACyB,GAAG,SAAO;IACtC;;OAEG;IACyB,GAAG,SAAY;IAC3C;;OAEG;IACyB,SAAS,EAAE,UAAU,CAAY;IAE/C,IAAI,EAAE,cAAc,CAAC;IAEnC,MAAM,CAAC,MAAM,4BA6EX;IAEF,SAAS,CAAC,MAAM,IAAI,YAAY;IAMhC,iBAAiB;IAcjB,IAAI;IAIJ,SAAS;IAKT,KAAK;IAIL,SAAS,CAAC,OAAO,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,IAAI,CAAC;IAO3D,SAAS,CAAC,YAAY,CAAC,CAAC,EAAE,GAAG;IAgB7B,SAAS,CAAC,cAAc,CAAC,CAAC,EAAE,aAAa;IAOzC,SAAS,CAAC,aAAa,CAAC,CAAC,EAAE,WAAW;CAKvC;AAED,eAAe,UAAU,CAAC;AAE1B,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,UAAU,CAAC;KAC3B;CACF"}
1
+ {"version":3,"file":"open-dialog.d.ts","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/open/open-dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,cAAc,EAAyB,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAY,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAErE,OAAO,eAAe,EAAE,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAIxD;;GAEG;AACH,qBACa,UAAW,SAAQ,eAAe;IAC7C,SAAS,EAAE,UAAU,CAAY;IACjC;;OAEG;IACyC,KAAK,UAAS;IAC1D;;OAEG;IAC0B,KAAK,UAAS;IAC3C;;OAEG;IACyB,GAAG,SAAO;IACtC;;OAEG;IACyB,GAAG,SAAY;IAE7B,IAAI,EAAE,cAAc,CAAC;IAEnC,MAAM,CAAC,MAAM,EAAE,cAAc,CAkG3B;IAEF,SAAS,CAAC,MAAM,IAAI,YAAY;IAIhC,iBAAiB;IAcjB,SAAS;IAKT,SAAS,CAAC,YAAY,CAAC,CAAC,EAAE,GAAG;IAU7B,SAAS,CAAC,cAAc,CAAC,CAAC,EAAE,aAAa;IAOzC,SAAS,CAAC,aAAa,CAAC,CAAC,EAAE,WAAW;CAKvC;AAED,eAAe,UAAU,CAAC;AAE1B,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,UAAU,CAAC;KAC3B;CACF"}
@@ -1,21 +1,20 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { css, html, property, query } from "../../deps.js";
3
- import { cssvarValues, define, GodownElement } from "../../root.js";
3
+ import { htmlSlot } from "../../lib/templates.js";
4
+ import { cssvar, cssvarValues, define } from "../../root.js";
5
+ import OpenableElement from "./open.js";
4
6
  const defineName = "open-dialog";
5
7
  /**
6
8
  * OpenDialog similar to dialog.
7
9
  */
8
- let OpenDialog = class OpenDialog extends GodownElement {
10
+ let OpenDialog = class OpenDialog extends OpenableElement {
9
11
  constructor() {
10
12
  super(...arguments);
13
+ this.direction = "center";
11
14
  /**
12
15
  * Enable modal.
13
16
  */
14
17
  this.modal = false;
15
- /**
16
- * Whether this element is activated.
17
- */
18
- this.open = false;
19
18
  /**
20
19
  * Enable scale.
21
20
  */
@@ -23,19 +22,70 @@ let OpenDialog = class OpenDialog extends GodownElement {
23
22
  /**
24
23
  * Scale gap.
25
24
  */
26
- this.gap = 0.1;
25
+ this.gap = 0.2;
27
26
  /**
28
27
  * Exit key, which can be multiple.
29
28
  */
30
29
  this.key = "Escape";
31
- /**
32
- * The direction in which it appears.
33
- */
34
- this.direction = "center";
35
30
  }
36
- static { this.styles = [
37
- css `
31
+ render() {
32
+ return html `<div style="--s:1" class="${this.direction}">${htmlSlot()}</div>`;
33
+ }
34
+ connectedCallback() {
35
+ super.connectedCallback();
36
+ this.addEvent(this, "submit", this._handelSubmit);
37
+ if (this.scale && this.direction === "center") {
38
+ this.addEvent(this, "wheel", this._handleWheel);
39
+ }
40
+ if (this.key) {
41
+ this.addEvent(document, "keydown", this._handleKeydown.bind(this));
42
+ }
43
+ if (this.open) {
44
+ this.show();
45
+ }
46
+ }
47
+ showModal() {
48
+ this.modal = true;
49
+ this.show();
50
+ }
51
+ _handleWheel(e) {
52
+ let scale = Number(this._div.style.getPropertyValue("--s"));
53
+ if (e.deltaY > 0) {
54
+ scale -= this.gap;
55
+ }
56
+ else {
57
+ scale += this.gap;
58
+ }
59
+ this._div.style.setProperty("--s", `${scale}`);
60
+ }
61
+ _handleKeydown(e) {
62
+ const keys = this.key.split(/[^a-zA-Z0-9]/).filter((s) => s);
63
+ if (keys.includes(e.key) || keys.includes(e.code)) {
64
+ this.close();
65
+ }
66
+ }
67
+ _handelSubmit(e) {
68
+ if (e.target.method === "dialog") {
69
+ this.close();
70
+ }
71
+ }
72
+ };
73
+ OpenDialog.styles = [
74
+ OpenableElement.styles,
75
+ css `
76
+ :host {
77
+ display: block;
78
+ transition:
79
+ all 0.3s ease-in-out,
80
+ color 0s,
81
+ background 0s;
82
+ height: fit-content;
83
+ }
84
+ `,
85
+ css `
38
86
  :host {
87
+ ${cssvar}--background: rgb(var(${cssvarValues.mainRGB}) / 0%);
88
+ ${cssvar}--background-modal: rgb(var(${cssvarValues.mainRGB}) / 15%);
39
89
  position: fixed;
40
90
  height: 100%;
41
91
  width: 100%;
@@ -46,7 +96,7 @@ let OpenDialog = class OpenDialog extends GodownElement {
46
96
  transition: all 0.3s;
47
97
  display: flex;
48
98
  visibility: hidden;
49
- background: rgb(${cssvarValues.mainRGB} / 0%);
99
+ background: var(${cssvar}--background);
50
100
  pointer-events: none;
51
101
  }
52
102
 
@@ -57,7 +107,7 @@ let OpenDialog = class OpenDialog extends GodownElement {
57
107
  :host([open][modal]) {
58
108
  pointer-events: all;
59
109
  backdrop-filter: blur(0.25px);
60
- background: rgb(${cssvarValues.mainRGB} / 20%);
110
+ background: var(${cssvar}--background-modal);
61
111
  }
62
112
 
63
113
  :host([open]) slot {
@@ -70,6 +120,7 @@ let OpenDialog = class OpenDialog extends GodownElement {
70
120
  width: 100%;
71
121
  display: flex;
72
122
  transition: inherit;
123
+ transform: scale(var(--s));
73
124
  }
74
125
 
75
126
  slot {
@@ -82,103 +133,45 @@ let OpenDialog = class OpenDialog extends GodownElement {
82
133
  pointer-events: all;
83
134
  }
84
135
 
85
- .center {
86
- transform: translateY(-15%);
136
+ div {
137
+ position: relative;
87
138
  }
88
139
 
89
- .top {
90
- width: 100%;
91
- margin-top: 0;
92
- transform: translateY(-15%);
140
+ slot {
141
+ position: absolute;
93
142
  }
94
143
 
95
- .right {
96
- height: 100%;
97
- margin-right: 0;
98
- transform: translateX(15%);
144
+ [class^="top"] slot {
145
+ top: 0;
99
146
  }
100
147
 
101
- .bottom {
102
- width: 100%;
103
- margin-bottom: 0;
104
- transform: translateY(15%);
148
+ [class^="bottom"] slot {
149
+ bottom: 0;
105
150
  }
106
151
 
107
- .left {
108
- height: 100%;
109
- margin-left: 0;
110
- transform: translateX(-15%);
152
+ [class$="right"] slot {
153
+ right: 0%;
154
+ }
155
+
156
+ [class$="left"] slot {
157
+ left: 0%;
158
+ }
159
+
160
+ div[class$="center"],
161
+ .top,
162
+ .left,
163
+ .right,
164
+ .bottom {
165
+ align-items: center;
166
+ justify-content: center;
167
+ align-items: center;
168
+ justify-content: center;
111
169
  }
112
170
  `,
113
- ]; }
114
- render() {
115
- return html `<div>
116
- <slot class="${this.direction}"></slot>
117
- </div>`;
118
- }
119
- connectedCallback() {
120
- super.connectedCallback();
121
- this.addEvent(this, "submit", this._handelSubmit);
122
- if (this.scale) {
123
- this.addEvent(this, "wheel", this._handleWheel);
124
- }
125
- if (this.key) {
126
- this.addEvent(document, "keydown", this._handleKeydown.bind(this));
127
- }
128
- if (this.open) {
129
- this.show();
130
- }
131
- }
132
- show() {
133
- this.open = true;
134
- }
135
- showModal() {
136
- this.modal = true;
137
- this.show();
138
- }
139
- close() {
140
- this.open = false;
141
- }
142
- updated(changedProperties) {
143
- const hasOpen = changedProperties.has("open");
144
- if (hasOpen) {
145
- this.dispatchEvent(new CustomEvent(this.open ? "open" : "close"));
146
- }
147
- }
148
- _handleWheel(e) {
149
- if (this.scale) {
150
- const s = this._div.style.transform.match(/scale\((.*)\)/);
151
- let scale = 1;
152
- if (s) {
153
- scale = Number(s[1]);
154
- }
155
- if (e.deltaY > 0) {
156
- scale -= this.gap;
157
- }
158
- else {
159
- scale += this.gap;
160
- }
161
- this._div.style.transform = `scale(${scale})`;
162
- }
163
- }
164
- _handleKeydown(e) {
165
- const keys = this.key.split(/[^a-zA-Z0-9]/).filter((s) => s);
166
- if (keys.includes(e.key) || keys.includes(e.code)) {
167
- this.close();
168
- }
169
- }
170
- _handelSubmit(e) {
171
- if (e.target.method === "dialog") {
172
- this.close();
173
- }
174
- }
175
- };
171
+ ];
176
172
  __decorate([
177
173
  property({ type: Boolean, reflect: true })
178
174
  ], OpenDialog.prototype, "modal", void 0);
179
- __decorate([
180
- property({ type: Boolean, reflect: true })
181
- ], OpenDialog.prototype, "open", void 0);
182
175
  __decorate([
183
176
  property({ type: Boolean })
184
177
  ], OpenDialog.prototype, "scale", void 0);
@@ -188,9 +181,6 @@ __decorate([
188
181
  __decorate([
189
182
  property({ type: String })
190
183
  ], OpenDialog.prototype, "key", void 0);
191
- __decorate([
192
- property({ type: String })
193
- ], OpenDialog.prototype, "direction", void 0);
194
184
  __decorate([
195
185
  query("div")
196
186
  ], OpenDialog.prototype, "_div", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"open-dialog.js","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/open/open-dialog.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAyB,KAAK,EAAE,MAAM,eAAe,CAAC;AAElF,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAIpE,MAAM,UAAU,GAAG,aAAa,CAAC;AAEjC;;GAEG;AAEI,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,aAAa;IAAtC;;QACL;;WAEG;QACyC,UAAK,GAAG,KAAK,CAAC;QAC1D;;WAEG;QACyC,SAAI,GAAG,KAAK,CAAC;QACzD;;WAEG;QAC0B,UAAK,GAAG,KAAK,CAAC;QAC3C;;WAEG;QACyB,QAAG,GAAG,GAAG,CAAC;QACtC;;WAEG;QACyB,QAAG,GAAG,QAAQ,CAAC;QA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,CAAC;IACH,CAAC;;AA1K2C;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCAAe;AAId;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wCAAc;AAI5B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;yCAAe;AAIf;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCAAW;AAIV;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCAAgB;AAIf;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAkC;AAE/C;IAAb,KAAK,CAAC,KAAK,CAAC;wCAAsB;AA1BxB,UAAU;IADtB,MAAM,CAAC,UAAU,CAAC;GACN,UAAU,CA+KtB;;AAED,eAAe,UAAU,CAAC","sourcesContent":["import { css, html, property, type PropertyValueMap, query } from \"../../deps.js\";\nimport { type HTMLTemplate } from \"../../lib/templates.js\";\nimport { cssvarValues, define, GodownElement } from \"../../root.js\";\n\ntype Direction5 = \"left\" | \"center\" | \"right\" | \"top\" | \"bottom\";\n\nconst defineName = \"open-dialog\";\n\n/**\n * OpenDialog similar to dialog.\n */\n@define(defineName)\nexport class OpenDialog extends GodownElement {\n /**\n * Enable modal.\n */\n @property({ type: Boolean, reflect: true }) modal = false;\n /**\n * Whether this element is activated.\n */\n @property({ type: Boolean, reflect: true }) open = false;\n /**\n * Enable scale.\n */\n @property({ type: Boolean }) scale = false;\n /**\n * Scale gap.\n */\n @property({ type: Number }) gap = 0.1;\n /**\n * Exit key, which can be multiple.\n */\n @property({ type: String }) key = \"Escape\";\n /**\n * The direction in which it appears.\n */\n @property({ type: String }) direction: Direction5 = \"center\";\n\n @query(\"div\") _div: HTMLDivElement;\n\n static styles = [\n css`\n :host {\n position: fixed;\n height: 100%;\n width: 100%;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n transition: all 0.3s;\n display: flex;\n visibility: hidden;\n background: rgb(${cssvarValues.mainRGB} / 0%);\n pointer-events: none;\n }\n\n :host([open]) {\n visibility: visible;\n }\n\n :host([open][modal]) {\n pointer-events: all;\n backdrop-filter: blur(0.25px);\n background: rgb(${cssvarValues.mainRGB} / 20%);\n }\n\n :host([open]) slot {\n opacity: 1 !important;\n transform: translateY(0) translateX(0) !important;\n }\n\n div {\n height: 100%;\n width: 100%;\n display: flex;\n transition: inherit;\n }\n\n slot {\n display: block;\n width: fit-content;\n height: fit-content;\n margin: auto;\n opacity: 0;\n transition: inherit;\n pointer-events: all;\n }\n\n .center {\n transform: translateY(-15%);\n }\n\n .top {\n width: 100%;\n margin-top: 0;\n transform: translateY(-15%);\n }\n\n .right {\n height: 100%;\n margin-right: 0;\n transform: translateX(15%);\n }\n\n .bottom {\n width: 100%;\n margin-bottom: 0;\n transform: translateY(15%);\n }\n\n .left {\n height: 100%;\n margin-left: 0;\n transform: translateX(-15%);\n }\n `,\n ];\n\n protected render(): HTMLTemplate {\n return html`<div>\n <slot class=\"${this.direction}\"></slot>\n </div>`;\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.addEvent(this, \"submit\", this._handelSubmit);\n if (this.scale) {\n this.addEvent(this, \"wheel\", this._handleWheel);\n }\n if (this.key) {\n this.addEvent(document, \"keydown\", this._handleKeydown.bind(this));\n }\n if (this.open) {\n this.show();\n }\n }\n\n show() {\n this.open = true;\n }\n\n showModal() {\n this.modal = true;\n this.show();\n }\n\n close() {\n this.open = false;\n }\n\n protected updated(changedProperties: PropertyValueMap<this>) {\n const hasOpen = changedProperties.has(\"open\");\n if (hasOpen) {\n this.dispatchEvent(new CustomEvent(this.open ? \"open\" : \"close\"));\n }\n }\n\n protected _handleWheel(e: any) {\n if (this.scale) {\n const s = this._div.style.transform.match(/scale\\((.*)\\)/);\n let scale = 1;\n if (s) {\n scale = Number(s[1]);\n }\n if (e.deltaY > 0) {\n scale -= this.gap;\n } else {\n scale += this.gap;\n }\n this._div.style.transform = `scale(${scale})`;\n }\n }\n\n protected _handleKeydown(e: KeyboardEvent) {\n const keys = this.key.split(/[^a-zA-Z0-9]/).filter((s) => s);\n if (keys.includes(e.key) || keys.includes(e.code)) {\n this.close();\n }\n }\n\n protected _handelSubmit(e: SubmitEvent) {\n if ((e.target as HTMLFormElement).method === \"dialog\") {\n this.close();\n }\n }\n}\n\nexport default OpenDialog;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"open-dialog\": OpenDialog;\n }\n}\n"]}
1
+ {"version":3,"file":"open-dialog.js","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/open/open-dialog.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAkB,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAqB,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,eAA+B,MAAM,WAAW,CAAC;AAExD,MAAM,UAAU,GAAG,aAAa,CAAC;AAEjC;;GAEG;AAEI,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,eAAe;IAAxC;;QACL,cAAS,GAAe,QAAQ,CAAC;QACjC;;WAEG;QACyC,UAAK,GAAG,KAAK,CAAC;QAC1D;;WAEG;QAC0B,UAAK,GAAG,KAAK,CAAC;QAC3C;;WAEG;QACyB,QAAG,GAAG,GAAG,CAAC;QACtC;;WAEG;QACyB,QAAG,GAAG,QAAQ,CAAC;IAqJ7C,CAAC;IA7CW,MAAM;QACd,OAAO,IAAI,CAAA,6BAA6B,IAAI,CAAC,SAAS,KAAK,QAAQ,EAAE,QAAQ,CAAC;IAChF,CAAC;IAED,iBAAiB;QACf,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,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,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;YAClD,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,CAAC;IACH,CAAC;IAES,aAAa,CAAC,CAAc;QACpC,IAAK,CAAC,CAAC,MAA0B,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;YACtD,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,CAAC;IACH,CAAC;;AAhJM,iBAAM,GAAmB;IAC9B,eAAe,CAAC,MAAM;IACtB,GAAG,CAAA;;;;;;;;;KASF;IACD,GAAG,CAAA;;UAEG,MAAM,yBAAyB,YAAY,CAAC,OAAO;UACnD,MAAM,+BAA+B,YAAY,CAAC,OAAO;;;;;;;;;;;0BAWzC,MAAM;;;;;;;;;;;0BAWN,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4D3B;CACF,AAlGY,CAkGX;AAlH0C;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCAAe;AAI7B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;yCAAe;AAIf;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCAAW;AAIV;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCAAgB;AAE7B;IAAb,KAAK,CAAC,KAAK,CAAC;wCAAsB;AAnBxB,UAAU;IADtB,MAAM,CAAC,UAAU,CAAC;GACN,UAAU,CAsKtB;;AAED,eAAe,UAAU,CAAC","sourcesContent":["import { css, CSSResultGroup, html, property, query } from \"../../deps.js\";\nimport { htmlSlot, type HTMLTemplate } from \"../../lib/templates.js\";\nimport { cssvar, cssvarValues, define } from \"../../root.js\";\nimport OpenableElement, { Direction9 } from \"./open.js\";\n\nconst defineName = \"open-dialog\";\n\n/**\n * OpenDialog similar to dialog.\n */\n@define(defineName)\nexport class OpenDialog extends OpenableElement {\n direction: Direction9 = \"center\";\n /**\n * Enable modal.\n */\n @property({ type: Boolean, reflect: true }) modal = false;\n /**\n * Enable scale.\n */\n @property({ type: Boolean }) scale = false;\n /**\n * Scale gap.\n */\n @property({ type: Number }) gap = 0.2;\n /**\n * Exit key, which can be multiple.\n */\n @property({ type: String }) key = \"Escape\";\n\n @query(\"div\") _div: HTMLDivElement;\n\n static styles: CSSResultGroup = [\n OpenableElement.styles,\n css`\n :host {\n display: block;\n transition:\n all 0.3s ease-in-out,\n color 0s,\n background 0s;\n height: fit-content;\n }\n `,\n css`\n :host {\n ${cssvar}--background: rgb(var(${cssvarValues.mainRGB}) / 0%);\n ${cssvar}--background-modal: rgb(var(${cssvarValues.mainRGB}) / 15%);\n position: fixed;\n height: 100%;\n width: 100%;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n transition: all 0.3s;\n display: flex;\n visibility: hidden;\n background: var(${cssvar}--background);\n pointer-events: none;\n }\n\n :host([open]) {\n visibility: visible;\n }\n\n :host([open][modal]) {\n pointer-events: all;\n backdrop-filter: blur(0.25px);\n background: var(${cssvar}--background-modal);\n }\n\n :host([open]) slot {\n opacity: 1 !important;\n transform: translateY(0) translateX(0) !important;\n }\n\n div {\n height: 100%;\n width: 100%;\n display: flex;\n transition: inherit;\n transform: scale(var(--s));\n }\n\n slot {\n display: block;\n width: fit-content;\n height: fit-content;\n margin: auto;\n opacity: 0;\n transition: inherit;\n pointer-events: all;\n }\n\n div {\n position: relative;\n }\n\n slot {\n position: absolute;\n }\n\n [class^=\"top\"] slot {\n top: 0;\n }\n\n [class^=\"bottom\"] slot {\n bottom: 0;\n }\n\n [class$=\"right\"] slot {\n right: 0%;\n }\n\n [class$=\"left\"] slot {\n left: 0%;\n }\n\n div[class$=\"center\"],\n .top,\n .left,\n .right,\n .bottom {\n align-items: center;\n justify-content: center;\n align-items: center;\n justify-content: center;\n }\n `,\n ];\n\n protected render(): HTMLTemplate {\n return html`<div style=\"--s:1\" class=\"${this.direction}\">${htmlSlot()}</div>`;\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.addEvent(this, \"submit\", this._handelSubmit);\n if (this.scale && this.direction === \"center\") {\n this.addEvent(this, \"wheel\", this._handleWheel);\n }\n if (this.key) {\n this.addEvent(document, \"keydown\", this._handleKeydown.bind(this));\n }\n if (this.open) {\n this.show();\n }\n }\n\n showModal() {\n this.modal = true;\n this.show();\n }\n\n protected _handleWheel(e: any) {\n let scale = Number(this._div.style.getPropertyValue(\"--s\"));\n if (e.deltaY > 0) {\n scale -= this.gap;\n } else {\n scale += this.gap;\n }\n this._div.style.setProperty(\"--s\", `${scale}`);\n }\n\n protected _handleKeydown(e: KeyboardEvent) {\n const keys = this.key.split(/[^a-zA-Z0-9]/).filter((s) => s);\n if (keys.includes(e.key) || keys.includes(e.code)) {\n this.close();\n }\n }\n\n protected _handelSubmit(e: SubmitEvent) {\n if ((e.target as HTMLFormElement).method === \"dialog\") {\n this.close();\n }\n }\n}\n\nexport default OpenDialog;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"open-dialog\": OpenDialog;\n }\n}\n"]}
@@ -8,7 +8,6 @@ import { type Direction4, OpenableElement } from "./open.js";
8
8
  */
9
9
  export declare class OpenOffset extends OpenableElement {
10
10
  direction: Direction4;
11
- private _span;
12
11
  private _balancer;
13
12
  static styles: CSSResultGroup;
14
13
  protected render(): HTMLTemplate;
@@ -1 +1 @@
1
- {"version":3,"file":"open-offset.d.ts","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/open/open-offset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,cAAc,EAAe,MAAM,eAAe,CAAC;AACtE,OAAO,EAAY,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAGrE,OAAO,EAAE,KAAK,UAAU,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAI7D;;;;GAIG;AACH,qBACa,UAAW,SAAQ,eAAe;IAC7C,SAAS,EAAE,UAAU,CAAC;IAEP,OAAO,CAAC,KAAK,CAAc;IAC1B,OAAO,CAAC,SAAS,CAAc;IAE/C,MAAM,CAAC,MAAM,iBAiDO;IAEpB,SAAS,CAAC,MAAM,IAAI,YAAY;IAOhC,iBAAiB;cAKD,YAAY;IAM5B,SAAS,CAAC,YAAY,CAAC,CAAC,EAAE,UAAU;IAQpC,SAAS,CAAC,aAAa;IAKvB,MAAM;CA2BP;AAED,eAAe,UAAU,CAAC;AAE1B,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,UAAU,CAAC;KAC3B;CACF"}
1
+ {"version":3,"file":"open-offset.d.ts","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/open/open-offset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,cAAc,EAAe,MAAM,eAAe,CAAC;AACtE,OAAO,EAAY,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAGrE,OAAO,EAAE,KAAK,UAAU,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAI7D;;;;GAIG;AACH,qBACa,UAAW,SAAQ,eAAe;IAC7C,SAAS,EAAE,UAAU,CAAC;IAEN,OAAO,CAAC,SAAS,CAAc;IAE/C,MAAM,CAAC,MAAM,iBAiDO;IAEpB,SAAS,CAAC,MAAM,IAAI,YAAY;IAOhC,iBAAiB;cAKD,YAAY;IAM5B,SAAS,CAAC,YAAY,CAAC,CAAC,EAAE,UAAU;IAQpC,SAAS,CAAC,aAAa;IAKvB,MAAM;CA2BP;AAED,eAAe,UAAU,CAAC;AAE1B,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,UAAU,CAAC;KAC3B;CACF"}
@@ -11,56 +11,6 @@ const defineName = "open-offset";
11
11
  * Content can be opened in 4 directions.
12
12
  */
13
13
  let OpenOffset = class OpenOffset extends OpenableElement {
14
- static { this.styles = [
15
- css `
16
- :host {
17
- display: block;
18
- height: fit-content;
19
- width: fit-content;
20
- }
21
-
22
- span {
23
- user-select: none;
24
- }
25
-
26
- main {
27
- height: inherit;
28
- width: inherit;
29
- display: flex;
30
- position: relative;
31
- align-items: center;
32
- }
33
-
34
- aside {
35
- background-color: inherit;
36
- visibility: hidden;
37
- top: 100%;
38
- z-index: 1;
39
- }
40
-
41
- :host([open]) aside {
42
- visibility: visible;
43
- }
44
-
45
- :host([float]) aside {
46
- position: absolute;
47
- }
48
- `,
49
- css `
50
- .left {
51
- flex-direction: row-reverse;
52
- }
53
- .right {
54
- flex-direction: row;
55
- }
56
- .top {
57
- flex-direction: column-reverse;
58
- }
59
- .bottom {
60
- flex-direction: column;
61
- }
62
- `,
63
- ]; }
64
14
  render() {
65
15
  return html `<main class="${this.direction || "bottom"}">
66
16
  <span>${this.summary || htmlSlot("summary")}</span>
@@ -119,9 +69,56 @@ let OpenOffset = class OpenOffset extends OpenableElement {
119
69
  }
120
70
  }
121
71
  };
122
- __decorate([
123
- query("span")
124
- ], OpenOffset.prototype, "_span", void 0);
72
+ OpenOffset.styles = [
73
+ css `
74
+ :host {
75
+ display: block;
76
+ height: fit-content;
77
+ width: fit-content;
78
+ }
79
+
80
+ span {
81
+ user-select: none;
82
+ }
83
+
84
+ main {
85
+ height: inherit;
86
+ width: inherit;
87
+ display: flex;
88
+ position: relative;
89
+ align-items: center;
90
+ }
91
+
92
+ aside {
93
+ background-color: inherit;
94
+ visibility: hidden;
95
+ top: 100%;
96
+ z-index: 1;
97
+ }
98
+
99
+ :host([open]) aside {
100
+ visibility: visible;
101
+ }
102
+
103
+ :host([float]) aside {
104
+ position: absolute;
105
+ }
106
+ `,
107
+ css `
108
+ .left {
109
+ flex-direction: row-reverse;
110
+ }
111
+ .right {
112
+ flex-direction: row;
113
+ }
114
+ .top {
115
+ flex-direction: column-reverse;
116
+ }
117
+ .bottom {
118
+ flex-direction: column;
119
+ }
120
+ `,
121
+ ];
125
122
  __decorate([
126
123
  query("aside")
127
124
  ], OpenOffset.prototype, "_balancer", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"open-offset.js","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/open/open-offset.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAuB,IAAI,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAqB,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAmB,eAAe,EAAE,MAAM,WAAW,CAAC;AAE7D,MAAM,UAAU,GAAG,aAAa,CAAC;AAEjC;;;;GAIG;AAEI,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,eAAe;aAMtC,WAAM,GAAG;QACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiCF;QACD,GAAG,CAAA;;;;;;;;;;;;;KAaF;KACgB,AAjDN,CAiDO;IAEV,MAAM;QACd,OAAO,IAAI,CAAA,gBAAgB,IAAI,CAAC,SAAS,IAAI,QAAQ;cAC3C,IAAI,CAAC,OAAO,IAAI,QAAQ,CAAC,SAAS,CAAC;eAClC,QAAQ,EAAE;YACb,CAAC;IACX,CAAC;IAED,iBAAiB;QACf,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;IAChF,CAAC;IAES,KAAK,CAAC,YAAY;QAC1B,MAAM,IAAI,CAAC,cAAc,CAAC;QAC1B,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,Y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xD,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,GAAG,cAAc,eAAe,KAAK,CAAC;YACtE,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,KAAK,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;gBAC1B,MAAM,cAAc,GAAG,OAAO,CAAC,KAAK,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;gBAC3D,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,GAAG,cAAc,cAAc,KAAK,CAAC;YACrE,CAAC;iBAAM,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;gBACpB,MAAM,aAAa,GAAG,CAAC,IAAI,CAAC;gBAC5B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,GAAG,cAAc,aAAa,KAAK,CAAC;YACpE,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,GAAG,EAAE,CAAC;YACtC,CAAC;QACH,CAAC;IACH,CAAC;;AA/GsB;IAAtB,KAAK,CAAC,MAAM,CAAC;yCAA4B;AAClB;IAAvB,KAAK,CAAC,OAAO,CAAC;6CAAgC;AAJpC,UAAU;IADtB,MAAM,CAAC,UAAU,CAAC;GACN,UAAU,CAmHtB;;AAED,eAAe,UAAU,CAAC","sourcesContent":["import { css, type CSSResultGroup, html, query } from \"../../deps.js\";\nimport { htmlSlot, type HTMLTemplate } from \"../../lib/templates.js\";\nimport { debounce } from \"../../lib/utils.js\";\nimport { define } from \"../../root.js\";\nimport { type Direction4, OpenableElement } from \"./open.js\";\n\nconst defineName = \"open-offset\";\n\n/**\n * OpenOffset will calculate a lateral offset to try to keep the content within the allowable range.\n *\n * Content can be opened in 4 directions.\n */\n@define(defineName)\nexport class OpenOffset extends OpenableElement {\n direction: Direction4;\n\n @query(\"span\") private _span: HTMLElement;\n @query(\"aside\") private _balancer: HTMLElement;\n\n static styles = [\n css`\n :host {\n display: block;\n height: fit-content;\n width: fit-content;\n }\n\n span {\n user-select: none;\n }\n\n main {\n height: inherit;\n width: inherit;\n display: flex;\n position: relative;\n align-items: center;\n }\n\n aside {\n background-color: inherit;\n visibility: hidden;\n top: 100%;\n z-index: 1;\n }\n\n :host([open]) aside {\n visibility: visible;\n }\n\n :host([float]) aside {\n position: absolute;\n }\n `,\n css`\n .left {\n flex-direction: row-reverse;\n }\n .right {\n flex-direction: row;\n }\n .top {\n flex-direction: column-reverse;\n }\n .bottom {\n flex-direction: column;\n }\n `,\n ] as CSSResultGroup;\n\n protected render(): HTMLTemplate {\n return html`<main class=\"${this.direction || \"bottom\"}\">\n <span>${this.summary || htmlSlot(\"summary\")}</span>\n <aside>${htmlSlot()}</aside>\n </main>`;\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.addEvent(window, \"resize\", debounce(this._handelResize.bind(this), 500));\n }\n\n protected async firstUpdated() {\n await this.updateComplete;\n this.addEvent(document, \"click\", this._handelClick.bind(this));\n this.resize();\n }\n\n protected _handelClick(e: MouseEvent) {\n if (e.target === this) {\n this.show();\n } else if (!this.contains(e.target as HTMLElement)) {\n this.close();\n }\n }\n\n protected _handelResize() {\n this._balancer.style.transform = \"none\";\n this.resize();\n }\n\n resize() {\n if (!this._balancer) {\n return;\n }\n const offsets = this.offsetParent?.getBoundingClientRect() || document.body.getBoundingClientRect();\n const { left, right, top, bottom, height } = this._balancer.getBoundingClientRect();\n if (this.direction === \"left\" || this.direction === \"right\") {\n if (top < offsets.y) {\n const topTranslate = -top;\n this._balancer.style.transform = `translateY(${topTranslate}px)`;\n }\n if (bottom > offsets.bottom) {\n const bottomTranslate = offsets.height - (top + height);\n this._balancer.style.transform = `translateY(${bottomTranslate}px)`;\n }\n } else {\n if (right > offsets.right) {\n const rightTranslate = offsets.width - (right - offsets.x);\n this._balancer.style.transform = `translateX(${rightTranslate}px)`;\n } else if (left < 0) {\n const leftTranslate = -left;\n this._balancer.style.transform = `translateX(${leftTranslate}px)`;\n } else {\n this._balancer.style.transform = \"\";\n }\n }\n }\n}\n\nexport default OpenOffset;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"open-offset\": OpenOffset;\n }\n}\n"]}
1
+ {"version":3,"file":"open-offset.js","sourceRoot":"https://github.com/startracex/godown/tree/main/src/","sources":["web-components/open/open-offset.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAuB,IAAI,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAqB,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAmB,eAAe,EAAE,MAAM,WAAW,CAAC;AAE7D,MAAM,UAAU,GAAG,aAAa,CAAC;AAEjC;;;;GAIG;AAEI,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,eAAe;IAwDnC,MAAM;QACd,OAAO,IAAI,CAAA,gBAAgB,IAAI,CAAC,SAAS,IAAI,QAAQ;cAC3C,IAAI,CAAC,OAAO,IAAI,QAAQ,CAAC,SAAS,CAAC;eAClC,QAAQ,EAAE;YACb,CAAC;IACX,CAAC;IAED,iBAAiB;QACf,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;IAChF,CAAC;IAES,KAAK,CAAC,YAAY;QAC1B,MAAM,IAAI,CAAC,cAAc,CAAC;QAC1B,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/D,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAES,YAAY,CAAC,CAAa;QAClC,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K,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;gBAC1B,MAAM,cAAc,GAAG,OAAO,CAAC,KAAK,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;gBAC3D,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,GAAG,cAAc,cAAc,KAAK,CAAC;YACrE,CAAC;iBAAM,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;gBACpB,MAAM,aAAa,GAAG,CAAC,IAAI,CAAC;gBAC5B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,GAAG,cAAc,aAAa,KAAK,CAAC;YACpE,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,GAAG,EAAE,CAAC;YACtC,CAAC;QACH,CAAC;IACH,CAAC;;AA5GM,iBAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiCF;IACD,GAAG,CAAA;;;;;;;;;;;;;KAaF;CACgB,AAjDN,CAiDO;AAnDI;IAAvB,KAAK,CAAC,OAAO,CAAC;6CAAgC;AAHpC,UAAU;IADtB,MAAM,CAAC,UAAU,CAAC;GACN,UAAU,CAkHtB;;AAED,eAAe,UAAU,CAAC","sourcesContent":["import { css, type CSSResultGroup, html, query } from \"../../deps.js\";\nimport { htmlSlot, type HTMLTemplate } from \"../../lib/templates.js\";\nimport { debounce } from \"../../lib/utils.js\";\nimport { define } from \"../../root.js\";\nimport { type Direction4, OpenableElement } from \"./open.js\";\n\nconst defineName = \"open-offset\";\n\n/**\n * OpenOffset will calculate a lateral offset to try to keep the content within the allowable range.\n *\n * Content can be opened in 4 directions.\n */\n@define(defineName)\nexport class OpenOffset extends OpenableElement {\n direction: Direction4;\n\n @query(\"aside\") private _balancer: HTMLElement;\n\n static styles = [\n css`\n :host {\n display: block;\n height: fit-content;\n width: fit-content;\n }\n\n span {\n user-select: none;\n }\n\n main {\n height: inherit;\n width: inherit;\n display: flex;\n position: relative;\n align-items: center;\n }\n\n aside {\n background-color: inherit;\n visibility: hidden;\n top: 100%;\n z-index: 1;\n }\n\n :host([open]) aside {\n visibility: visible;\n }\n\n :host([float]) aside {\n position: absolute;\n }\n `,\n css`\n .left {\n flex-direction: row-reverse;\n }\n .right {\n flex-direction: row;\n }\n .top {\n flex-direction: column-reverse;\n }\n .bottom {\n flex-direction: column;\n }\n `,\n ] as CSSResultGroup;\n\n protected render(): HTMLTemplate {\n return html`<main class=\"${this.direction || \"bottom\"}\">\n <span>${this.summary || htmlSlot(\"summary\")}</span>\n <aside>${htmlSlot()}</aside>\n </main>`;\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.addEvent(window, \"resize\", debounce(this._handelResize.bind(this), 500));\n }\n\n protected async firstUpdated() {\n await this.updateComplete;\n this.addEvent(document, \"click\", this._handelClick.bind(this));\n this.resize();\n }\n\n protected _handelClick(e: MouseEvent) {\n if (e.target === this) {\n this.show();\n } else if (!this.contains(e.target as HTMLElement)) {\n this.close();\n }\n }\n\n protected _handelResize() {\n this._balancer.style.transform = \"none\";\n this.resize();\n }\n\n resize() {\n if (!this._balancer) {\n return;\n }\n const offsets = this.offsetParent?.getBoundingClientRect() || document.body.getBoundingClientRect();\n const { left, right, top, bottom, height } = this._balancer.getBoundingClientRect();\n if (this.direction === \"left\" || this.direction === \"right\") {\n if (top < offsets.y) {\n const topTranslate = -top;\n this._balancer.style.transform = `translateY(${topTranslate}px)`;\n }\n if (bottom > offsets.bottom) {\n const bottomTranslate = offsets.height - (top + height);\n this._balancer.style.transform = `translateY(${bottomTranslate}px)`;\n }\n } else {\n if (right > offsets.right) {\n const rightTranslate = offsets.width - (right - offsets.x);\n this._balancer.style.transform = `translateX(${rightTranslate}px)`;\n } else if (left < 0) {\n const leftTranslate = -left;\n this._balancer.style.transform = `translateX(${leftTranslate}px)`;\n } else {\n this._balancer.style.transform = \"\";\n }\n }\n }\n}\n\nexport default OpenOffset;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"open-offset\": OpenOffset;\n }\n}\n"]}