@forsakringskassan/docs-live-example 2.1.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
- }>, void, {}, {}, {}, 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
- }>, void, {}, {}, {}, 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",
@@ -2000,25 +2000,16 @@ function toKebabCase(input) {
2000
2000
  var LiveExampleSourcecode_default = /* @__PURE__ */ (0, import_vue.defineComponent)({
2001
2001
  __name: "LiveExampleSourcecode",
2002
2002
  props: {
2003
- element: {
2004
- type: HTMLElement,
2005
- required: true
2006
- },
2007
- template: {
2008
- type: String,
2009
- required: true
2010
- },
2011
- templateLanguage: {
2012
- type: String,
2013
- required: true
2014
- }
2003
+ element: { type: null, required: true },
2004
+ template: { type: String, required: true },
2005
+ templateLanguage: { type: String, required: true }
2015
2006
  },
2016
2007
  setup(__props, { expose: __expose }) {
2017
2008
  __expose();
2018
2009
  const props = __props;
2019
2010
  let idPrefix = generateId(props.template);
2020
2011
  const sourcecode = (0, import_vue2.ref)("");
2021
- const expandable = (0, import_vue2.ref)(null);
2012
+ const expandable = (0, import_vue2.useTemplateRef)("expandableRef");
2022
2013
  const animation = (0, import_vue2.ref)({
2023
2014
  isOpen: false,
2024
2015
  toggle() {
@@ -2129,7 +2120,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
2129
2120
  ]),
2130
2121
  (0, import_vue3.createElementVNode)("div", {
2131
2122
  id: $setup.id("code-expand"),
2132
- ref: "expandable",
2123
+ ref: "expandableRef",
2133
2124
  class: "collapsed"
2134
2125
  }, [
2135
2126
  (0, import_vue3.createCommentVNode)(" [html-validate-disable-next wcag/h32 -- this form is not meant to be submitted] "),
@@ -2367,7 +2358,7 @@ function render2(_ctx, _cache, $props, $setup, $data, $options) {
2367
2358
  ],
2368
2359
  2112
2369
2360
  /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
2370
- )) : ((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] = [
2371
2362
  (0, import_vue6.createElementVNode)(
2372
2363
  "pre",
2373
2364
  null,
@@ -2375,7 +2366,7 @@ function render2(_ctx, _cache, $props, $setup, $data, $options) {
2375
2366
  -1
2376
2367
  /* CACHED */
2377
2368
  )
2378
- ])))
2369
+ ])]))
2379
2370
  ],
2380
2371
  512
2381
2372
  /* NEED_PATCH */
@@ -2452,7 +2443,7 @@ function serializeAttribute(key, value, prefix = "") {
2452
2443
  return [];
2453
2444
  }
2454
2445
  if (typeof value === "string" || typeof value === "number") {
2455
- return `${prefix}${key}="${value}"`;
2446
+ return `${prefix}${key}="${String(value)}"`;
2456
2447
  }
2457
2448
  if (typeof value === "boolean") {
2458
2449
  return value ? `${prefix}${key}` : [];
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",
@@ -1986,25 +1986,16 @@ function toKebabCase(input) {
1986
1986
  var LiveExampleSourcecode_default = /* @__PURE__ */ _defineComponent({
1987
1987
  __name: "LiveExampleSourcecode",
1988
1988
  props: {
1989
- element: {
1990
- type: HTMLElement,
1991
- required: true
1992
- },
1993
- template: {
1994
- type: String,
1995
- required: true
1996
- },
1997
- templateLanguage: {
1998
- type: String,
1999
- required: true
2000
- }
1989
+ element: { type: null, required: true },
1990
+ template: { type: String, required: true },
1991
+ templateLanguage: { type: String, required: true }
2001
1992
  },
2002
1993
  setup(__props, { expose: __expose }) {
2003
1994
  __expose();
2004
1995
  const props = __props;
2005
1996
  let idPrefix = generateId(props.template);
2006
1997
  const sourcecode = ref("");
2007
- const expandable = ref(null);
1998
+ const expandable = useTemplateRef("expandableRef");
2008
1999
  const animation = ref({
2009
2000
  isOpen: false,
2010
2001
  toggle() {
@@ -2115,7 +2106,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
2115
2106
  ]),
2116
2107
  _createElementVNode("div", {
2117
2108
  id: $setup.id("code-expand"),
2118
- ref: "expandable",
2109
+ ref: "expandableRef",
2119
2110
  class: "collapsed"
2120
2111
  }, [
2121
2112
  _createCommentVNode(" [html-validate-disable-next wcag/h32 -- this form is not meant to be submitted] "),
@@ -2182,7 +2173,7 @@ LiveExampleSourcecode_default.__scopeId = "data-v-7a98eb26";
2182
2173
  var LiveExampleSourcecode_default2 = LiveExampleSourcecode_default;
2183
2174
 
2184
2175
  // src/live-vue-code.ts
2185
- import { defineComponent, compile, h } from "vue";
2176
+ import { compile, defineComponent, h } from "vue";
2186
2177
  var live_vue_code_default = defineComponent({
2187
2178
  name: "LiveVueCode",
2188
2179
  props: {
@@ -2353,7 +2344,7 @@ function render2(_ctx, _cache, $props, $setup, $data, $options) {
2353
2344
  ],
2354
2345
  2112
2355
2346
  /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
2356
- )) : (_openBlock2(), _createElementBlock2("div", _hoisted_52, _cache[0] || (_cache[0] = [
2347
+ )) : (_openBlock2(), _createElementBlock2("div", _hoisted_52, [..._cache[0] || (_cache[0] = [
2357
2348
  _createElementVNode2(
2358
2349
  "pre",
2359
2350
  null,
@@ -2361,7 +2352,7 @@ function render2(_ctx, _cache, $props, $setup, $data, $options) {
2361
2352
  -1
2362
2353
  /* CACHED */
2363
2354
  )
2364
- ])))
2355
+ ])]))
2365
2356
  ],
2366
2357
  512
2367
2358
  /* NEED_PATCH */
@@ -2438,7 +2429,7 @@ function serializeAttribute(key, value, prefix = "") {
2438
2429
  return [];
2439
2430
  }
2440
2431
  if (typeof value === "string" || typeof value === "number") {
2441
- return `${prefix}${key}="${value}"`;
2432
+ return `${prefix}${key}="${String(value)}"`;
2442
2433
  }
2443
2434
  if (typeof value === "boolean") {
2444
2435
  return value ? `${prefix}${key}` : [];
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forsakringskassan/docs-live-example",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Components used for live examples",
5
5
  "keywords": [
6
6
  "documentation"