godown 3.5.3 → 3.6.1

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 (66) hide show
  1. package/build/godown+lit.iife.js +2 -2
  2. package/build/godown+lit.iife.js.map +1 -1
  3. package/build/godown+lit.js +3 -3
  4. package/build/godown+lit.js.map +1 -1
  5. package/build/godown+lit.umd.js +2 -2
  6. package/build/godown+lit.umd.js.map +1 -1
  7. package/build/godown.iife.js +4 -4
  8. package/build/godown.js +6 -6
  9. package/build/godown.js.map +1 -1
  10. package/build/godown.umd.js +4 -4
  11. package/build/godown.umd.js.map +1 -1
  12. package/components/alert.js +1 -1
  13. package/components/alert.js.map +1 -1
  14. package/components/avatar.js +1 -1
  15. package/components/avatar.js.map +1 -1
  16. package/components/badge.d.ts +1 -1
  17. package/components/badge.d.ts.map +1 -1
  18. package/components/badge.js +1 -1
  19. package/components/badge.js.map +1 -1
  20. package/components/button.js +1 -1
  21. package/components/button.js.map +1 -1
  22. package/components/card.js +1 -1
  23. package/components/card.js.map +1 -1
  24. package/components/details.d.ts +4 -0
  25. package/components/details.d.ts.map +1 -1
  26. package/components/details.js +1 -1
  27. package/components/details.js.map +1 -1
  28. package/components/dialog.d.ts +4 -6
  29. package/components/dialog.d.ts.map +1 -1
  30. package/components/dialog.js +1 -1
  31. package/components/dialog.js.map +1 -1
  32. package/components/divider.js +1 -1
  33. package/components/divider.js.map +1 -1
  34. package/components/layout.d.ts +10 -4
  35. package/components/layout.d.ts.map +1 -1
  36. package/components/layout.js +1 -1
  37. package/components/layout.js.map +1 -1
  38. package/components/split.js +1 -1
  39. package/components/split.js.map +1 -1
  40. package/core/global-style.d.ts +1 -0
  41. package/core/global-style.d.ts.map +1 -1
  42. package/core/global-style.js +1 -1
  43. package/core/global-style.js.map +1 -1
  44. package/core/outline.d.ts +2 -1
  45. package/core/outline.d.ts.map +1 -1
  46. package/core/outline.js +1 -1
  47. package/core/outline.js.map +1 -1
  48. package/core/super-input.js +1 -1
  49. package/core/super-input.js.map +1 -1
  50. package/custom-elements.json +1 -1
  51. package/package.json +2 -2
  52. package/src/components/alert.ts +0 -2
  53. package/src/components/avatar.ts +3 -5
  54. package/src/components/badge.ts +9 -11
  55. package/src/components/button.ts +0 -1
  56. package/src/components/card.ts +0 -1
  57. package/src/components/details.ts +25 -21
  58. package/src/components/dialog.ts +59 -70
  59. package/src/components/divider.ts +1 -2
  60. package/src/components/layout.ts +30 -31
  61. package/src/components/split.ts +1 -1
  62. package/src/core/global-style.ts +8 -0
  63. package/src/core/outline.ts +10 -1
  64. package/src/core/super-input.ts +0 -1
  65. package/vscode.html-custom-data.json +1 -1
  66. package/web-types.json +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "godown",
3
- "version": "3.5.3",
3
+ "version": "3.6.1",
4
4
  "description": "Non Composite Web Components Library",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -19,8 +19,8 @@
19
19
  "fmtime": "^0.0.3",
20
20
  "lit": "^3.0.0",
21
21
  "tslib": "^2.7.0",
22
- "@godown/colors": "^1.0.0",
23
22
  "@godown/element": "^1.3.1",
23
+ "@godown/colors": "^1.0.0",
24
24
  "@godown/f7-icon": "^1.0.4"
25
25
  },
