godown 3.1.0 → 3.2.0

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 (55) hide show
  1. package/README.md +2 -2
  2. package/build/godown+lit.iife.js +4 -4
  3. package/build/godown+lit.iife.js.map +1 -1
  4. package/build/godown+lit.js +6 -6
  5. package/build/godown+lit.js.map +1 -1
  6. package/build/godown+lit.umd.js +4 -4
  7. package/build/godown+lit.umd.js.map +1 -1
  8. package/build/godown.iife.js +2 -2
  9. package/build/godown.js +3 -3
  10. package/build/godown.js.map +1 -1
  11. package/build/godown.umd.js +2 -2
  12. package/build/godown.umd.js.map +1 -1
  13. package/components/link.d.ts +34 -7
  14. package/components/link.d.ts.map +1 -1
  15. package/components/link.js +1 -1
  16. package/components/link.js.map +1 -1
  17. package/components/range.js +1 -1
  18. package/components/range.js.map +1 -1
  19. package/components/router.d.ts +9 -1
  20. package/components/router.d.ts.map +1 -1
  21. package/components/router.js +1 -1
  22. package/components/router.js.map +1 -1
  23. package/components/split.d.ts.map +1 -1
  24. package/components/split.js +1 -1
  25. package/components/split.js.map +1 -1
  26. package/core/super-anchor.d.ts +1 -0
  27. package/core/super-anchor.d.ts.map +1 -1
  28. package/core/super-anchor.js +1 -1
  29. package/core/super-anchor.js.map +1 -1
  30. package/custom-elements.json +1 -1
  31. package/dev/components/link.d.ts +34 -7
  32. package/dev/components/link.d.ts.map +1 -1
  33. package/dev/components/link.js +70 -12
  34. package/dev/components/link.js.map +1 -1
  35. package/dev/components/range.js +2 -2
  36. package/dev/components/range.js.map +1 -1
  37. package/dev/components/router.d.ts +9 -1
  38. package/dev/components/router.d.ts.map +1 -1
  39. package/dev/components/router.js +26 -18
  40. package/dev/components/router.js.map +1 -1
  41. package/dev/components/split.d.ts.map +1 -1
  42. package/dev/components/split.js +1 -8
  43. package/dev/components/split.js.map +1 -1
  44. package/dev/core/super-anchor.d.ts +1 -0
  45. package/dev/core/super-anchor.d.ts.map +1 -1
  46. package/dev/core/super-anchor.js +3 -4
  47. package/dev/core/super-anchor.js.map +1 -1
  48. package/package.json +3 -3
  49. package/src/components/link.ts +75 -12
  50. package/src/components/range.ts +2 -2
  51. package/src/components/router.ts +30 -18
  52. package/src/components/split.ts +1 -9
  53. package/src/core/super-anchor.ts +5 -1
  54. package/vscode.html-custom-data.json +1 -1
  55. package/web-types.json +1 -1
@@ -6,41 +6,104 @@ import Router from "./router.js";
6
6
 
7
7
  const protoName = "link";
8
8
 
9
+ const linkTypes = {
10
+ push: "push",
11
+ replace: "replace",
12
+ normal: "normal",
13
+ auto: "auto",
14
+ } as const;
15
+
16
+ type LinkType = keyof typeof linkTypes;
17
+
9
18
  /**
10
- * {@linkcode Link} is used for link jumping.
19
+ * {@linkcode Link} is used for link jumping, works standalone or in {@linkcode Router}.
20
+ *
21
+ * Set `type` to `"normal"`,
22
+ * behave like a normal anchor.
11
23
  *
12
24
  * Set `type` to `"push" `or `"replace"`,
13
- * will invoke the history api and trigger the {@linkcode Router.updateAll}.
25
+ * update history state by `history.pushState` or `history.replaceState`,
26
+ * update all routers whether current pathname is registered or not.
27
+ *
28
+ * Set `type` to `"auto"`,
29
+ * only update the routers if the current pathname is registered,
30
+ * if not registered, behave like `"normal"`.
14
31
  *
32
+ * `replace` property will enforce `history.replaceState`.
33
+ *
34
+ * @fires navigate - Fires when the link is clicked.
15
35
  * @category navigation
16
36
  */
17
37
  @godown(protoName)
18
38
  class Link extends SuperAnchor {
19
39
  /**
20
- * If "push", call `history.pushState`.
40
+ * If `"normal"`, behave like a normal anchor.
21
41
  *
22
- * If "replace", call `history.replaceState`.
42
+ * If `"auto"` or `"push"`, call `history.pushState` if `replace` is false,
23
43
  *
24
- * If "normal", behave like a normal anchor.
44
+ * If `"replace"`, call `history.replaceState`.
25
45
  */
26
46
  @property()
27
- type: "push" | "replace" | "normal" = "normal";
47
+ type: LinkType = linkTypes.auto;
28
48
 
29
49
  /**
30
- * Suppress the update of the {@linkcode Router}.
50
+ * If `true`, the {@linkcode Router} will not be updated.
31
51
  */
32
52
  @property({ type: Boolean })
33
53
  suppress = false;
34
54
 
55
+ /**
56
+ * Use `replaceState` instead of `pushState`.
57
+ */
58
+ @property({ type: Boolean })
59
+ replace = false;
60
+
61
+ /**
62
+ * Location state object.
63
+ */
64
+ state = {};
65
+
35
66
  protected _handleClick(e: MouseEvent): void {
36
- if (this.type === "push" || this.type === "replace") {
67
+ const { state, type, href, pathname, suppress } = this;
68
+ this.dispatchCustomEvent("navigate", {
69
+ ...this.observedRecord,
70
+ pathname,
71
+ state,
72
+ });
73
+ if (href.startsWith("#") || type === linkTypes.normal) {
74
+ return;
75
+ }
76
+ this.handleState();
77
+ const routers = [...Router.routerInstances];
78
+ if (
79
+ // only runs when suppress is false
80
+ !suppress &&
81
+ (type !== linkTypes.auto ||
82
+ // in auto mode, only update the routers if the current pathname is registered
83
+ routers.some((i) => i.search(location.pathname)))
84
+ ) {
37
85
  e.preventDefault();
38
- history[`${this.type}State`](null, "", this.href);
39
- if (!this.suppress) {
40
- Router.updateAll();
41
- }
86
+ Router.routerInstances.forEach((i) => {
87
+ i.handlePopstate();
88
+ });
42
89
  }
43
90
  }
91
+
92
+ handleState: () => void = () => {
93
+ switch (this.type) {
94
+ case linkTypes.auto:
95
+ // biome-ignore lint: if replace is true, fallthrough to replace case
96
+ case linkTypes.push:
97
+ if (!this.replace) {
98
+ // type is auto or push and replace is false
99
+ history.pushState(this.state, "", this.href);
100
+ break;
101
+ }
102
+ case linkTypes.replace:
103
+ history.replaceState(this.state, "", this.href);
104
+ break;
105
+ }
106
+ };
44
107
  }
45
108
 
46
109
  export default Link;
@@ -1,4 +1,4 @@
1
- import { attr, classList, godown, isNil, joinProperties, part, styles } from "@godown/element";
1
+ import { attr, classList, godown, isNil, joinProperties, loop, part, styles } from "@godown/element";
2
2
  import { type TemplateResult, css, html } from "lit";
3
3
  import { property, queryAll, state } from "lit/decorators.js";
4
4
 
@@ -223,7 +223,7 @@ class Range extends SuperInput {
223
223
  })}"
