@forsakringskassan/docs-live-example 2.0.0 → 2.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.
@@ -1,5 +1,5 @@
1
1
  import { type PropType } from "vue";
2
- declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
+ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
3
3
  /**
4
4
  * Explicitly render example in given language.
5
5
  *
@@ -89,39 +89,15 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
89
89
  livedata: Record<string, any>;
90
90
  livemethods: Record<string, any>;
91
91
  }, {}, {
92
- LiveExampleSourcecode: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
93
- element: {
94
- type: {
95
- new (): HTMLElement;
96
- prototype: HTMLElement;
97
- };
98
- required: true;
99
- };
100
- template: {
101
- type: StringConstructor;
102
- required: true;
103
- };
104
- templateLanguage: {
105
- type: PropType<"vue" | "html">;
106
- required: true;
107
- };
108
- }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
109
- element: {
110
- type: {
111
- new (): HTMLElement;
112
- prototype: HTMLElement;
113
- };
114
- required: true;
115
- };
116
- template: {
117
- type: StringConstructor;
118
- required: true;
119
- };
120
- templateLanguage: {
121
- type: PropType<"vue" | "html">;
122
- required: true;
123
- };
124
- }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
92
+ LiveExampleSourcecode: import("vue").DefineComponent<{
93
+ element: HTMLElement;
94
+ template: string;
95
+ templateLanguage: "vue" | "html";
96
+ }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
97
+ element: HTMLElement;
98
+ template: string;
99
+ templateLanguage: "vue" | "html";
100
+ }> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
125
101
  LiveVueCode: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
126
102
  template: {
127
103
  type: StringConstructor;
@@ -158,4 +134,5 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
158
134
  };
159
135
  }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
160
136
  }, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
137
+ declare const _default: typeof __VLS_export;
161
138
  export default _default;
@@ -1,35 +1,8 @@
1
- import { type PropType } from "vue";
2
- declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
3
- element: {
4
- type: {
5
- new (): HTMLElement;
6
- prototype: HTMLElement;
7
- };
8
- required: true;
9
- };
10
- template: {
11
- type: StringConstructor;
12
- required: true;
13
- };
14
- templateLanguage: {
15
- type: PropType<"vue" | "html">;
16
- required: true;
17
- };
18
- }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
19
- element: {
20
- type: {
21
- new (): HTMLElement;
22
- prototype: HTMLElement;
23
- };
24
- required: true;
25
- };
26
- template: {
27
- type: StringConstructor;
28
- required: true;
29
- };
30
- templateLanguage: {
31
- type: PropType<"vue" | "html">;
32
- required: true;
33
- };
34
- }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
1
+ type __VLS_Props = {
2
+ element: HTMLElement;
3
+ template: string;
4
+ templateLanguage: "vue" | "html";
5
+ };
6
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
+ declare const _default: typeof __VLS_export;
35
8
  export default _default;
package/dist/cjs/index.js CHANGED
@@ -1626,7 +1626,7 @@ function expandAnimation(element) {
1626
1626
  };
1627
1627
  function shrink() {
1628
1628
  isClosing = true;
1629
- const startHeight = `${element.offsetHeight}px`;
1629
+ const startHeight = `${String(element.offsetHeight)}px`;
1630
1630
  const endHeight = `0px`;
1631
1631
  element.classList.add(ClassNames.COLLAPSING);
1632
1632
  if (animation) {
@@ -1655,7 +1655,9 @@ function expandAnimation(element) {
1655
1655
  currentHeight = element.getBoundingClientRect().height;
1656
1656
  }
1657
1657
  element.setAttribute("aria-expanded", "true");
1658
- window.requestAnimationFrame(() => expand(currentHeight));
1658
+ window.requestAnimationFrame(() => {
1659
+ expand(currentHeight);
1660
+ });
1659
1661
  }
1660
1662
  function expand(currentHeight) {
1661
1663
  isExpanding = true;
@@ -1663,8 +1665,8 @@ function expandAnimation(element) {
1663
1665
  animation.cancel();
1664
1666
  element.style.height = "";
1665
1667
  }
1666
- const startHeight = `${currentHeight}px`;
1667
- const endHeight = `${element.offsetHeight}px`;
1668
+ const startHeight = `${String(currentHeight)}px`;
1669
+ const endHeight = `${String(element.offsetHeight)}px`;
1668
1670
  element.classList.add(ClassNames.EXPANDING);
1669
1671
  animation = element.animate(
1670
1672
  {
@@ -1720,10 +1722,6 @@ function generateId(template) {
1720
1722
  return `le-${hash.toString(16)}`;
1721
1723
  }
1722
1724
 
1723
- // src/utils/highlight.ts
1724
- var import_standalone = require("prettier/standalone");
1725
- var import_html = __toESM(require("prettier/plugins/html"));
1726
-
1727
1725
  // node_modules/highlight.js/es/core.js
1728
1726
  var import_core = __toESM(require_core(), 1);
1729
1727
  var core_default = import_core.default;
@@ -1955,6 +1953,8 @@ function xml(hljs) {
1955
1953
  }
1956
1954
 
1957
1955
  // src/utils/highlight.ts
1956
+ var import_html = __toESM(require("prettier/plugins/html"));
1957
+ var import_standalone = require("prettier/standalone");
1958
1958
  core_default.registerLanguage("html", xml);
1959
1959
  var prettierConfig = {
1960
1960
  parser: "html",
@@ -1988,29 +1988,28 @@ async function getSourceCode(options) {
1988
1988
  }
1989
1989
  }
1990
1990
 
1991
+ // src/utils/to-kebab-case.ts
1992
+ function toKebabCase(input) {
1993
+ return input.replace(
1994
+ /[A-Z]+(?![a-z])|[A-Z]/g,
1995
+ ($, ofs) => (ofs ? "-" : "") + $.toLowerCase()
1996
+ );
1997
+ }
1998
+
1991
1999
  // sfc-script:/home/runner/work/docs-live-example/docs-live-example/src/LiveExampleSourcecode.vue?type=script
1992
2000
  var LiveExampleSourcecode_default = /* @__PURE__ */ (0, import_vue.defineComponent)({
1993
2001
  __name: "LiveExampleSourcecode",
1994
2002
  props: {
1995
- element: {
1996
- type: HTMLElement,
1997
- required: true
1998
- },
1999
- template: {
2000
- type: String,
2001
- required: true
2002
- },
2003
- templateLanguage: {
2004
- type: String,
2005
- required: true
2006
- }
2003
+ element: { type: null, required: true },
2004
+ template: { type: String, required: true },
2005
+ templateLanguage: { type: String, required: true }
2007
2006
  },
2008
2007
  setup(__props, { expose: __expose }) {
2009
2008
  __expose();
2010
2009
  const props = __props;
2011
2010
  let idPrefix = generateId(props.template);
2012
2011
  const sourcecode = (0, import_vue2.ref)("");
2013
- const expandable = (0, import_vue2.ref)(null);
2012
+ const expandable = (0, import_vue2.useTemplateRef)("expandableRef");
2014
2013
  const animation = (0, import_vue2.ref)({
2015
2014
  isOpen: false,
2016
2015
  toggle() {
@@ -2110,7 +2109,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
2110
2109
  { class: "icon icon--code" },
2111
2110
  null,
2112
2111
  -1
2113
- /* HOISTED */
2112
+ /* CACHED */
2114
2113
  )),
2115
2114
  (0, import_vue3.createTextVNode)(
2116
2115
  " " + (0, import_vue3.toDisplayString)($setup.codeToggleText),
@@ -2121,7 +2120,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
2121
2120
  ]),
2122
2121
  (0, import_vue3.createElementVNode)("div", {
2123
2122
  id: $setup.id("code-expand"),
2124
- ref: "expandable",
2123
+ ref: "expandableRef",
2125
2124
  class: "collapsed"
2126
2125
  }, [
2127
2126
  (0, import_vue3.createCommentVNode)(" [html-validate-disable-next wcag/h32 -- this form is not meant to be submitted] "),
@@ -2132,7 +2131,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
2132
2131
  { class: "label fieldset__label" },
2133
2132
  "Kodspr\xE5k",
2134
2133
  -1
2135
- /* HOISTED */
2134
+ /* CACHED */
2136
2135
  )),
2137
2136
  (0, import_vue3.createElementVNode)("div", _hoisted_6, [
2138
2137
  $props.templateLanguage === "vue" ? ((0, import_vue3.openBlock)(), (0, import_vue3.createElementBlock)("div", _hoisted_7, [
@@ -2359,15 +2358,15 @@ function render2(_ctx, _cache, $props, $setup, $data, $options) {
2359
2358
  ],
2360
2359
  2112
2361
2360
  /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
2362
- )) : ((0, import_vue6.openBlock)(), (0, import_vue6.createElementBlock)("div", _hoisted_52, _cache[0] || (_cache[0] = [
2361
+ )) : ((0, import_vue6.openBlock)(), (0, import_vue6.createElementBlock)("div", _hoisted_52, [..._cache[0] || (_cache[0] = [
2363
2362
  (0, import_vue6.createElementVNode)(
2364
2363
  "pre",
2365
2364
  null,
2366
2365
  "Unknown language, cannot render example",
2367
2366
  -1
2368
- /* HOISTED */
2367
+ /* CACHED */
2369
2368
  )
2370
- ])))
2369
+ ])]))
2371
2370
  ],
2372
2371
  512
2373
2372
  /* NEED_PATCH */
@@ -2444,7 +2443,7 @@ function serializeAttribute(key, value, prefix = "") {
2444
2443
  return [];
2445
2444
  }
2446
2445
  if (typeof value === "string" || typeof value === "number") {
2447
- return `${prefix}${key}="${value}"`;
2446
+ return `${prefix}${key}="${String(value)}"`;
2448
2447
  }
2449
2448
  if (typeof value === "boolean") {
2450
2449
  return value ? `${prefix}${key}` : [];
@@ -2455,7 +2454,9 @@ function serializeAttribute(key, value, prefix = "") {
2455
2454
  }
2456
2455
  function serializeAttributes(attrs) {
2457
2456
  const entries = Object.entries(attrs);
2458
- const kv = entries.map(([key, value]) => serializeAttribute(key, value));
2457
+ const kv = entries.map(
2458
+ ([key, value]) => serializeAttribute(toKebabCase(key), value)
2459
+ );
2459
2460
  const flat = kv.flat();
2460
2461
  if (flat.length > 0) {
2461
2462
  return ` ${kv.flat().join(" ")}`;
package/dist/esm/index.js CHANGED
@@ -1567,7 +1567,7 @@ import { defineComponent as defineComponent2 } from "vue";
1567
1567
 
1568
1568
  // sfc-script:/home/runner/work/docs-live-example/docs-live-example/src/LiveExampleSourcecode.vue?type=script
1569
1569
  import { defineComponent as _defineComponent } from "vue";
1570
- import { ref, computed, onMounted, watch, nextTick } from "vue";
1570
+ import { computed, nextTick, onMounted, ref, useTemplateRef, watch } from "vue";
1571
1571
 
1572
1572
  // src/expand-animation.ts
1573
1573
  var DURATION = 400;
@@ -1612,7 +1612,7 @@ function expandAnimation(element) {
1612
1612
  };
1613
1613
  function shrink() {
1614
1614
  isClosing = true;
1615
- const startHeight = `${element.offsetHeight}px`;
1615
+ const startHeight = `${String(element.offsetHeight)}px`;
1616
1616
  const endHeight = `0px`;
1617
1617
  element.classList.add(ClassNames.COLLAPSING);
1618
1618
  if (animation) {
@@ -1641,7 +1641,9 @@ function expandAnimation(element) {
1641
1641
  currentHeight = element.getBoundingClientRect().height;
1642
1642
  }
1643
1643
  element.setAttribute("aria-expanded", "true");
1644
- window.requestAnimationFrame(() => expand(currentHeight));
1644
+ window.requestAnimationFrame(() => {
1645
+ expand(currentHeight);
1646
+ });
1645
1647
  }
1646
1648
  function expand(currentHeight) {
1647
1649
  isExpanding = true;
@@ -1649,8 +1651,8 @@ function expandAnimation(element) {
1649
1651
  animation.cancel();
1650
1652
  element.style.height = "";
1651
1653
  }
1652
- const startHeight = `${currentHeight}px`;
1653
- const endHeight = `${element.offsetHeight}px`;
1654
+ const startHeight = `${String(currentHeight)}px`;
1655
+ const endHeight = `${String(element.offsetHeight)}px`;
1654
1656
  element.classList.add(ClassNames.EXPANDING);
1655
1657
  animation = element.animate(
1656
1658
  {
@@ -1706,10 +1708,6 @@ function generateId(template) {
1706
1708
  return `le-${hash.toString(16)}`;
1707
1709
  }
1708
1710
 
1709
- // src/utils/highlight.ts
1710
- import { format } from "prettier/standalone";
1711
- import htmlPlugin from "prettier/plugins/html";
1712
-
1713
1711
  // node_modules/highlight.js/es/core.js
1714
1712
  var import_core = __toESM(require_core(), 1);
1715
1713
  var core_default = import_core.default;
@@ -1941,6 +1939,8 @@ function xml(hljs) {
1941
1939
  }
1942
1940
 
1943
1941
  // src/utils/highlight.ts
1942
+ import htmlPlugin from "prettier/plugins/html";
1943
+ import { format } from "prettier/standalone";
1944
1944
  core_default.registerLanguage("html", xml);
1945
1945
  var prettierConfig = {
1946
1946
  parser: "html",
@@ -1974,29 +1974,28 @@ async function getSourceCode(options) {
1974
1974
  }
1975
1975
  }
1976
1976
 
1977
+ // src/utils/to-kebab-case.ts
1978
+ function toKebabCase(input) {
1979
+ return input.replace(
1980
+ /[A-Z]+(?![a-z])|[A-Z]/g,
1981
+ ($, ofs) => (ofs ? "-" : "") + $.toLowerCase()
1982
+ );
1983
+ }
1984
+
1977
1985
  // sfc-script:/home/runner/work/docs-live-example/docs-live-example/src/LiveExampleSourcecode.vue?type=script
1978
1986
  var LiveExampleSourcecode_default = /* @__PURE__ */ _defineComponent({
1979
1987
  __name: "LiveExampleSourcecode",
1980
1988
  props: {
1981
- element: {
1982
- type: HTMLElement,
1983
- required: true
1984
- },
1985
- template: {
1986
- type: String,
1987
- required: true
1988
- },
1989
- templateLanguage: {
1990
- type: String,
1991
- required: true
1992
- }
1989
+ element: { type: null, required: true },
1990
+ template: { type: String, required: true },
1991
+ templateLanguage: { type: String, required: true }
1993
1992
  },
1994
1993
  setup(__props, { expose: __expose }) {
1995
1994
  __expose();
1996
1995
  const props = __props;
1997
1996
  let idPrefix = generateId(props.template);
1998
1997
  const sourcecode = ref("");
1999
- const expandable = ref(null);
1998
+ const expandable = useTemplateRef("expandableRef");
2000
1999
  const animation = ref({
2001
2000
  isOpen: false,
2002
2001
  toggle() {
@@ -2096,7 +2095,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
2096
2095
  { class: "icon icon--code" },
2097
2096
  null,
2098
2097
  -1
2099
- /* HOISTED */
2098
+ /* CACHED */
2100
2099
  )),
2101
2100
  _createTextVNode(
2102
2101
  " " + _toDisplayString($setup.codeToggleText),
@@ -2107,7 +2106,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
2107
2106
  ]),
2108
2107
  _createElementVNode("div", {
2109
2108
  id: $setup.id("code-expand"),
2110
- ref: "expandable",
2109
+ ref: "expandableRef",
2111
2110
  class: "collapsed"
2112
2111
  }, [
2113
2112
  _createCommentVNode(" [html-validate-disable-next wcag/h32 -- this form is not meant to be submitted] "),
@@ -2118,7 +2117,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
2118
2117
  { class: "label fieldset__label" },
2119
2118
  "Kodspr\xE5k",
2120
2119
  -1
2121
- /* HOISTED */
2120
+ /* CACHED */
2122
2121
  )),
2123
2122
  _createElementVNode("div", _hoisted_6, [
2124
2123
  $props.templateLanguage === "vue" ? (_openBlock(), _createElementBlock("div", _hoisted_7, [
@@ -2174,7 +2173,7 @@ LiveExampleSourcecode_default.__scopeId = "data-v-7a98eb26";
2174
2173
  var LiveExampleSourcecode_default2 = LiveExampleSourcecode_default;
2175
2174
 
2176
2175
  // src/live-vue-code.ts
2177
- import { defineComponent, compile, h } from "vue";
2176
+ import { compile, defineComponent, h } from "vue";
2178
2177
  var live_vue_code_default = defineComponent({
2179
2178
  name: "LiveVueCode",
2180
2179
  props: {
@@ -2345,15 +2344,15 @@ function render2(_ctx, _cache, $props, $setup, $data, $options) {
2345
2344
  ],
2346
2345
  2112
2347
2346
  /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
2348
- )) : (_openBlock2(), _createElementBlock2("div", _hoisted_52, _cache[0] || (_cache[0] = [
2347
+ )) : (_openBlock2(), _createElementBlock2("div", _hoisted_52, [..._cache[0] || (_cache[0] = [
2349
2348
  _createElementVNode2(
2350
2349
  "pre",
2351
2350
  null,
2352
2351
  "Unknown language, cannot render example",
2353
2352
  -1
2354
- /* HOISTED */
2353
+ /* CACHED */
2355
2354
  )
2356
- ])))
2355
+ ])]))
2357
2356
  ],
2358
2357
  512
2359
2358
  /* NEED_PATCH */
@@ -2430,7 +2429,7 @@ function serializeAttribute(key, value, prefix = "") {
2430
2429
  return [];
2431
2430
  }
2432
2431
  if (typeof value === "string" || typeof value === "number") {
2433
- return `${prefix}${key}="${value}"`;
2432
+ return `${prefix}${key}="${String(value)}"`;
2434
2433
  }
2435
2434
  if (typeof value === "boolean") {
2436
2435
  return value ? `${prefix}${key}` : [];
@@ -2441,7 +2440,9 @@ function serializeAttribute(key, value, prefix = "") {
2441
2440
  }
2442
2441
  function serializeAttributes(attrs) {
2443
2442
  const entries = Object.entries(attrs);
2444
- const kv = entries.map(([key, value]) => serializeAttribute(key, value));
2443
+ const kv = entries.map(
2444
+ ([key, value]) => serializeAttribute(toKebabCase(key), value)
2445
+ );
2445
2446
  const flat = kv.flat();
2446
2447
  if (flat.length > 0) {
2447
2448
  return ` ${kv.flat().join(" ")}`;
package/dist/main.css CHANGED
@@ -33,9 +33,18 @@
33
33
  .live-example__example {
34
34
  grid-area: example;
35
35
  padding: var(--live-example-space);
36
- background: repeating-conic-gradient(#fff 0 90deg, rgb(235, 235, 235) 0 180deg) 0 0/20px 20px round;
37
36
  overflow: auto;
38
37
  }
38
+ @media (prefers-color-scheme: light) {
39
+ .live-example__example {
40
+ background: repeating-conic-gradient(#fff 0 90deg, rgb(235, 235, 235) 0 180deg) 0 0/20px 20px round;
41
+ }
42
+ }
43
+ @media (prefers-color-scheme: dark) {
44
+ .live-example__example {
45
+ background: repeating-conic-gradient(#1b1e23 0 90deg, #313438 0 180deg) 0 0/20px 20px round;
46
+ }
47
+ }
39
48
  .live-example__controls {
40
49
  grid-area: controls;
41
50
  padding: var(--live-example-space);
@@ -2,3 +2,4 @@ export { generateId } from "./generate-id";
2
2
  export { getSourceCode } from "./get-source-code";
3
3
  export { highlight } from "./highlight";
4
4
  export { stripComments } from "./strip-comments";
5
+ export { toKebabCase } from "./to-kebab-case";
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @internal
3
+ */
4
+ export declare function toKebabCase(input: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forsakringskassan/docs-live-example",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "description": "Components used for live examples",
5
5
  "keywords": [
6
6
  "documentation"