26
26
  "publishConfig": {
@@ -90,12 +90,10 @@ const calls = {
90
90
  @styles(css`
91
91
  :host,
92
92
  :where(:host([contents]) [part="root"]) {
93
- ${cssScope}--border-radius: .2em;
94
93
  ${cssScope}--border-width: .075em;
95
94
  ${cssScope}--blockquote-width: .2em;
96
95
  ${cssScope}--blockquote-background: transparent;
97
96
  ${cssScope}--gap: .5em;
98
- border-radius: var(${cssScope}--border-radius);
99
97
  display: block;
100
98
  width: 100%;
101
99
  }
@@ -19,12 +19,11 @@ const cssScope = scopePrefix(protoName);
19
19
  @godown(protoName)
20
20
  @styles(css`
21
21
  :host {
22
- ${cssScope}--size: 2em;
23
- width: var(${cssScope}--size);
24
- height: var(${cssScope}--size);
25
22
  background: var(${cssGlobalVars.passive});
26
23
  vertical-align: bottom;
27
- border-radius: 0.2em;
24
+ overflow: hidden;
25
+ width: 2em;
26
+ height: 2em;
28
27
  }
29
28
 
30
29
  :host,
@@ -49,7 +48,6 @@ const cssScope = scopePrefix(protoName);
49
48
  }
50
49
 
51
50
  [part="root"] {
52
- overflow: hidden;
53
51
  position: relative;
54
52
  border-radius: inherit;
55
53
  width: 100%;
@@ -3,7 +3,7 @@ import { type TemplateResult, css, html } from "lit";
3
3
  import { property } from "lit/decorators.js";
4
4
 
5
5
  import { GlobalStyle, cssGlobalVars, scopePrefix } from "../core/global-style.js";
6
- import { DirectionCorner } from "../core/direction.js";
6
+ import type { DirectionCorner } from "../core/direction.js";
7
7
 
8
8
  const protoName = "badge";
9
9
  const cssScope = scopePrefix(protoName);
@@ -39,8 +39,6 @@ const cssScope = scopePrefix(protoName);
39
39
  user-select: none;
40
40
  border-radius: calc(infinity * 1px);
41
41
  transform: translate(-50%, -50%);
42
- left: var(--left);
43
- top: var(--top);
44
42
  background: var(${cssScope}--background);
45
43
  }
46
44
 
@@ -52,20 +50,20 @@ const cssScope = scopePrefix(protoName);
52
50
  border-radius: 50%;
53
51
  }
54
52
 
55
- [position^="top"] {
56
- --top: calc(0% + var(${cssScope}--offset-y));
53
+ [position^="top"] [part="badge"] {
54
+ top: calc(0% + var(${cssScope}--offset-y));
57
55
  }
58
56
 
59
- [position$="right"] {
60
- --left: calc(100% - var(${cssScope}--offset-x));
57
+ [position$="right"] [part="badge"] {
58
+ left: calc(100% - var(${cssScope}--offset-x));
61
59
  }
62
60
 
63
- [position^="bottom"] {
64
- --top: calc(100% - var(${cssScope}--offset-y));
61
+ [position^="bottom"] [part="badge"] {
62
+ top: calc(100% - var(${cssScope}--offset-y));
65
63
  }
66
64
 
67
- [position$="left"] {
68
- --left: calc(0% + var(${cssScope}--offset-x));
65
+ [position$="left"] [part="badge"] {
66
+ left: calc(0% + var(${cssScope}--offset-x));
69
67
  }
70
68
  `)
71
69
  class Badge extends GlobalStyle {
@@ -132,7 +132,6 @@ const colors: Record<Colors, string> = constructCSSObject(
132
132
  var(${cssScope}--gradients, var(${cssScope}--background))
133
133
  );
134
134
  padding: var(${cssScope}--padding);
135
- border-radius: 0.2em;
136
135
  width: fit-content;
137
136
  display: block;
138
137
  overflow: hidden;
@@ -28,7 +28,6 @@ const cssScope = scopePrefix(protoName);
28
28
  border-width: var(${cssScope}--border-width);
29
29
  display: block;
30
30
  flex-shrink: 0;
31
- border-radius: 0.2em;
32
31
  }
33
32
 
34
33
  slot {
@@ -23,54 +23,54 @@ const cssScope = scopePrefix(protoName);
23
23
  :host {
24
24
  ${cssScope}--icon-deg-open: 0deg;
25
25
  ${cssScope}--icon-deg-close: 90deg;
26
- ${cssScope}--icon-space: 0.3em;
27
- ${cssScope}--summary-direction: row;
28
- ${cssScope}--transition: .3s;
29
- height: fit-content;
26
+ ${cssScope}--icon-space: .22em;
30
27
  display: block;
31
- transition: var(${cssScope}--transition);
28
+ transition: 0.3s;
32
29
  }
33
30
 
34
31
  [part="root"] {
35
32
  height: 100%;
36
33
  position: relative;
37
- overflow: hidden;
38
34
  }
39
35
 
40
36
  [part="title"] {
41
37
  direction: ltr;
42
38
  height: 100%;
43
- display: flex;
44
- flex-wrap: nowrap;
45
- justify-content: space-between;
46
- background: inherit;
39
+ display: grid;
47
40
  align-items: center;
48
- flex-direction: var(${cssScope}--summary-direction);
41
+ justify-content: space-between;
42
+ grid-template-columns: auto auto;
43
+ transition: inherit;
44
+ overflow: hidden;
49
45
  }
50
46
 
51
47
  [part="details"] {
52
- display: grid;
53
48
  overflow: hidden;
49
+ display: grid;
54
50
  grid-template-rows: 0fr;
55
- transition: var(${cssScope}--transition);
56
- transition-property: grid-template-rows;
51
+ transition: inherit;
57
52
  }
58
53
 
59
54
  :host([open]) [part="details"] {
60
55
  grid-template-rows: 1fr;
61
56
  }
62
57
 
63
- :host([float]) [part="details"] {
64
- top: 100%;
58
+ [float] [part="details"] {
65
59
  position: absolute;
60
+ top: 100%;
61
+ width: 100%;
62
+ }
63
+
64
+ [part] {
65
+ transition: inherit;
66
+ transition-property: transform, grid-template-rows;
66
67
  }
67
68
 
68
69
  [part="icon"] {
69
70
  display: flex;
70
71
  backface-visibility: hidden;
71
- padding: var(${cssScope}--icon-space);
72
- transition: var(${cssScope}--transition);
73
72
  transform: rotate(var(${cssScope}--icon-deg-close));
73
+ padding: var(${cssScope}--icon-space);
74
74
  }
75
75
 
76
76
  :host([open]) [part="icon"] {
@@ -78,6 +78,12 @@ const cssScope = scopePrefix(protoName);
78
78
  }
79
79
  `)
80
80
  class Details extends SuperOpenable {
81
+ /**
82
+ * Determines whether the details component should float.
83
+ */
84
+ @property({ type: Boolean })
85
+ float = false;
86
+
81
87
  /**
82
88
  * Determines whether the details component should fill the available space.
83
89
  */
@@ -101,9 +107,7 @@ class Details extends SuperOpenable {
101
107
  @click="${() => this.toggle()}"
102
108
  >
103
109
  <span part="summary">${this.summary || htmlSlot("summary")}</span>
104
- <span>
105
- <i part="icon">${svgCaretDown()}</i>
106
- </span>
110
+ <span part="icon">${svgCaretDown()}</span>
107
111
  </dt>
108
112
  <dd
109
113
  part="details"
@@ -1,15 +1,9 @@
1
1
  import { type HandlerEvent, attr, godown, htmlSlot, styles } from "@godown/element";
2
2
  import { type PropertyValues, type TemplateResult, css, html } from "lit";
3
- import { property } from "lit/decorators.js";
3
+ import { property, query } from "lit/decorators.js";
4
4
 
5
5
  import { scopePrefix } from "../core/global-style.js";
6
6
  import { SuperOpenable } from "../core/super-openable.js";
7
- import {
8
- type DirectionCardinal,
9
- type DirectionCenter,
10
- type DirectionCorner,
11
- directionInsetAlign,
12
- } from "../core/direction.js";
13
7
 
14
8
  const protoName = "dialog";
15
9
  const cssScope = scopePrefix(protoName);
@@ -25,65 +19,50 @@ const cssScope = scopePrefix(protoName);
25
19
  * @category feedback
26
20
  */
27
21
  @godown(protoName)
28
- @styles(
29
- directionInsetAlign,
30
- css`
31
- :host {
32
- ${cssScope}--background: none;
33
- ${cssScope}--background-modal: black;
34
- ${cssScope}--opacity-modal: 0.2;
35
- background: var(${cssScope}--background);
36
- pointer-events: none;
37
- position: fixed;
38
- z-index: 1;
39
- inset: 0;
40
- }
41
-
42
- :host(:not([open])) {
43
- visibility: hidden;
44
- }
22
+ @styles(css`
23
+ :host {
24
+ ${cssScope}--background-modal: black;
25
+ ${cssScope}--opacity-modal: 0.2;
26
+ width: fit-content;
27
+ display: block;
28
+ margin: auto;
29
+ background: none;
30
+ left: 50%;
31
+ top: 50%;
32
+ position: fixed;
33
+ transform: translate(-50%, -50%);
34
+ }
45
35
 
46
- :host([modal]) [part="modal"] {
47
- pointer-events: all;
48
- opacity: var(${cssScope}--opacity-modal);
49
- }
36
+ :host(:not([open])) {
37
+ visibility: hidden;
38
+ }
50
39
 
51
- [part="modal"] {
52
- visibility: inherit;
53
- opacity: 0;
54
- width: 100%;
55
- height: 100%;
56
- position: absolute;
57
- background: var(${cssScope}--background-modal);
58
- }
40
+ :host([contents]) dialog {
41
+ position: fixed;
42
+ }
59
43
 
60
- [part="root"] {
61
- width: 100%;
62
- height: 100%;
63
- display: flex;
64
- position: relative;
65
- align-items: center;
66
- justify-content: center;
67
- }
44
+ dialog {
45
+ position: relative;
46
+ background: inherit;
47
+ }
68
48
 
69
- [part="container"] {
70
- pointer-events: all;
71
- position: absolute;
72
- }
73
- `,
74
- )
49
+ ::backdrop {
50
+ background: var(${cssScope}--background-modal);
51
+ opacity: var(${cssScope}--opacity-modal);
52
+ }
53
+ `)
75
54
  class Dialog extends SuperOpenable {
76
- /**
77
- * The direction of the dialog container.
78
- */
79
- @property()
80
- direction: DirectionCardinal | DirectionCorner | DirectionCenter;
81
-
82
55
  /**
83
56
  * Indicates whether the dialog should be displayed as a modal.
84
57
  */
85
58
  @property({ type: Boolean, reflect: true })
86
- modal = false;
59
+ set modal(value: boolean) {
60
+ this.contents = value;
61
+ }
62
+
63
+ get modal(): boolean {
64
+ return this.contents;
65
+ }
87
66
 
88
67
  /**
89
68
  * The keys will close the dialog when pressed.
@@ -96,31 +75,41 @@ class Dialog extends SuperOpenable {
96
75
  */
97
76
  private __modalInvoke = false;
98
77
 
78
+ @query("dialog")
79
+ protected _dialog: HTMLDialogElement;
80
+
99
81
  protected render(): TemplateResult<1> {
100
82
  return html`
101
- <div
83
+ <dialog
102
84
  part="root"
103
85
  ${attr(this.observedRecord)}
104
86
  >
105
- <div part="modal"></div>
106
- <div
107
- part="container"
108
- direction-inset-align
109
- >
110
- ${htmlSlot()}
111
- </div>
112
- </div>
87
+ ${htmlSlot()}
88
+ </dialog>
113
89
  `;
114
90
  }
115
91
 
116
92
  showModal(): void {
117
- if (!this.modal) {
118
- this.modal = true;
119
- this.__modalInvoke = true;
120
- }
93
+ this.modal = true;
94
+ this.__modalInvoke = true;
121
95
  this.show();
122
96
  }
123
97
 
98
+ attributeChangedCallback(name: string, _old: string | null, value: string | null): void {
99
+ super.attributeChangedCallback(name, _old, value);
100
+ if (name === "open") {
101
+ if (this.open) {
102
+ if (this.modal) {
103
+ this._dialog.showModal();
104
+ } else {
105
+ this._dialog.show();
106
+ }
107
+ } else {
108
+ this._dialog.close();
109
+ }
110
+ }
111
+ }
112
+
124
113
  private __submitEvent: EventListenerOrEventListenerObject;
125
114
  private __keydownEvent: EventListenerOrEventListenerObject;
126
115
 
@@ -16,7 +16,6 @@ const protoName = "divider";
16
16
  :host {
17
17
  width: 100%;
18
18
  height: 0.05em;
19
- margin: auto;
20
19
  display: block;
21
20
  background: currentColor;
22
21
  color: var(${cssGlobalVars.passive});
@@ -24,7 +23,7 @@ const protoName = "divider";
24
23
 
25
24
  :host([vertical]) {
26
25
  width: 0.05em;
27
- height: max(1em, 100%);
26
+ height: 100%;
28
27
  }
29
28
 
30
29
  :host([contents]) [part="root"] {
@@ -7,7 +7,13 @@ import { GlobalStyle } from "../core/global-style.js";
7
7
  const protoName = "layout";
8
8
 
9
9
  /**
10
- * {@linkcode Layout} renders slot and optional top header, bottom footer.
10
+ * {@linkcode Layout} renders main content, top header, bottom footer.
11
+ *
12
+ * If `sticky` is set to `true`, the header will be sticky.
13
+ *
14
+ * Main content will take up the remaining space.
15
+ *
16
+ * Element display should be `(inline-)flex` or `(inline-)grid`.
11
17
  *
12
18
  * @slot - The main content of the layout.
13
19
  * @slot header - The header of the layout.
@@ -16,50 +22,51 @@ const protoName = "layout";
16
22
  */
17
23
  @godown(protoName)
18
24
  @styles(css`
25
+ :host {
26
+ width: 100%;
27
+ min-height: 100%;
28
+ flex-direction: column;
29
+ grid-template-rows: auto 1fr auto;
30
+ }
31
+
19
32
  :host,
20
33
  :host([contents]) [part="root"] {
21
- min-height: 100%;
22
34
  display: flex;
23
- flex-direction: column;
24
35
  }
25
36
 
26
37
  [part="root"] {
27
38
  display: contents;
28
39
  }
29
40
 
30
- [sticky] header {
31
- position: sticky;
32
- top: 0;
33
- z-index: 1;
34
- }
35
-
36
41
  [part="main"] {
37
- position: relative;
38
- flex: 1;
39
42
  width: 100%;
43
+ flex: 1;
40
44
  }
41
45
 
42
- header,
43
- main,
44
- footer {
46
+ [part="header"],
47
+ [part="footer"] {
48
+ flex-shrink: 0;
45
49
  width: 100%;
46
50
  }
51
+
52
+ [sticky] header {
53
+ position: sticky;
54
+ top: 0;
55
+ }
47
56
  `)
48
57
  class Layout extends GlobalStyle {
49
58
  /**
50
- * If true, remove the header slot.
59
+ * @deprecated Omit header slot instead.
51
60
  */
52
- @property({ type: Boolean })
53
- noHeader = false;
61
+ noHeader: boolean;
54
62
 
55
63
  /**
56
- * If true, remove the footer slot.
64
+ * @deprecated Omit footer slot instead.
57
65
  */
58
- @property({ type: Boolean })
59
- noFooter = false;
66
+ noFooter: boolean;
60
67
 
61
68
  /**
62
- * If true, header will sticky.
69
+ * If `true`, header will sticky.
63
70
  */
64
71
  @property({ type: Boolean })
65
72
  sticky = false;
@@ -70,17 +77,9 @@ class Layout extends GlobalStyle {
70
77
  part="root"
71
78
  ${attr(this.observedRecord)}
72
79
  >
73
- ${!this.noHeader
74
- ? html`
75
- <header part="header">${htmlSlot("header")}</header>
76
- `
77
- : ""}
80
+ <header part="header">${htmlSlot("header")}</header>
78
81
  <main part="main">${htmlSlot()}</main>
79
- ${!this.noFooter
80
- ? html`
81
- <footer part="footer">${htmlSlot("footer")}</footer>
82
- `
83
- : ""}
82
+ <footer part="footer">${htmlSlot("footer")}</footer>
84
83
  </div>
85
84
  `;
86
85
  }
@@ -25,7 +25,7 @@ const cssScope = scopePrefix(protoName);
25
25
  @styles(css`
26
26
  :host {
27
27
  display: block;
28
- border-radius: 1px;
28
+ border-radius: 0.1em;
29
29
  width: fit-content;
30
30
  ${cssScope}--size: 1.45em;
31
31
  ${cssScope}--gap: .25em;
@@ -25,6 +25,7 @@ export const cssGlobalVars: {
25
25
  white: CSSResult;
26
26
  black: CSSResult;
27
27
  color: CSSResult;
28
+ borderRadius: CSSResult;
28
29
  } = {
29
30
  clipBackground: scopePrefix("clip-background", 2),
30
31
  active: scopePrefix("active", 2),
@@ -34,6 +35,7 @@ export const cssGlobalVars: {
34
35
  white: scopePrefix("color-white", 2),
35
36
  black: scopePrefix("color-black", 2),
36
37
  color: scopePrefix("color", 2),
38
+ borderRadius: scopePrefix("border-radius", 2),
37
39
  };
38
40
 
39
41
  type PresetsGradientsCSSResult = Record<keyof typeof presetsRGB, Gradients<CSSResult>>;
@@ -95,4 +97,10 @@ GlobalStyle.styles = [
95
97
  display: revert;
96
98
  }
97
99
  `,
100
+ css`
101
+ :host {
102
+ ${cssGlobalVars.borderRadius}: 0.2em;
103
+ border-radius: var(${cssGlobalVars.borderRadius});
104
+ }
105
+ `,
98
106
  ];
@@ -51,4 +51,13 @@ export class OutlineBuilder {
51
51
  }
52
52
  }
53
53
 
54
- export type OutlineType = "outline" | "outline-inset" | "box-shadow" | "box-shadow-inset" | "border";
54
+ export type OutlineType =
55
+ | "outline"
56
+ | "outline-inset"
57
+ | "box-shadow"
58
+ | "box-shadow-inset"
59
+ | "border"
60
+ | "none"
61
+ | undefined;
62
+
63
+ export const isNone = (type: OutlineType): boolean => !type || type === "none";
@@ -53,7 +53,6 @@ const inputStyle = css`
53
53
  ${cssGlobalVars.input}-outline-width: .075em;
54
54
  ${cssGlobalVars.input}-outline-color: var(${cssGlobalVars._colors.darkgray[4]});
55
55
  ${cssGlobalVars.input}-icon-color: var(${cssGlobalVars._colors.darkgray[4]});
56
- border-radius: 0.2em;
57
56
  }
58
57
 
59
58
  :host([disabled]) {