224
224
  >
225
225
  <div part="track"></div>
226
- ${this.range ? (this.value as number[]).map((_, index) => this._renderHandle(index)) : this._renderHandle(0)}
226
+ ${loop(this.rangeValue.length, (index) => this._renderHandle(index))}
227
227
  </div>
228
228
  `;
229
229
  }
@@ -21,6 +21,14 @@ interface RouteItem {
21
21
  component?: unknown;
22
22
  }
23
23
 
24
+ const routerTypes = {
25
+ field: "field",
26
+ slotted: "slotted",
27
+ united: "united",
28
+ } as const;
29
+
30
+ type RouterType = keyof typeof routerTypes;
31
+
24
32
  const protoName = "router";
25
33
 
26
34
  /**
@@ -101,7 +109,7 @@ class Router extends GlobalStyle {
101
109
  * This property should not be changed after the rendering is complete.
102
110
  */
103
111
  @property()
104
- type: "united" | "slotted" | "field" = "united";
112
+ type: RouterType = routerTypes.united;
105
113
 
106
114
  /**
107
115
  * Cache accessed records.
@@ -126,22 +134,23 @@ class Router extends GlobalStyle {
126
134
  }
127
135
 
128
136
  protected render(): unknown {
129
- if (this.cache) {
130
- const cached = this.__cacheRecord.get(this.pathname);
131
- if (cached) {
132
- Object.assign(this, cached);
133
- return this.component;
134
- }
137
+ let cached: RouteResult | undefined;
138
+ if (this.cache && (cached = this.__cacheRecord.get(this.pathname))) {
139
+ this.component = cached.component;
140
+ this.path = cached.path;
141
+ this.pathname = cached.pathname;
135
142
  }
136
- switch (this.type) {
137
- case "field":
138
- this.component = this.fieldComponent();
139
- break;
140
- case "slotted":
141
- this.component = this.slottedComponent();
142
- break;
143
- default:
144
- this.component = this.fieldComponent() ?? this.slottedComponent();
143
+ if (!cached) {
144
+ switch (this.type) {
145
+ case routerTypes.field:
146
+ this.component = this.fieldComponent();
147
+ break;
148
+ case routerTypes.slotted:
149
+ this.component = this.slottedComponent();
150
+ break;
151
+ default:
152
+ this.component = this.fieldComponent() ?? this.slottedComponent();
153
+ }
145
154
  }
146
155
  return this.component ?? this.default;
147
156
  }
@@ -179,8 +188,7 @@ class Router extends GlobalStyle {
179
188
  const shouldDispatch = changedProperties.has("pathname") || changedProperties.has("path");
180
189
  if (shouldDispatch) {
181
190
  const ur = this.useRouter();
182
- const noRecord = !this.__cacheRecord.has(this.pathname);
183
- if (noRecord) {
191
+ if (!this.__cacheRecord.has(this.pathname) && this.path) {
184
192
  this.__cacheRecord.set(this.pathname, ur);
185
193
  }
186
194
  this.dispatchEvent(new CustomEvent("change", { detail: ur }));
@@ -258,6 +266,10 @@ class Router extends GlobalStyle {
258
266
  });
259
267
  }
260
268
 
269
+ search(pathname: string): RouteTree {
270
+ return this.__fieldRouteTree.search(pathname) || this.__slottedRouteTree.search(pathname);
271
+ }
272
+
261
273
  handlePopstate: () => void = this.events.add(window, "popstate", () => {
262
274
  this.pathname = location.pathname;
263
275
  });
@@ -1,4 +1,4 @@
1
- import { type HandlerEvent, attr, classList, godown, styles } from "@godown/element";
1
+ import { type HandlerEvent, attr, classList, godown, styles, loop } from "@godown/element";
2
2
  import { type TemplateResult, css, html } from "lit";
3
3
  import { property, state } from "lit/decorators.js";
4
4
 
@@ -8,14 +8,6 @@ import SuperInput from "../core/super-input.js";
8
8
  const protoName = "split";
9
9
  const cssScope = scopePrefix(protoName);
10
10
 
11
- const loop = <T>(len: number, fn: (index?: number) => T) => {
12
- const result: T[] = new Array(len);
13
- for (let index = 0; index < len; index++) {
14
- result[index] = fn(index);
15
- }
16
- return result;
17
- };
18
-
19
11
  /**
20
12
  * {@linkcode Split} renders multiple input boxes.
21
13
  *
@@ -28,13 +28,17 @@ class SuperAnchor extends GlobalStyle {
28
28
  * A element href.
29
29
  */
30
30
  @property()
31
- href: string = undefined;
31
+ href: string;
32
32
  /**
33
33
  * A element target.
34
34
  */
35
35
  @property()
36
36
  target: "_blank" | "_self" | "_parent" | "_top" = "_self";
37
37
 
38
+ get pathname(): string {
39
+ return new URL(this.href, location.href).pathname;
40
+ }
41
+
38
42
  protected render(): TemplateResult<1> {
39
43
  return html`
40
44
  <a
