@kubed.io/cdn 0.0.3 β†’ 0.0.5

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 (59) hide show
  1. package/README.md +33 -5
  2. package/dist/chunks/define-BSZoKakE.js +10 -0
  3. package/dist/chunks/define-BSZoKakE.js.map +1 -0
  4. package/dist/chunks/element-ChNBLJ5X.js +632 -0
  5. package/dist/chunks/element-ChNBLJ5X.js.map +1 -0
  6. package/dist/chunks/kd-BeZbw7cp.js +1149 -0
  7. package/dist/chunks/kd-BeZbw7cp.js.map +1 -0
  8. package/dist/chunks/scene-CUr0fSXC.js +240 -0
  9. package/dist/chunks/scene-CUr0fSXC.js.map +1 -0
  10. package/dist/k8s/elements/events.d.ts +54 -0
  11. package/dist/k8s/elements/object.d.ts +47 -0
  12. package/dist/k8s/elements/ref.d.ts +45 -0
  13. package/dist/k8s/events.d.ts +63 -0
  14. package/dist/k8s/icons.d.ts +18 -0
  15. package/dist/k8s/index.d.ts +13 -0
  16. package/dist/k8s/links.d.ts +72 -0
  17. package/dist/k8s/map.d.ts +114 -0
  18. package/dist/k8s.js +909 -0
  19. package/dist/k8s.js.map +1 -0
  20. package/dist/kd/cell.d.ts +45 -0
  21. package/dist/kd/element.d.ts +32 -0
  22. package/dist/kd/elements/bar.d.ts +33 -0
  23. package/dist/kd/elements/data.d.ts +27 -0
  24. package/dist/kd/elements/groups.d.ts +32 -0
  25. package/dist/kd/elements/link.d.ts +67 -0
  26. package/dist/kd/elements/mask.d.ts +22 -0
  27. package/dist/kd/elements/meter.d.ts +37 -0
  28. package/dist/kd/elements/pill.d.ts +15 -0
  29. package/dist/kd/elements/sheet.d.ts +28 -0
  30. package/dist/kd/elements/steps.d.ts +30 -0
  31. package/dist/kd/elements/table.d.ts +38 -0
  32. package/dist/kd/elements/tabs.d.ts +27 -0
  33. package/dist/kd/elements/tile.d.ts +19 -0
  34. package/dist/kd/helpers.d.ts +12 -0
  35. package/dist/kd/index.d.ts +30 -0
  36. package/dist/kd/parts.d.ts +15 -0
  37. package/dist/kd/scene.d.ts +178 -0
  38. package/dist/kd/theme.d.ts +2 -0
  39. package/dist/kd/yaml.d.ts +17 -0
  40. package/dist/kd.js +5 -64
  41. package/dist/n8n/config.d.ts +58 -0
  42. package/dist/n8n/fetch.d.ts +35 -0
  43. package/dist/n8n/history.d.ts +8 -0
  44. package/dist/n8n/index.d.ts +8 -0
  45. package/dist/n8n/metadata.d.ts +10 -0
  46. package/dist/n8n/mount.d.ts +29 -0
  47. package/dist/n8n/state.d.ts +44 -0
  48. package/dist/n8n/stream.d.ts +17 -0
  49. package/dist/n8n/styles.d.ts +1 -0
  50. package/dist/n8n.js +384 -0
  51. package/dist/n8n.js.map +1 -0
  52. package/dist/openapi/describe.d.ts +20 -0
  53. package/dist/openapi/index.d.ts +6 -0
  54. package/dist/openapi/model.d.ts +154 -0
  55. package/dist/openapi/schema.d.ts +52 -0
  56. package/dist/openapi.js +504 -0
  57. package/dist/openapi.js.map +1 -0
  58. package/package.json +26 -2
  59. package/dist/kd.js.map +0 -1
package/README.md CHANGED
@@ -9,10 +9,24 @@
9
9
 
10
10
  ## πŸ—‚οΈ What is here
11
11
 
12
- | File | What it is |
12
+ | Entry | What it brings |
13
13
  |---|---|
14
- | `dist/kd.js` | the core: `applyTheme`, `followTheme` and `define` |
15
- | `dist/kd.css` | text, links, tables, badges, code and cards for `.kd` markup, styled only from the theme |
14
+ | `dist/kd.js` | 🎨 the core: the theme layer, the Grafana page helpers, and every generic element |
15
+ | `dist/kd.css` | text, links, tables, badges, code and cards for plain `.kd` markup |
16
+ | `dist/openapi.js` | πŸ“œ `<kd-schema>`: any OpenAPI v3 or JSON Schema, kubectl-explain style, rendered lazily |
17
+ | `dist/k8s.js` | ☸️ Kubernetes objects mapped onto the core elements: `<kd-k8s-object>`, `<kd-k8s-ref>`, `<kd-k8s-events>` |
18
+ | `dist/n8n.js` | πŸ’¬ `mount(config)`: the n8n agent chat tile for app dashboards |
19
+
20
+ The entries share chunks, so a page that loads several pays for Lit and the core once. The look lives in the core; a domain entry adds behaviour, never colours.
21
+
22
+ **Elements** (all `kd-*`, real custom elements with shadow DOM, themed from `--kd-*`):
23
+
24
+ | | |
25
+ |---|---|
26
+ | `kd-pill` `kd-tile` `kd-link` `kd-mask` | small things: a toned pill, a header tile, a dashboard link that keeps the time range and a back chain, a click-to-reveal value |
27
+ | `kd-bar` `kd-sheet` `kd-table` | a title bar with chips and a breadcrumb, a property sheet, a table; cells can be text, pills, links, code or data |
28
+ | `kd-groups` `kd-data` | labels as grouped pills, annotations as a tree; any JSON value as folded YAML |
29
+ | `kd-tabs` `kd-steps` `kd-meter` | tabs that remember their choice, a stepper, a value against request/limit marks |
16
30
 
