p-elements-core 2.1.0-rc9 → 2.1.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 (145) hide show
  1. package/dist/p-elements-core.js +1 -1
  2. package/package.json +15 -5
  3. package/readme.md +13 -13
  4. package/typings/custom-element-controller.d.ts +18 -0
  5. package/typings/custom-element-controller.d.ts.map +1 -0
  6. package/typings/custom-element.d.ts +140 -0
  7. package/typings/custom-element.d.ts.map +1 -0
  8. package/typings/decorators/bind.d.ts +6 -0
  9. package/typings/decorators/bind.d.ts.map +1 -0
  10. package/typings/decorators/custom-element-config.d.ts +8 -0
  11. package/typings/decorators/custom-element-config.d.ts.map +1 -0
  12. package/typings/decorators/property.d.ts +213 -0
  13. package/typings/decorators/property.d.ts.map +1 -0
  14. package/typings/decorators/query.d.ts +2 -0
  15. package/typings/decorators/query.d.ts.map +1 -0
  16. package/typings/decorators/render-property-on-set.d.ts +2 -0
  17. package/typings/decorators/render-property-on-set.d.ts.map +1 -0
  18. package/typings/maquette/cache.d.ts +10 -0
  19. package/typings/maquette/cache.d.ts.map +1 -0
  20. package/typings/maquette/dom.d.ts +60 -0
  21. package/typings/maquette/dom.d.ts.map +1 -0
  22. package/typings/maquette/h.d.ts +35 -0
  23. package/typings/maquette/h.d.ts.map +1 -0
  24. package/{src/maquette/index.ts → typings/maquette/index.d.ts} +1 -1
  25. package/typings/maquette/index.d.ts.map +1 -0
  26. package/typings/maquette/interfaces.d.ts +475 -0
  27. package/typings/maquette/interfaces.d.ts.map +1 -0
  28. package/typings/maquette/jsx.d.ts +6 -0
  29. package/typings/maquette/jsx.d.ts.map +1 -0
  30. package/typings/maquette/mapping.d.ts +14 -0
  31. package/typings/maquette/mapping.d.ts.map +1 -0
  32. package/typings/maquette/projection.d.ts +9 -0
  33. package/typings/maquette/projection.d.ts.map +1 -0
  34. package/typings/maquette/projector.d.ts +27 -0
  35. package/typings/maquette/projector.d.ts.map +1 -0
  36. package/typings/p-elements-core.d.ts +239 -0
  37. package/typings/p-elements-core.d.ts.map +1 -0
  38. package/.babelrc +0 -21
  39. package/.editorconfig +0 -17
  40. package/.gitlab-ci.yml +0 -18
  41. package/demo/sample.js +0 -1
  42. package/demo/screen.css +0 -6
  43. package/demo/theme.css +0 -14
  44. package/docs/.eleventy.js +0 -109
  45. package/docs/package.json +0 -27
  46. package/docs/src/404.md +0 -8
  47. package/docs/src/_data/demos/animation/animation.tsx +0 -216
  48. package/docs/src/_data/demos/animation/index.html +0 -10
  49. package/docs/src/_data/demos/animation/project.json +0 -7
  50. package/docs/src/_data/demos/hello-world/hello-world.tsx +0 -35
  51. package/docs/src/_data/demos/hello-world/index.html +0 -10
  52. package/docs/src/_data/demos/hello-world/project.json +0 -7
  53. package/docs/src/_data/demos/timer/demo-timer.tsx +0 -120
  54. package/docs/src/_data/demos/timer/icons.tsx +0 -62
  55. package/docs/src/_data/demos/timer/index.html +0 -12
  56. package/docs/src/_data/demos/timer/project.json +0 -8
  57. package/docs/src/_data/global.js +0 -14
  58. package/docs/src/_data/helpers.js +0 -19
  59. package/docs/src/_includes/layouts/base.njk +0 -31
  60. package/docs/src/_includes/layouts/playground.njk +0 -40
  61. package/docs/src/_includes/partials/app-header.njk +0 -9
  62. package/docs/src/_includes/partials/head.njk +0 -15
  63. package/docs/src/_includes/partials/nav.njk +0 -20
  64. package/docs/src/_includes/partials/top-nav.njk +0 -52
  65. package/docs/src/assets/favicon.png +0 -0
  66. package/docs/src/assets/logo.svg +0 -9
  67. package/docs/src/documentation/custom-element-controller.md +0 -294
  68. package/docs/src/documentation/custom-element.md +0 -221
  69. package/docs/src/documentation/decorators/bind.md +0 -71
  70. package/docs/src/documentation/decorators/custom-element-config.md +0 -63
  71. package/docs/src/documentation/decorators/property.md +0 -83
  72. package/docs/src/documentation/decorators/query.md +0 -66
  73. package/docs/src/documentation/decorators/render-property-on-set.md +0 -60
  74. package/docs/src/documentation/decorators.md +0 -9
  75. package/docs/src/documentation/getting-started.md +0 -60
  76. package/docs/src/documentation/index.md +0 -33
  77. package/docs/src/documentation/reactive-properties.md +0 -54
  78. package/docs/src/index.d.ts +0 -25
  79. package/docs/src/index.md +0 -3
  80. package/docs/src/playground/animation.njk +0 -10
  81. package/docs/src/playground/index.njk +0 -10
  82. package/docs/src/playground/timer.njk +0 -10
  83. package/docs/src/scripts/components/app-drawer/app-drawer.css +0 -92
  84. package/docs/src/scripts/components/app-drawer/app-drawer.tsx +0 -67
  85. package/docs/src/scripts/components/app-mobile-menu/app-mobile-menu.css +0 -48
  86. package/docs/src/scripts/components/app-mobile-menu/app-mobile-menu.tsx +0 -112
  87. package/docs/src/scripts/components/app-mode-switch/app-mode-switch.css +0 -78
  88. package/docs/src/scripts/components/app-mode-switch/app-mode-switch.tsx +0 -166
  89. package/docs/src/scripts/components/app-playground/app-playground.tsx +0 -190
  90. package/docs/src/scripts/components/app-split-panel/app-split-panel.css +0 -33
  91. package/docs/src/scripts/components/app-split-panel/app-split-panel.tsx +0 -73
  92. package/docs/src/scripts/components/app-split-panel/resize-bar.tsx +0 -155
  93. package/docs/src/scripts/components/lazy-svg/lazy-svg.tsx +0 -94
  94. package/docs/src/scripts/index.ts +0 -6
  95. package/docs/src/scripts/playground.ts +0 -1
  96. package/docs/src/styles/main.css +0 -699
  97. package/docs/tsconfig.json +0 -22
  98. package/index.html +0 -49
  99. package/src/custom-element-controller.ts +0 -31
  100. package/src/custom-element.ts +0 -588
  101. package/src/decorators/bind.ts +0 -46
  102. package/src/decorators/custom-element-config.ts +0 -17
  103. package/src/decorators/property.ts +0 -684
  104. package/src/decorators/query.ts +0 -12
  105. package/src/decorators/render-property-on-set.ts +0 -3
  106. package/src/maquette/cache.ts +0 -35
  107. package/src/maquette/dom.ts +0 -115
  108. package/src/maquette/h.ts +0 -100
  109. package/src/maquette/interfaces.ts +0 -536
  110. package/src/maquette/jsx.ts +0 -61
  111. package/src/maquette/mapping.ts +0 -56
  112. package/src/maquette/projection.ts +0 -666
  113. package/src/maquette/projector.ts +0 -200
  114. package/src/p-elements-core.ts +0 -260
  115. package/src/sample/animate.tsx +0 -199
  116. package/src/sample/mixin/highlight.tsx +0 -33
  117. package/src/sample/sample.tsx +0 -447
  118. package/storybook/storybook-demo/.storybook/main.ts +0 -30
  119. package/storybook/storybook-demo/.storybook/preview-head.html +0 -1
  120. package/storybook/storybook-demo/.storybook/preview.ts +0 -20
  121. package/storybook/storybook-demo/package.json +0 -23
  122. package/storybook/storybook-demo/stories/bar.stories.tsx +0 -27
  123. package/storybook/storybook-demo/stories/baz.stories.tsx +0 -37
  124. package/storybook/storybook-demo/stories/foo.mdx +0 -11
  125. package/storybook/storybook-demo/stories/foo.stories.tsx +0 -27
  126. package/storybook/storybook-demo/stories/foo.tsx +0 -24
  127. package/storybook/storybook-demo/tsconfig.json +0 -30
  128. package/storybook/storybook-p-element-vite/README.md +0 -97
  129. package/storybook/storybook-p-element-vite/package.json +0 -81
  130. package/storybook/storybook-p-element-vite/preset.js +0 -2
  131. package/storybook/storybook-p-element-vite/src/docs/index.ts +0 -8
  132. package/storybook/storybook-p-element-vite/src/docs/source-decorator.ts +0 -55
  133. package/storybook/storybook-p-element-vite/src/entry-preview-docs.ts +0 -16
  134. package/storybook/storybook-p-element-vite/src/entry-preview.ts +0 -8
  135. package/storybook/storybook-p-element-vite/src/index.ts +0 -9
  136. package/storybook/storybook-p-element-vite/src/node/index.ts +0 -5
  137. package/storybook/storybook-p-element-vite/src/portable-stories.ts +0 -35
  138. package/storybook/storybook-p-element-vite/src/preset.ts +0 -69
  139. package/storybook/storybook-p-element-vite/src/render.ts +0 -96
  140. package/storybook/storybook-p-element-vite/src/types.ts +0 -99
  141. package/storybook/storybook-p-element-vite/tsconfig.json +0 -14
  142. package/storybook/storybook-p-element-vite/tsdown.config.ts +0 -26
  143. package/tsconfig.json +0 -67
  144. package/tsconfig.sample.json +0 -20
  145. package/webpack.config.js +0 -76
