@nordcraft/runtime 1.0.57 → 1.0.59

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 (39) hide show
  1. package/dist/components/createComponent.js +12 -13
  2. package/dist/components/createComponent.js.map +1 -1
  3. package/dist/components/createElement.js +9 -7
  4. package/dist/components/createElement.js.map +1 -1
  5. package/dist/components/createNode.js.map +1 -1
  6. package/dist/custom-element.main.esm.js +27 -27
  7. package/dist/custom-element.main.esm.js.map +4 -4
  8. package/dist/editor/input.d.ts +1 -0
  9. package/dist/editor/input.js +16 -0
  10. package/dist/editor/input.js.map +1 -0
  11. package/dist/editor/links.d.ts +6 -0
  12. package/dist/editor/links.js +15 -0
  13. package/dist/editor/links.js.map +1 -0
  14. package/dist/editor/overlay.d.ts +12 -0
  15. package/dist/editor/overlay.js +20 -0
  16. package/dist/editor/overlay.js.map +1 -0
  17. package/dist/editor/types.d.ts +254 -0
  18. package/dist/editor/types.js +42 -0
  19. package/dist/editor/types.js.map +1 -0
  20. package/dist/editor-preview.main.js +147 -198
  21. package/dist/editor-preview.main.js.map +1 -1
  22. package/dist/page.main.esm.js +3 -3
  23. package/dist/page.main.esm.js.map +4 -4
  24. package/dist/page.main.js +20 -0
  25. package/dist/page.main.js.map +1 -1
  26. package/dist/styles/CustomPropertyStyleSheet.test.js +12 -3
  27. package/dist/styles/CustomPropertyStyleSheet.test.js.map +1 -1
  28. package/package.json +4 -4
  29. package/src/components/createComponent.ts +27 -20
  30. package/src/components/createElement.ts +29 -21
  31. package/src/components/createNode.ts +0 -1
  32. package/src/editor/input.ts +17 -0
  33. package/src/editor/links.ts +16 -0
  34. package/src/editor/overlay.ts +21 -0
  35. package/src/editor/types.ts +271 -0
  36. package/src/editor-preview.main.ts +180 -411
  37. package/src/page.main.ts +23 -0
  38. package/src/styles/CustomPropertyStyleSheet.test.ts +12 -3
  39. package/src/editor/types.d.ts +0 -36
package/src/page.main.ts CHANGED
@@ -175,6 +175,29 @@ export const createRoot = (domNode: HTMLElement) => {
175
175
  ]),
176
176
  })
177
177
 
178
+ const langFormula = component.route?.info?.language?.formula
179
+ const dynamicLang = langFormula && langFormula.type !== 'value'
180
+ if (dynamicLang) {
181
+ dataSignal
182
+ .map<string | null>(() =>
183
+ component
184
+ ? applyFormula(langFormula, {
185
+ data: dataSignal.get(),
186
+ component,
187
+ root: document,
188
+ package: undefined,
189
+ toddle: window.toddle,
190
+ env,
191
+ })
192
+ : null,
193
+ )
194
+ .subscribe((newLang) => {
195
+ if (isDefined(newLang) && document.documentElement.lang !== newLang) {
196
+ document.documentElement.setAttribute('lang', newLang)
197
+ }
198
+ })
199
+ }
200
+
178
201
  // Handle dynamic updates of <head> elements (title, og:image etc.)
179
202
  const titleFormula = component.route?.info?.title?.formula
180
203
  const dynamicTitle = titleFormula && titleFormula.type !== 'value'
@@ -50,7 +50,10 @@ describe('CustomPropertyStyleSheet', () => {
50
50
  })('256px')
51
51
  expect(instance.getStyleSheet().cssRules.length).toBe(1)
52
52
  expect(instance.getStyleSheet().cssRules[0].cssText).toBe(
53
- '@media (max-width: 600px) { .my-class { --my-property: 256px; } }',
53
+ `\
54
+ @media (max-width: 600px) {
55
+ .my-class { --my-property: 256px; }
56
+ }`,
54
57
  )
55
58
  })
56
59
 
@@ -87,7 +90,10 @@ describe('CustomPropertyStyleSheet', () => {
87
90
  setter('256px')
88
91
  expect(instance.getStyleSheet().cssRules.length).toBe(1)
89
92
  expect(instance.getStyleSheet().cssRules[0].cssText).toBe(
90
- '@media (max-width: 600px) { .my-class-with-media { --my-property-with-media: 256px; } }',
93
+ `\
94
+ @media (max-width: 600px) {
95
+ .my-class-with-media { --my-property-with-media: 256px; }
96
+ }`,
91
97
  )
92
98
 
93
99
  instance.unregisterProperty(
@@ -98,7 +104,10 @@ describe('CustomPropertyStyleSheet', () => {
98
104
  },
99
105
  )
100
106
  expect(instance.getStyleSheet().cssRules[0].cssText).toBe(
101
- '@media (max-width: 600px) { .my-class-with-media { } }',
107
+ `\
108
+ @media (max-width: 600px) {
109
+ .my-class-with-media { }
110
+ }`,
102
111
  )
103
112
  })
104
113
  })
@@ -1,36 +0,0 @@
1
- export type DragState = {
2
- /**
3
- * Dragging elements within the initial container is a reorder operation while dragging elements outside the initial container is an insert operation.
4
- * While they share some common properties, we need to differentiate between the two to handle them differently.
5
- */
6
- mode: 'reorder' | 'insert'
7
- elementType: 'element' | 'component' | 'text'
8
- copy?: HTMLElement
9
- element: HTMLElement
10
- repeatedNodes: HTMLElement[]
11
- offset: Point
12
- lastCursorPosition: Point
13
- initialContainer: HTMLElement
14
- initialNextSibling: Element | null
15
- initialRect: DOMRect
16
- reorderPermutations: Array<{
17
- nextSibling: Node | null
18
- rect: DOMRect
19
- }>
20
- isTransitioning: boolean
21
- selectedInsertAreaIndex?: number
22
- insertAreas?: Array<InsertArea>
23
- destroying: boolean
24
- }
25
-
26
- export type InsertArea = {
27
- layout: 'block' | 'inline'
28
- parent: Element
29
- index: number
30
- center: Point
31
- size: number
32
- direction: 1 | -1
33
- }
34
-
35
- export type Point = { x: number; y: number }
36
- export type Line = { x1: number; y1: number; x2: number; y2: number }