17
31
  The source is TypeScript under `src/`, one folder per entry. `dist/` is built by CI and exists only in the published package.
18
32
 
@@ -56,7 +70,7 @@ A release is then a one-line change per dashboard. Move every dashboard together
56
70
  ## 🧩 In a Business Text panel
57
71
 
58
72
  ```
59
- externalStyles: ["${assets}/kd.css"]
73
+ externalStyles: [{ id: "kd", url: "${assets}/kd.css" }] # objects: a bare string never loads
60
74
  content: <div class="kd"> ... </div>
61
75
  afterRender: import(context.grafana.replaceVariables("${assets}") + "/kd.js")
62
76
  .then(m => m.applyTheme(context.element, context.grafana.theme))
@@ -64,7 +78,21 @@ afterRender: import(context.grafana.replaceVariables("${assets}") + "/kd.js")
64
78
 
65
79
  `afterRender` runs on every re-render and `applyTheme` is idempotent, so switching Grafana's theme restyles the panel. Code with no `context.grafana.theme` calls `followTheme(element)` instead: it reads the live theme from Grafana's runtime and follows a theme switch.
66
80
 
67
- Every panel imports what it needs itself. The browser loads a URL once per page however many panels import it.
81
+ Every panel imports what it needs itself. The browser loads a URL once per page however many panels import it, and an element defined by one panel works in all of them.
82
+
83
+ **Feeding an element.** Elements draw from their `data` and nothing else, because Business Text recreates them whenever the panel's HTML changes. Push data in from `afterRender` on every render:
84
+
85
+ ```
86
+ content: <div class="kd"><kd-table></kd-table></div>
87
+ afterRender: import(base + "/kd.js").then(m => {
88
+ m.applyTheme(context.element, context.grafana.theme)
89
+ context.element.querySelector("kd-table").data = { rows: context.data }
90
+ })
91
+ ```
92
+
93
+ Markup from a query can carry the data as a JSON attribute instead, escaped: `data="{{kdjson rows}}"` with the `kdjson` helper (`registerHelpers(context.handlebars)`), or `@json | @html` in Infinity jq. Never `{{{ }}}` JSON into an attribute.
94
+
95
+ Ready-made panels are in [`examples/`](examples).
68
96
 
69
97
  ## πŸ› οΈ Develop
70
98
 
@@ -0,0 +1,10 @@
1
+ //#region src/kd/define.ts
2
+ var e = "0.0.5";
3
+ function t(t, n, r = customElements) {
4
+ let i = r.get(t);
5
+ return i ? (i !== n && i.kdVersion !== "0.0.5" && console.warn(`@kubed.io/cdn ${e}: <${t}> is already defined by ${i.kdVersion ? `@kubed.io/cdn ${i.kdVersion}` : "another script"}; that definition stays until the page is reloaded.`), !1) : (Object.defineProperty(n, "kdVersion", { value: e }), r.define(t, n), !0);
6
+ }
7
+ //#endregion
8
+ export { t as n, e as t };
9
+
10
+ //# sourceMappingURL=define-BSZoKakE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-BSZoKakE.js","names":["VERSION","define","existing","registry","name","element"],"sources":["../../src/kd/define.ts"],"sourcesContent":["/** This build's package version. */\nexport const VERSION: string = __KD_VERSION__;\n\n/**\n * Registers a custom element unless the name is taken, and says so when it is.\n *\n * Every panel on a page shares one registry, and a definition outlives SPA\n * navigation, so the first version of a tag loaded owns it until a full page\n * reload. A second define would throw; this keeps the first and warns when the\n * two builds differ.\n *\n * @returns whether this call defined the element\n */\nexport function define(\n name: string,\n element: CustomElementConstructor,\n registry: CustomElementRegistry = customElements,\n): boolean {\n const existing = registry.get(name) as (CustomElementConstructor & { kdVersion?: string }) | undefined;\n if (existing) {\n if (existing !== element && existing.kdVersion !== VERSION) {\n console.warn(\n `@kubed.io/cdn ${VERSION}: <${name}> is already defined by ${existing.kdVersion ? `@kubed.io/cdn ${existing.kdVersion}` : 'another script'}; ` +\n 'that definition stays until the page is reloaded.',\n );\n }\n return false;\n }\n Object.defineProperty(element, 'kdVersion', { value: VERSION });\n registry.define(name, element);\n return true;\n}\n"],"mappings":";AACA,IAAaA,IAAA;AAYb,SAAgBC,EACd,GACA,GACA,IAAkC,gBACzB;CACT,IAAMC,IAAWC,EAAS,IAAIC,CAAI;CAYlC,OAXIF,KACEA,MAAaG,KAAWH,EAAS,cAAA,WACnC,QAAQ,KACN,iBAAiBF,EAAQ,KAAKI,EAAK,0BAA0BF,EAAS,YAAY,iBAAiBA,EAAS,cAAc,iBAAiB,oDAE7I,GAEK,OAET,OAAO,eAAeG,GAAS,aAAa,EAAE,OAAOL,EAAQ,CAAC,GAC9DG,EAAS,OAAOC,GAAMC,CAAO,GACtB;AACT"}