@@ -1,35 +0,0 @@
1
- import { CalculationCache } from "./interfaces";
2
-
3
- /**
4
- * Creates a [[CalculationCache]] object, useful for caching [[VNode]] trees.
5
- * In practice, caching of [[VNode]] trees is not needed, because achieving 60 frames per second is almost never a problem.
6
- * For more information, see [[CalculationCache]].
7
- *
8
- * @param <Result> The type of the value that is cached.
9
- */
10
- export let createCache = <Result,>(): CalculationCache<Result> => {
11
- let cachedInputs: unknown[] | undefined;
12
- let cachedOutcome: Result | undefined;
13
-
14
- return {
15
- invalidate: () => {
16
- cachedOutcome = undefined;
17
- cachedInputs = undefined;
18
- },
19
-
20
- result: (inputs: unknown[], calculation: () => Result) => {
21
- if (cachedInputs) {
22
- for (let i = 0; i < inputs.length; i++) {
23
- if (cachedInputs[i] !== inputs[i]) {
24
- cachedOutcome = undefined;
25
- }
26
- }
27
- }
28
- if (!cachedOutcome) {
29
- cachedOutcome = calculation();
30
- cachedInputs = inputs;
31
- }
32
- return cachedOutcome;
33
- },
34
- };
35
- };
@@ -1,115 +0,0 @@
1
- /**
2
- * Contains simple low-level utility functions to manipulate the real DOM.
3
- */
4
- import { Projection, ProjectionOptions, VNode } from "./interfaces";
5
- import { createDom, createProjection, extend, initPropertiesAndChildren } from "./projection";
6
-
7
- const DEFAULT_PROJECTION_OPTIONS: ProjectionOptions = {
8
- namespace: undefined,
9
- performanceLogger: () => undefined,
10
- eventHandlerInterceptor: undefined,
11
- styleApplyer: (domNode: HTMLElement, styleName: string, value: string) => {
12
- if (styleName.charAt(0) === "-") {
13
- // CSS variables must be set using setProperty
14
- domNode.style.setProperty(styleName, value);
15
- } else {
16
- // properties like 'backgroundColor' must be set as a js-property
17
- (domNode.style as any)[styleName] = value;
18
- }
19
- },
20
- };
21
-
22
- export let applyDefaultProjectionOptions = (
23
- projectorOptions?: ProjectionOptions
24
- ): ProjectionOptions => {
25
- return extend(DEFAULT_PROJECTION_OPTIONS, projectorOptions);
26
- };
27
-
28
- export let dom = {
29
- /**
30
- * Creates a real DOM tree from `vnode`. The [[Projection]] object returned will contain the resulting DOM Node in
31
- * its [[Projection.domNode|domNode]] property.
32
- * This is a low-level method. Users will typically use a [[Projector]] instead.
33
- * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]]
34
- * objects may only be rendered once.
35
- * @param projectionOptions - Options to be used to create and update the projection.
36
- * @returns The [[Projection]] which also contains the DOM Node that was created.
37
- */
38
- create: (vnode: VNode, projectionOptions?: ProjectionOptions): Projection => {
39
- projectionOptions = applyDefaultProjectionOptions(projectionOptions);
40
- createDom(vnode, document.createElement("div"), undefined, projectionOptions);
41
- return createProjection(vnode, projectionOptions);
42
- },
43
-
44
- /**
45
- * Appends a new child node to the DOM which is generated from a [[VNode]].
46
- * This is a low-level method. Users will typically use a [[Projector]] instead.
47
- * @param parentNode - The parent node for the new child node.
48
- * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]]
49
- * objects may only be rendered once.
50
- * @param projectionOptions - Options to be used to create and update the [[Projection]].
51
- * @returns The [[Projection]] that was created.
52
- */
53
- append: (
54
- parentNode: Element,
55
- vnode: VNode,
56
- projectionOptions?: ProjectionOptions
57
- ): Projection => {
58
- projectionOptions = applyDefaultProjectionOptions(projectionOptions);
59
- createDom(vnode, parentNode, undefined, projectionOptions);
60
- return createProjection(vnode, projectionOptions);
61
- },
62
-
63
- /**
64
- * Inserts a new DOM node which is generated from a [[VNode]].
65
- * This is a low-level method. Users wil typically use a [[Projector]] instead.
66
- * @param beforeNode - The node that the DOM Node is inserted before.
67
- * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function.
68
- * NOTE: [[VNode]] objects may only be rendered once.
69
- * @param projectionOptions - Options to be used to create and update the projection, see [[createProjector]].
70
- * @returns The [[Projection]] that was created.
71
- */
72
- insertBefore: (
73
- beforeNode: Element,
74
- vnode: VNode,
75
- projectionOptions?: ProjectionOptions
76
- ): Projection => {
77
- projectionOptions = applyDefaultProjectionOptions(projectionOptions);
78
- createDom(vnode, beforeNode.parentNode!, beforeNode, projectionOptions);
79
- return createProjection(vnode, projectionOptions);
80
- },
81
-
82
- /**
83
- * Merges a new DOM node which is generated from a [[VNode]] with an existing DOM Node.
84
- * This means that the virtual DOM and the real DOM will have one overlapping element.
85
- * Therefore the selector for the root [[VNode]] will be ignored, but its properties and children will be applied to the Element provided.
86
- * This is a low-level method. Users wil typically use a [[Projector]] instead.
87
- * @param element - The existing element to adopt as the root of the new virtual DOM. Existing attributes and child nodes are preserved.
88
- * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]] objects
89
- * may only be rendered once.
90
- * @param projectionOptions - Options to be used to create and update the projection, see [[createProjector]].
91
- * @returns The [[Projection]] that was created.
92
- */
93
- merge: (element: Element, vnode: VNode, projectionOptions?: ProjectionOptions): Projection => {
94
- projectionOptions = applyDefaultProjectionOptions(projectionOptions);
95
- vnode.domNode = element;
96
- initPropertiesAndChildren(element, vnode, projectionOptions);
97
- return createProjection(vnode, projectionOptions);
98
- },
99
-
100
- /**
101
- * Replaces an existing DOM node with a node generated from a [[VNode]].
102
- * This is a low-level method. Users will typically use a [[Projector]] instead.
103
- * @param element - The node for the [[VNode]] to replace.
104
- * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]]
105
- * objects may only be rendered once.
106
- * @param projectionOptions - Options to be used to create and update the [[Projection]].
107
- * @returns The [[Projection]] that was created.
108
- */
109
- replace: (element: Element, vnode: VNode, projectionOptions?: ProjectionOptions): Projection => {
110
- projectionOptions = applyDefaultProjectionOptions(projectionOptions);
111
- createDom(vnode, element.parentNode!, element, projectionOptions);
112
- element.parentNode!.removeChild(element);
113
- return createProjection(vnode, projectionOptions);
114
- },
115
- };
package/src/maquette/h.ts DELETED
@@ -1,100 +0,0 @@
1
- import { VNode, VNodeChild, VNodeProperties } from "./interfaces";
2
-
3
- let toTextVNode = (data: string): VNode => {
4
- return {
5
- vnodeSelector: "",
6
- properties: undefined,
7
- children: undefined,
8
- text: data.toString(),
9
- domNode: null,
10
- };
11
- };
12
-
13
- let appendChildren = (parentSelector: string, insertions: VNodeChild[], main: VNode[]) => {
14
- for (let i = 0, length = insertions.length; i < length; i++) {
15
- let item = insertions[i];
16
- if (Array.isArray(item)) {
17
- appendChildren(parentSelector, item, main);
18
- } else {
19
- if (item !== null && item !== undefined && item !== false) {
20
- if (typeof item === "string") {
21
- item = toTextVNode(item);
22
- }
23
- main.push(item);
24
- }
25
- }
26
- }
27
- };
28
-
29
- /**
30
- * The `h` function is used to create a virtual DOM node.
31
- * This function is largely inspired by the mercuryjs and mithril frameworks.
32
- * The `h` stands for (virtual) hyperscript.
33
- *
34
- * @param selector Contains the tagName, id and fixed css classnames in CSS selector format.
35
- * It is formatted as follows: `tagname.cssclass1.cssclass2#id`.
36
- * @param properties An object literal containing properties that will be placed on the DOM node.
37
- * @param children Virtual DOM nodes and strings to add as child nodes.
38
- * `children` may contain [[VNode]]s, `string`s, nested arrays, `null` and `undefined`.
39
- * Nested arrays are flattened, `null` and `undefined` are removed.
40
- *
41
- * @returns A VNode object, used to render a real DOM later.
42
- *
43
- * NOTE: There are {@link http://maquettejs.org/docs/rules.html two basic rules} you should be aware of when updating the virtual DOM.
44
- */
45
- export function h(
46
- selector: string,
47
- properties?: VNodeProperties,
48
- children?: VNodeChild[] | null
49
- ): VNode;
50
- /**
51
- * The `h` function is used to create a virtual DOM node.
52
- * This function is largely inspired by the mercuryjs and mithril frameworks.
53
- * The `h` stands for (virtual) hyperscript.
54
- *
55
- * @param selector Contains the tagName, id and fixed css classnames in CSS selector format.
56
- * It is formatted as follows: `tagname.cssclass1.cssclass2#id`.
57
- * @param children Virtual DOM nodes and strings to add as child nodes.
58
- * `children` may contain [[VNode]]s, `string`s, nested arrays, `null` and `undefined`.
59
- * Nested arrays are flattened, `null` and `undefined` are removed.
60
- *
61
- * @returns A VNode object, used to render a real DOM later.
62
- *
63
- * NOTE: There are {@link http://maquettejs.org/docs/rules.html two basic rules} you should be aware of when updating the virtual DOM.
64
- */
65
- export function h(selector: string, children: VNodeChild[]): VNode;
66
-
67
- export function h(
68
- selector: string,
69
- properties?: VNodeProperties,
70
- children?: VNodeChild[] | null
71
- ): VNode {
72
- if (Array.isArray(properties)) {
73
- children = properties;
74
- properties = undefined;
75
- } else if (
76
- (properties && (typeof (properties as any) === "string" || properties.vnodeSelector)) ||
77
- (children && (typeof (children as any) === "string" || (children as any).vnodeSelector))
78
- ) {
79
- throw new Error("h called with invalid arguments");
80
- }
81
- let text: string | undefined;
82
- let flattenedChildren: VNode[] | undefined;
83
- // Recognize a common special case where there is only a single text node
84
- if (children && children.length === 1 && typeof children[0] === "string") {
85
- text = children[0];
86
- } else if (children) {
87
- flattenedChildren = [];
88
- appendChildren(selector, children, flattenedChildren);
89
- if (flattenedChildren.length === 0) {
90
- flattenedChildren = undefined;
91
- }
92
- }
93
- return {
94
- vnodeSelector: selector,
95
- properties: properties,
96
- children: flattenedChildren,
97
- text: text === "" ? undefined : text,
98
- domNode: null,
99
- };
100
- }