@@ -1 +1 @@
1
- {"version":1.1,"tags":[{"name":"godown-typewriter","description":"Typewriter renders a typewriter effect to text.\n---\n### **Events:**\n ","attributes":[{"name":"content","description":"Raw text.","values":[]},{"name":"ended","description":"If true, hide the cursor","values":[]},{"name":"max","description":"Maximum random time.","values":[]},{"name":"min","description":"Minimum random time.","values":[]},{"name":"delay","description":"Fixed time.","values":[]},{"name":"index","description":"The index at the beginning.","values":[]}],"references":[]},{"name":"godown-tooltip","description":"Tooltip provide tooltip for slot elements.\nIf it has the tip property, ignore the slot tip.\n---\n### **Events:**\n - **change**\n### **Slots:**\n - **tip** - Tip element if no `tip` provided.\n- _default_ - Content.","attributes":[{"name":"tip","description":"Tip text, if there is a value, the slot will be ignored.","values":[]},{"name":"direction","description":"Direction of opening the tip.","values":[{"name":"Direction8"}]},{"name":"align","description":"Content alignment.","values":[{"name":"center"},{"name":"flex-start"},{"name":"flex-end"},{"name":"start"},{"name":"end"}]},{"name":"propagation","description":"If true, allow penetration of the tip.","values":[]},{"name":"type","description":"How can tips be triggered.\nIf `focus`, element will be focusable, open tip when focused.\nIf `hover`, element will open tip when hovered.","values":[{"name":"hover"},{"name":"focus"}]},{"name":"open","description":"Open the content.","values":[]}],"references":[]},{"name":"godown-time","description":"Time renders a formatting time.\n---\n### **Events:**\n - **time** - Fires when the time changes.","attributes":[{"name":"escape","description":"Escape symbol.","values":[]},{"name":"format","description":"Format strings.","values":[]},{"name":"time","description":"Time.","values":[{"name":"Date"}]},{"name":"timeout","description":"If there is a value, update every gap or timeout.","values":[]},{"name":"gap","description":"The number of milliseconds that change with each update.","values":[]}],"references":[]},{"name":"godown-text","description":"Text renders nowrap text.\n---\n","attributes":[{"name":"underline","description":"Underline behavior.","values":[{"name":"none"},{"name":"hover"},{"name":"active"},{"name":"always"}]},{"name":"clip","description":"Set background-clip to text.","values":[]}],"references":[]},{"name":"godown-switch","description":"Switch renders a switch.\nThe switch is rectangular by default,\nset the round property to rounded switch.\n---\n### **Events:**\n - **change** - Fires when the switch is switched.\n- **input**","attributes":[{"name":"round","description":"Display rounded.","values":[]},{"name":"checked","description":"Whether this element is selected or not.","values":[]},{"name":"disabled","description":"Disable this element.","values":[]},{"name":"default","description":"Default checked state.","values":[]},{"name":"value","description":"Input value.","values":[]},{"name":"autocomplete","values":[]},{"name":"type","values":[{"name":"InputType"}]},{"name":"placeholder","values":[]},{"name":"name","values":[]}],"references":[]},{"name":"godown-split","description":"Split renders multiple input boxes.\nInput: will move the focus box backward until the complete input from start to end.\nDelete: will move the focus box forward until the first and no inputs for each.\n---\n### **Events:**\n - **input** - Fires when the input value changes.\n- **focus** - Fires when the input is focused.\n- **blur** - Fires when the input is blurred.\n- **change** - Fires when the input value changes.\n### **Methods:**\n ","attributes":[{"name":"len","description":"The number of input boxes.","values":[]},{"name":"index","description":"Focus index.","values":[]},{"name":"autocomplete","values":[]},{"name":"disabled","values":[]},{"name":"type","values":[{"name":"InputType"}]},{"name":"placeholder","values":[]},{"name":"name","values":[]},{"name":"value","values":[]},{"name":"default","description":"default property records the default or initial value and is used to reset the input.","values":[]}],"references":[]},{"name":"godown-skeleton","description":"Skeleton renders a skeleton screen.\n---\n### **Slots:**\n - **loading** - The content if loading is true.\n- _default_ - The content if loading is false.","attributes":[{"name":"type","description":"If \"image\", render a image placeholder.","values":[{"name":"text"},{"name":"image"}]},{"name":"animation","description":"Animation type.\nopacity animation only effect on slotted element and image icon.","values":[{"name":"position"},{"name":"opacity"}]}],"references":[]},{"name":"godown-select","description":"Select is similar to `<select>`.\nElements with the value attribute/property can be used as options.\nThe checked attribute will be added to the selected element.\nMulti-selected state looks the same as single-selected.\nInput will filter the element.\n---\n### **Events:**\n - **select** - Fires when select an option.\n- **input** - Fires when the input value changes.\n- **change** - Fires when the input value changes.\n### **Slots:**\n - _default_ - Options.","attributes":[{"name":"text","description":"Selected texts.","values":[]},{"name":"direction","values":[{"name":"top"},{"name":"bottom"}]},{"name":"multiple","values":[]},{"name":"visible","values":[]},{"name":"variant","description":"If outline, the outline is always present.","values":[{"name":"default"},{"name":"outline"}]},{"name":"autocomplete","values":[]},{"name":"disabled","values":[]},{"name":"type","values":[{"name":"InputType"}]},{"name":"placeholder","values":[]},{"name":"name","values":[]},{"name":"value","values":[]},{"name":"default","description":"default property records the default or initial value and is used to reset the input.","values":[]}],"references":[]},{"name":"godown-router","description":"Router has basic routing control.\nTo switch routes, use `router-link component`.\nIt has two methods to collect routes.\n1. From field `routes`, an array, each elements require \"path\".\n2. From child elements, which have the slot attribute for matching routes.\nIf only the method 1 is used, set `type` to `\"field\"`.\nIf only the method 2 is used, set `type` to `\"slotted\"`.\n`type` defaults to `\"united\"`, which will try method 1, then method 2.\nIf no routes are matched, the default value (no named slot) will be rendered.\n---\n### **Events:**\n - **change**\n### **Methods:**\n - **fieldComponent(query: _string_): _unknown_** - Get component from routes by query.\n- **slottedComponent(query: _string_): _TemplateResult<1>_** - Get component from slotted elements by query.\n- **collectSlottedRoutes(): _void_** - Reset the route tree, clear cache, collect routes from child elements.\n- **collectFieldRoutes(value: _typeof this.routes_): _void_** - Reset the route tree, clear cache, collect routes from value.\n### **Slots:**\n - _default_ - Display slot when there is no match.\n- ***** - Matching slot will be displayed.","attributes":[{"name":"pathname","description":"Current pathname (equals to location.pathname).","values":[]},{"name":"type","description":"The type of routing sources.\nIf field, it won't collect the slot attribute of the child elements.\nThis property should not be changed after the rendering is complete.","values":[{"name":"united"},{"name":"slotted"},{"name":"field"}]},{"name":"cache","description":"Cache accessed records.\nEmptied at each re-collection.","values":[]}],"references":[]},{"name":"godown-rotate","description":"Rotate Make child elements rotate.\n---\n### **Methods:**\n ","attributes":[],"references":[]},{"name":"godown-range","description":"Range is similar to `<input type=\"range\">`.\nValue accepts number, or array.\nNumber has 1 handle, the array has the number of its elements and the minimum is 2.\n---\n### **Events:**\n - **focus** - Fires when the handle is focused.\n- **blur** - Fires when the handle is blurred.\n- **range** - Fires when the value changes.\n- **input** - Fires when the input value changes.\n- **change** - Fires when the input value changes.\n### **Methods:**\n \n- **normalizeValue(value: _number_): _number_** - Ensure that the values do not exceed the range of max and min.","attributes":[{"name":"min","description":"Minimum value.","values":[]},{"name":"max","description":"Maximum value.","values":[]},{"name":"step","description":"Sliding step length.","values":[]},{"name":"vertical","description":"Display vertically.","values":[]},{"name":"value","description":"Value, or each of values, will render a handle.\nAccepts number or array of numbers.","values":[]},{"name":"default","description":"The default of `this.value`.","values":[]},{"name":"autocomplete","values":[]},{"name":"disabled","values":[]},{"name":"type","values":[{"name":"InputType"}]},{"name":"placeholder","values":[]},{"name":"name","values":[]}],"references":[]},{"name":"godown-progress","description":"Progress similar to `<progress>`.\n---\n### **Methods:**\n - **parsePercent(s: _string | number_): __** - Convert s to a percentage without a percent sign.","attributes":[{"name":"max","values":[]},{"name":"min","values":[]},{"name":"value","values":[]}],"references":[]},{"name":"godown-link","description":"Link is used for link jumping.\nSet `type` to `\"push\" `or `\"replace\"`,\nwill invoke the history api and trigger the Router.updateAll.\n---\n","attributes":[{"name":"type","description":"If \"push\", call `history.pushState`.\nIf \"replace\", call `history.replaceState`.\nIf \"normal\", behave like a normal anchor.","values":[{"name":"push"},{"name":"replace"},{"name":"normal"}]},{"name":"suppress","description":"Suppress the update of the Router.","values":[]},{"name":"href","description":"A element href.","values":[]},{"name":"target","description":"A element target.","values":[{"name":"_blank"},{"name":"_self"},{"name":"_parent"},{"name":"_top"}]}],"references":[]},{"name":"godown-layout","description":"Layout renders slot and optional top header, bottom footer.\n---\n### **Slots:**\n - _default_ - The main content of the layout.\n- **header** - The header of the layout.\n- **footer** - The footer of the layout.","attributes":[{"name":"noHeader","description":"If true, remove the header slot.","values":[]},{"name":"noFooter","description":"If true, remove the footer slot.","values":[]},{"name":"sticky","description":"If true, header will sticky.","values":[]}],"references":[]},{"name":"godown-input","description":"Input renders a text input.\n---\n### **Events:**\n - **input** - Fires when the input value changes.\n- **change** - Fires when the input value changes.","attributes":[{"name":"variant","description":"If outline, the outline is always present.","values":[{"name":"default"},{"name":"outline"}]},{"name":"autocomplete","values":[]},{"name":"disabled","values":[]},{"name":"type","values":[{"name":"InputType"}]},{"name":"placeholder","values":[]},{"name":"name","values":[]},{"name":"value","values":[]},{"name":"default","description":"default property records the default or initial value and is used to reset the input.","values":[]}],"references":[]},{"name":"godown-heading","description":"Heading renders a heading.\nIf the id is provided, the anchor will be displayed.\n---\n### **Slots:**\n - _default_ - Heading content.","attributes":[{"name":"as","description":"The heading level.","values":[{"name":"h1"},{"name":"h2"},{"name":"h3"},{"name":"h4"},{"name":"h5"},{"name":"h6"}]},{"name":"anchor","description":"The anchor prefix.","values":[]},{"name":"side","description":"The anchor side.","values":[{"name":"left"},{"name":"right"}]}],"references":[]},{"name":"godown-grid","description":"Grid provides gird layout.\n---\n### **Slots:**\n - _default_ - Grid items.","attributes":[{"name":"gap","description":"CSS property `gap`.","values":[]},{"name":"columns","description":"CSS property `grid-template-columns`.\nIf columns is numerical, divide columns equally.","values":[]},{"name":"rows","description":"CSS property `grid-template-rows`.\nIf rows is numerical, divide rows equally.","values":[]},{"name":"content","description":"CSS property `place-content` (`align-content justify-content`).","values":[]},{"name":"items","description":"CSS property `place-items` (`align-items justify-items`).","values":[]}],"references":[]},{"name":"godown-form","description":"Form Gets child element key-value object,\nwhich will be nested if the child element is the same as this element.\n---\n","attributes":[{"name":"name","values":[]}],"references":[]},{"name":"godown-flex","description":"Flex provides flex layout.\n---\n### **Slots:**\n - _default_ - Flex items.","attributes":[{"name":"flex-flow","description":"CSS property `flex-flow` (`flex-direction flex-wrap`).","values":[]},{"name":"gap","description":"CSS property `gap`.","values":[]},{"name":"content","description":"CSS property `justify-content`.","values":[]},{"name":"items","description":"CSS property `align-items`.","values":[]},{"name":"vertical","description":"If true, set flex-direction to \"column\".","values":[]}],"references":[]},{"name":"godown-dragbox","description":"Dragbox does not extend beyond the range of Dragbox.offsetsWidth and Dragbox.offsetsHeight.\n---\n","attributes":[{"name":"x","description":"Position x.","values":[]},{"name":"y","description":"Position y.","values":[]}],"references":[]},{"name":"godown-divider","description":"Divider similar to `<hr>`.\n---\n","attributes":[{"name":"vertical","description":"Vertical display.","values":[]}],"references":[]},{"name":"godown-dialog","description":"Dialog similar to `<dialog>`.\nLike dialog, it listens for submit events and closes itself when the target method is \"dialog\".\nIt listens for the keydown event and also closes itself when the key contained in the key is pressed.\n---\n### **Events:**\n - **change** - Fires when the open changes.","attributes":[{"name":"modal","description":"Enable modal, blocking event penetration.","values":[]},{"name":"key","description":"Close key.","values":[]},{"name":"open","description":"Open the content.","values":[]}],"references":[]},{"name":"godown-details","description":"Details similar to `<details>`.\n---\n### **Events:**\n - **change** - Fires when the open changes.\n### **Slots:**\n - **summary** - Details summary if no `summary` is provided.\n- _default_ - Details content.","attributes":[{"name":"fill","description":"If it is true, the summary event scope will fill the element.","values":[]},{"name":"summary","description":"Summary text.","values":[]},{"name":"open","description":"Open the content.","values":[]}],"references":[]},{"name":"godown-carousel","description":"Carousel make the content display as a carousel.\nWhen this component is `firstUpdated`,\nclone the first and last element and make the matching element visible when switching index.\nChild elements should maintain the same size.\nIf no width, it will be the width of the first element.\n---\n### **Events:**\n - **change** - Fires when the index changes.\n### **Slots:**\n - _default_ - Carousel items, should maintain the same size.","attributes":[{"name":"index","description":"The index of the element is displayed for the first time.","values":[]},{"name":"autoChange","description":"If autoChange > 0, the rotation will be automated.","values":[]},{"name":"width","description":"Element width.","values":[]}],"references":[]},{"name":"godown-card","description":"Card renders a card.\nThis may be similar to Layout,\nbut it needs to be specified to enable header and footer.\n---\n### **Slots:**\n - _default_ - The main content of the card.\n- **header** - The header of the card.\n- **footer** - The footer of the card.","attributes":[{"name":"footer","values":[]},{"name":"header","values":[]}],"references":[]},{"name":"godown-button","description":"Button renders a button.\nCreate modal animation upon clicking.\nAvailable colors (background): none, black, gray, white, blue, green, red, orange, pink, purple, yellow, teal.\nDefault color is `black`.\nSet the color to `none` to prevent applying styles.\n---\n","attributes":[{"name":"disabled","description":"Whether to disable this element.","values":[]},{"name":"ghost","description":"Display ghost.","values":[]},{"name":"active","description":"Whether this element is active or not.","values":[]},{"name":"round","description":"Display rounded.","values":[]},{"name":"color","description":"The primary color.","values":[{"name":"none"},{"name":"keyof typeof colors"}]},{"name":"content","description":"Content text.","values":[]}],"references":[]},{"name":"godown-breath","description":"Breath render the text with a breathing effect.\nDynamically generate a breathing effect based on the length of the split text.\nIf there is not enough CSS variable, overrun elements will use the.\ngodown was a css library in its earliest days,\nand this is the component version of its first effect.\nInspired by Vercel home page (2023).\n---\n### **Slots:**\n - _default_ - Breathing parts.","attributes":[{"name":"content","description":"Strings or array of strings,\nif array, divided each element into chunks,\notherwise split strings by whitespace.","values":[{"name":"string[]"}]},{"name":"duration","description":"Effect duration, ending in s or ms.","values":[]}],"references":[]},{"name":"godown-badge","description":"Badge renders a badge.\n---\n### **Slots:**\n - _default_ - Badge content.","attributes":[{"name":"position","values":[{"name":"Position"}]},{"name":"value","values":[]},{"name":"dot","description":"If `true`, render a dot badge.","values":[]},{"name":"max","values":[]}],"references":[]},{"name":"godown-avatar","description":"Avatar renders a avatar.\nRenders as an image if it has a src property,\notherwise falls back to name or nameless slot.\n---\n### **Slots:**\n - _default_ - Display content if no `src` or `name` provided.","attributes":[{"name":"src","description":"Image src.","values":[]},{"name":"name","description":"If the image is not available, display name (call Avatar.format).","values":[]},{"name":"round","description":"Display rounded.","values":[]}],"references":[]},{"name":"godown-alert","description":"Alert renders a alert.\nColor defaults to blue.\n---\n### **Events:**\n - **close** - Fires when the alert is closed.\n### **Slots:**\n - _default_ - Alert content.\n- **title** - Alert title.\n- **icon** - Alert icon.","attributes":[{"name":"call","description":"If it is a legal value, the icon and preset color will be rendered.","values":[{"name":"tip"},{"name":"success"},{"name":"info"},{"name":"warning"},{"name":"danger"},{"name":"error"},{"name":"help"},{"name":"deprecated"}]},{"name":"color","description":"The tone of the component.\nOverrides the color of the call.","values":[{"name":""},{"name":"white"},{"name":"black"},{"name":"gray"},{"name":"green"},{"name":"teal"},{"name":"blue"},{"name":"red"},{"name":"purple"},{"name":"orange"},{"name":"yellow"},{"name":"pink"},{"name":"none"}]},{"name":"autoclose","description":"Close delay, if 0, it will not be closed automatically.","values":[]},{"name":"title","description":"The title is bold and the icon height is the same as it.","values":[]},{"name":"content","description":"Content, if zero value, will be rendered as an unnamed slot.","values":[]},{"name":"hideClose","description":"Set true to hide the close button.\nThe behavior may change due to the variant property.","values":[]},{"name":"variant","description":"Alert variant, if set to `blockquote`, the alert will be rendered as a blockquote.\nIf variant is `\"blockquote\"`, hide the close button.\n! __\"light\" will be deprecated__ in the future.","values":[{"name":"blockquote"},{"name":"dark"},{"name":"light"}]}],"references":[]}]}
1
+ {"version":1.1,"tags":[{"name":"godown-typewriter","description":"Typewriter renders a typewriter effect to text.\n---\n### **Events:**\n ","attributes":[{"name":"content","description":"Raw text.","values":[]},{"name":"ended","description":"If true, hide the cursor","values":[]},{"name":"max","description":"Maximum random time.","values":[]},{"name":"min","description":"Minimum random time.","values":[]},{"name":"delay","description":"Fixed time.","values":[]},{"name":"index","description":"The index at the beginning.","values":[]}],"references":[]},{"name":"godown-tooltip","description":"Tooltip provide tooltip for slot elements.\nIf it has the tip property, ignore the slot tip.\n---\n### **Events:**\n - **change**\n### **Slots:**\n - **tip** - Tip element if no `tip` provided.\n- _default_ - Content.","attributes":[{"name":"tip","description":"Tip text, if there is a value, the slot will be ignored.","values":[]},{"name":"direction","description":"Direction of opening the tip.","values":[{"name":"Direction8"}]},{"name":"align","description":"Content alignment.","values":[{"name":"center"},{"name":"flex-start"},{"name":"flex-end"},{"name":"start"},{"name":"end"}]},{"name":"propagation","description":"If true, allow penetration of the tip.","values":[]},{"name":"type","description":"How can tips be triggered.\nIf `focus`, element will be focusable, open tip when focused.\nIf `hover`, element will open tip when hovered.","values":[{"name":"hover"},{"name":"focus"}]},{"name":"open","description":"Open the content.","values":[]}],"references":[]},{"name":"godown-time","description":"Time renders a formatting time.\n---\n### **Events:**\n - **time** - Fires when the time changes.","attributes":[{"name":"escape","description":"Escape symbol.","values":[]},{"name":"format","description":"Format strings.","values":[]},{"name":"time","description":"Time.","values":[{"name":"Date"}]},{"name":"timeout","description":"If there is a value, update every gap or timeout.","values":[]},{"name":"gap","description":"The number of milliseconds that change with each update.","values":[]}],"references":[]},{"name":"godown-text","description":"Text renders nowrap text.\n---\n","attributes":[{"name":"underline","description":"Underline behavior.","values":[{"name":"none"},{"name":"hover"},{"name":"active"},{"name":"always"}]},{"name":"clip","description":"Set background-clip to text.","values":[]}],"references":[]},{"name":"godown-switch","description":"Switch renders a switch.\nThe switch is rectangular by default,\nset the round property to rounded switch.\n---\n### **Events:**\n - **change** - Fires when the switch is switched.\n- **input**","attributes":[{"name":"round","description":"Display rounded.","values":[]},{"name":"checked","description":"Whether this element is selected or not.","values":[]},{"name":"disabled","description":"Disable this element.","values":[]},{"name":"default","description":"Default checked state.","values":[]},{"name":"value","description":"Input value.","values":[]},{"name":"autocomplete","values":[]},{"name":"type","values":[{"name":"InputType"}]},{"name":"placeholder","values":[]},{"name":"name","values":[]}],"references":[]},{"name":"godown-split","description":"Split renders multiple input boxes.\nInput: will move the focus box backward until the complete input from start to end.\nDelete: will move the focus box forward until the first and no inputs for each.\n---\n### **Events:**\n - **input** - Fires when the input value changes.\n- **focus** - Fires when the input is focused.\n- **blur** - Fires when the input is blurred.\n- **change** - Fires when the input value changes.\n### **Methods:**\n ","attributes":[{"name":"len","description":"The number of input boxes.","values":[]},{"name":"index","description":"Focus index.","values":[]},{"name":"autocomplete","values":[]},{"name":"disabled","values":[]},{"name":"type","values":[{"name":"InputType"}]},{"name":"placeholder","values":[]},{"name":"name","values":[]},{"name":"value","values":[]},{"name":"default","description":"default property records the default or initial value and is used to reset the input.","values":[]}],"references":[]},{"name":"godown-skeleton","description":"Skeleton renders a skeleton screen.\n---\n### **Slots:**\n - **loading** - The content if loading is true.\n- _default_ - The content if loading is false.","attributes":[{"name":"type","description":"If \"image\", render a image placeholder.","values":[{"name":"text"},{"name":"image"}]},{"name":"animation","description":"Animation type.\nopacity animation only effect on slotted element and image icon.","values":[{"name":"position"},{"name":"opacity"}]}],"references":[]},{"name":"godown-select","description":"Select is similar to `<select>`.\nElements with the value attribute/property can be used as options.\nThe checked attribute will be added to the selected element.\nMulti-selected state looks the same as single-selected.\nInput will filter the element.\n---\n### **Events:**\n - **select** - Fires when select an option.\n- **input** - Fires when the input value changes.\n- **change** - Fires when the input value changes.\n### **Slots:**\n - _default_ - Options.","attributes":[{"name":"text","description":"Selected texts.","values":[]},{"name":"direction","values":[{"name":"top"},{"name":"bottom"}]},{"name":"multiple","values":[]},{"name":"visible","values":[]},{"name":"variant","description":"If outline, the outline is always present.","values":[{"name":"default"},{"name":"outline"}]},{"name":"autocomplete","values":[]},{"name":"disabled","values":[]},{"name":"type","values":[{"name":"InputType"}]},{"name":"placeholder","values":[]},{"name":"name","values":[]},{"name":"value","values":[]},{"name":"default","description":"default property records the default or initial value and is used to reset the input.","values":[]}],"references":[]},{"name":"godown-router","description":"Router has basic routing control.\nTo switch routes, use `router-link component`.\nIt has two methods to collect routes.\n1. From field `routes`, an array, each elements require \"path\".\n2. From child elements, which have the slot attribute for matching routes.\nIf only the method 1 is used, set `type` to `\"field\"`.\nIf only the method 2 is used, set `type` to `\"slotted\"`.\n`type` defaults to `\"united\"`, which will try method 1, then method 2.\nIf no routes are matched, the default value (no named slot) will be rendered.\n---\n### **Events:**\n - **change**\n### **Methods:**\n - **fieldComponent(query: _string_): _unknown_** - Get component from routes by query.\n- **slottedComponent(query: _string_): _TemplateResult<1>_** - Get component from slotted elements by query.\n- **collectSlottedRoutes(): _void_** - Reset the route tree, clear cache, collect routes from child elements.\n- **collectFieldRoutes(value: _typeof this.routes_): _void_** - Reset the route tree, clear cache, collect routes from value.\n### **Slots:**\n - _default_ - Display slot when there is no match.\n- ***** - Matching slot will be displayed.","attributes":[{"name":"pathname","description":"Current pathname (equals to location.pathname).","values":[]},{"name":"type","description":"The type of routing sources.\nIf field, it won't collect the slot attribute of the child elements.\nThis property should not be changed after the rendering is complete.","values":[{"name":"RouterType"}]},{"name":"cache","description":"Cache accessed records.\nEmptied at each re-collection.","values":[]}],"references":[]},{"name":"godown-rotate","description":"Rotate Make child elements rotate.\n---\n### **Methods:**\n ","attributes":[],"references":[]},{"name":"godown-range","description":"Range is similar to `<input type=\"range\">`.\nValue accepts number, or array.\nNumber has 1 handle, the array has the number of its elements and the minimum is 2.\n---\n### **Events:**\n - **focus** - Fires when the handle is focused.\n- **blur** - Fires when the handle is blurred.\n- **range** - Fires when the value changes.\n- **input** - Fires when the input value changes.\n- **change** - Fires when the input value changes.\n### **Methods:**\n \n- **normalizeValue(value: _number_): _number_** - Ensure that the values do not exceed the range of max and min.","attributes":[{"name":"min","description":"Minimum value.","values":[]},{"name":"max","description":"Maximum value.","values":[]},{"name":"step","description":"Sliding step length.","values":[]},{"name":"vertical","description":"Display vertically.","values":[]},{"name":"value","description":"Value, or each of values, will render a handle.\nAccepts number or array of numbers.","values":[]},{"name":"default","description":"The default of `this.value`.","values":[]},{"name":"autocomplete","values":[]},{"name":"disabled","values":[]},{"name":"type","values":[{"name":"InputType"}]},{"name":"placeholder","values":[]},{"name":"name","values":[]}],"references":[]},{"name":"godown-progress","description":"Progress similar to `<progress>`.\n---\n### **Methods:**\n - **parsePercent(s: _string | number_): __** - Convert s to a percentage without a percent sign.","attributes":[{"name":"max","values":[]},{"name":"min","values":[]},{"name":"value","values":[]}],"references":[]},{"name":"godown-link","description":"Link is used for link jumping, works standalone or in Router.\nSet `type` to `\"normal\"`,\nbehave like a normal anchor.\nSet `type` to `\"push\" `or `\"replace\"`,\nupdate history state by `history.pushState` or `history.replaceState`,\nupdate all routers whether current pathname is registered or not.\nSet `type` to `\"auto\"`,\nonly update the routers if the current pathname is registered,\nif not registered, behave like `\"normal\"`.\n`replace` property will enforce `history.replaceState`.\n---\n### **Events:**\n - **navigate** - Fires when the link is clicked.","attributes":[{"name":"type","description":"If `\"normal\"`, behave like a normal anchor.\nIf `\"auto\"` or `\"push\"`, call `history.pushState` if `replace` is false,\nIf `\"replace\"`, call `history.replaceState`.","values":[{"name":"LinkType"}]},{"name":"suppress","description":"If `true`, the Router will not be updated.","values":[]},{"name":"replace","description":"Use `replaceState` instead of `pushState`.","values":[]},{"name":"href","description":"A element href.","values":[]},{"name":"target","description":"A element target.","values":[{"name":"_blank"},{"name":"_self"},{"name":"_parent"},{"name":"_top"}]}],"references":[]},{"name":"godown-layout","description":"Layout renders slot and optional top header, bottom footer.\n---\n### **Slots:**\n - _default_ - The main content of the layout.\n- **header** - The header of the layout.\n- **footer** - The footer of the layout.","attributes":[{"name":"noHeader","description":"If true, remove the header slot.","values":[]},{"name":"noFooter","description":"If true, remove the footer slot.","values":[]},{"name":"sticky","description":"If true, header will sticky.","values":[]}],"references":[]},{"name":"godown-input","description":"Input renders a text input.\n---\n### **Events:**\n - **input** - Fires when the input value changes.\n- **change** - Fires when the input value changes.","attributes":[{"name":"variant","description":"If outline, the outline is always present.","values":[{"name":"default"},{"name":"outline"}]},{"name":"autocomplete","values":[]},{"name":"disabled","values":[]},{"name":"type","values":[{"name":"InputType"}]},{"name":"placeholder","values":[]},{"name":"name","values":[]},{"name":"value","values":[]},{"name":"default","description":"default property records the default or initial value and is used to reset the input.","values":[]}],"references":[]},{"name":"godown-heading","description":"Heading renders a heading.\nIf the id is provided, the anchor will be displayed.\n---\n### **Slots:**\n - _default_ - Heading content.","attributes":[{"name":"as","description":"The heading level.","values":[{"name":"h1"},{"name":"h2"},{"name":"h3"},{"name":"h4"},{"name":"h5"},{"name":"h6"}]},{"name":"anchor","description":"The anchor prefix.","values":[]},{"name":"side","description":"The anchor side.","values":[{"name":"left"},{"name":"right"}]}],"references":[]},{"name":"godown-grid","description":"Grid provides gird layout.\n---\n### **Slots:**\n - _default_ - Grid items.","attributes":[{"name":"gap","description":"CSS property `gap`.","values":[]},{"name":"columns","description":"CSS property `grid-template-columns`.\nIf columns is numerical, divide columns equally.","values":[]},{"name":"rows","description":"CSS property `grid-template-rows`.\nIf rows is numerical, divide rows equally.","values":[]},{"name":"content","description":"CSS property `place-content` (`align-content justify-content`).","values":[]},{"name":"items","description":"CSS property `place-items` (`align-items justify-items`).","values":[]}],"references":[]},{"name":"godown-form","description":"Form Gets child element key-value object,\nwhich will be nested if the child element is the same as this element.\n---\n","attributes":[{"name":"name","values":[]}],"references":[]},{"name":"godown-flex","description":"Flex provides flex layout.\n---\n### **Slots:**\n - _default_ - Flex items.","attributes":[{"name":"flex-flow","description":"CSS property `flex-flow` (`flex-direction flex-wrap`).","values":[]},{"name":"gap","description":"CSS property `gap`.","values":[]},{"name":"content","description":"CSS property `justify-content`.","values":[]},{"name":"items","description":"CSS property `align-items`.","values":[]},{"name":"vertical","description":"If true, set flex-direction to \"column\".","values":[]}],"references":[]},{"name":"godown-dragbox","description":"Dragbox does not extend beyond the range of Dragbox.offsetsWidth and Dragbox.offsetsHeight.\n---\n","attributes":[{"name":"x","description":"Position x.","values":[]},{"name":"y","description":"Position y.","values":[]}],"references":[]},{"name":"godown-divider","description":"Divider similar to `<hr>`.\n---\n","attributes":[{"name":"vertical","description":"Vertical display.","values":[]}],"references":[]},{"name":"godown-dialog","description":"Dialog similar to `<dialog>`.\nLike dialog, it listens for submit events and closes itself when the target method is \"dialog\".\nIt listens for the keydown event and also closes itself when the key contained in the key is pressed.\n---\n### **Events:**\n - **change** - Fires when the open changes.","attributes":[{"name":"modal","description":"Enable modal, blocking event penetration.","values":[]},{"name":"key","description":"Close key.","values":[]},{"name":"open","description":"Open the content.","values":[]}],"references":[]},{"name":"godown-details","description":"Details similar to `<details>`.\n---\n### **Events:**\n - **change** - Fires when the open changes.\n### **Slots:**\n - **summary** - Details summary if no `summary` is provided.\n- _default_ - Details content.","attributes":[{"name":"fill","description":"If it is true, the summary event scope will fill the element.","values":[]},{"name":"summary","description":"Summary text.","values":[]},{"name":"open","description":"Open the content.","values":[]}],"references":[]},{"name":"godown-carousel","description":"Carousel make the content display as a carousel.\nWhen this component is `firstUpdated`,\nclone the first and last element and make the matching element visible when switching index.\nChild elements should maintain the same size.\nIf no width, it will be the width of the first element.\n---\n### **Events:**\n - **change** - Fires when the index changes.\n### **Slots:**\n - _default_ - Carousel items, should maintain the same size.","attributes":[{"name":"index","description":"The index of the element is displayed for the first time.","values":[]},{"name":"autoChange","description":"If autoChange > 0, the rotation will be automated.","values":[]},{"name":"width","description":"Element width.","values":[]}],"references":[]},{"name":"godown-card","description":"Card renders a card.\nThis may be similar to Layout,\nbut it needs to be specified to enable header and footer.\n---\n### **Slots:**\n - _default_ - The main content of the card.\n- **header** - The header of the card.\n- **footer** - The footer of the card.","attributes":[{"name":"footer","values":[]},{"name":"header","values":[]}],"references":[]},{"name":"godown-button","description":"Button renders a button.\nCreate modal animation upon clicking.\nAvailable colors (background): none, black, gray, white, blue, green, red, orange, pink, purple, yellow, teal.\nDefault color is `black`.\nSet the color to `none` to prevent applying styles.\n---\n","attributes":[{"name":"disabled","description":"Whether to disable this element.","values":[]},{"name":"ghost","description":"Display ghost.","values":[]},{"name":"active","description":"Whether this element is active or not.","values":[]},{"name":"round","description":"Display rounded.","values":[]},{"name":"color","description":"The primary color.","values":[{"name":"none"},{"name":"keyof typeof colors"}]},{"name":"content","description":"Content text.","values":[]}],"references":[]},{"name":"godown-breath","description":"Breath render the text with a breathing effect.\nDynamically generate a breathing effect based on the length of the split text.\nIf there is not enough CSS variable, overrun elements will use the.\ngodown was a css library in its earliest days,\nand this is the component version of its first effect.\nInspired by Vercel home page (2023).\n---\n### **Slots:**\n - _default_ - Breathing parts.","attributes":[{"name":"content","description":"Strings or array of strings,\nif array, divided each element into chunks,\notherwise split strings by whitespace.","values":[{"name":"string[]"}]},{"name":"duration","description":"Effect duration, ending in s or ms.","values":[]}],"references":[]},{"name":"godown-badge","description":"Badge renders a badge.\n---\n### **Slots:**\n - _default_ - Badge content.","attributes":[{"name":"position","values":[{"name":"Position"}]},{"name":"value","values":[]},{"name":"dot","description":"If `true`, render a dot badge.","values":[]},{"name":"max","values":[]}],"references":[]},{"name":"godown-avatar","description":"Avatar renders a avatar.\nRenders as an image if it has a src property,\notherwise falls back to name or nameless slot.\n---\n### **Slots:**\n - _default_ - Display content if no `src` or `name` provided.","attributes":[{"name":"src","description":"Image src.","values":[]},{"name":"name","description":"If the image is not available, display name (call Avatar.format).","values":[]},{"name":"round","description":"Display rounded.","values":[]}],"references":[]},{"name":"godown-alert","description":"Alert renders a alert.\nColor defaults to blue.\n---\n### **Events:**\n - **close** - Fires when the alert is closed.\n### **Slots:**\n - _default_ - Alert content.\n- **title** - Alert title.\n- **icon** - Alert icon.","attributes":[{"name":"call","description":"If it is a legal value, the icon and preset color will be rendered.","values":[{"name":"tip"},{"name":"success"},{"name":"info"},{"name":"warning"},{"name":"danger"},{"name":"error"},{"name":"help"},{"name":"deprecated"}]},{"name":"color","description":"The tone of the component.\nOverrides the color of the call.","values":[{"name":""},{"name":"white"},{"name":"black"},{"name":"gray"},{"name":"green"},{"name":"teal"},{"name":"blue"},{"name":"red"},{"name":"purple"},{"name":"orange"},{"name":"yellow"},{"name":"pink"},{"name":"none"}]},{"name":"autoclose","description":"Close delay, if 0, it will not be closed automatically.","values":[]},{"name":"title","description":"The title is bold and the icon height is the same as it.","values":[]},{"name":"content","description":"Content, if zero value, will be rendered as an unnamed slot.","values":[]},{"name":"hideClose","description":"Set true to hide the close button.\nThe behavior may change due to the variant property.","values":[]},{"name":"variant","description":"Alert variant, if set to `blockquote`, the alert will be rendered as a blockquote.\nIf variant is `\"blockquote\"`, hide the close button.\n! __\"light\" will be deprecated__ in the future.","values":[{"name":"blockquote"},{"name":"dark"},{"name":"light"}]}],"references":[]}]}