@witchcraft/layout 0.5.4 → 0.5.6

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.
package/README.md CHANGED
@@ -79,6 +79,36 @@ declare module "@witchcraft/layout" {
79
79
  ```
80
80
  Note that `zFrameId` and `zWinId` are different as they also support constants (`zFrameIdConstants` and `zWindowIdConstants`).
81
81
 
82
+ #### Extending Move Types
83
+
84
+ You can also extend the move types. This is usually needed for creating custom actions.
85
+
86
+ Unlike frame types, this uses a pattern where you can extend as many times as you want so long as the key is prefixed with `LayoutMove` and the type satisfies `{ type: string, context: any, resolve: any, moveType: "edge" | "frame" | "other" }`.
87
+
88
+
89
+ ```ts
90
+
91
+ declare module "@witchcraft/layout" {
92
+ interface Register {
93
+ LayoutMovePicker: {
94
+ // used to discriminate the type
95
+ type: "picker",
96
+ // any other props to add to the context parameter of moveStart
97
+ // context ends up typed as { type: "picker", someState: string }
98
+ context: {
99
+ someState: string
100
+ }
101
+ // promise resolve value, for typing the return value of moveStart
102
+ resolve: string
103
+ // for typing the type parameter of moveStart so user picks supported types
104
+ moveType: "other",
105
+ }
106
+ }
107
+ }
108
+ ```
109
+
110
+ `moveStart`'s context parameter will now be type checked as `{someState: string, type: "picker"}` and the return value will be `Promise<string>`.
111
+
82
112
  ## Basics
83
113
 
84
114
  A layout is very simple, and looks like this:
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@witchcraft/layout",
3
3
  "configKey": "witchcraftLayout",
4
- "version": "0.5.4",
4
+ "version": "0.5.6",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"