@witchcraft/layout 0.2.0 → 0.3.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.
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@witchcraft/layout",
3
3
  "configKey": "witchcraftLayout",
4
- "version": "0.2.0",
4
+ "version": "0.3.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
@@ -81,12 +81,12 @@
81
81
  </FrameDragHandle>
82
82
  <div class="flex gap-1 px-2 py-1 flex-wrap">
83
83
  <button
84
- v-if="f.docked && f.collapsed === false"
84
+ v-if="f.docked && !f.collapsed"
85
85
  class="bg-neutral-200 dark:bg-neutral-700 px-2 py-0.5 text-xs rounded"
86
86
  @click="handleUndock(f.id)"
87
87
  >Undock</button>
88
88
  <button
89
- v-if="f.docked && f.collapsed === false"
89
+ v-if="f.docked && !f.collapsed"
90
90
  class="bg-neutral-200 dark:bg-neutral-700 px-2 py-0.5 text-xs rounded"
91
91
  @click="handleCollapse(f.id)"
92
92
  >Collapse</button>
@@ -1 +1 @@
1
- export const dragContextInjectionKey = Symbol("dragContext");
1
+ export const dragContextInjectionKey = Symbol.for("@witchcraft/layout:dragContext");
@@ -37,7 +37,7 @@ export function getFrameDockInfo(win, frameId, side, maxPerpendicularLength) {
37
37
  const effectiveMaxPerpendicular = maxPerpendicularLength ?? settings.maxPerpendicularLengthScaled.width;
38
38
  const perpendicularLength = otherFrameIds.length > 0 ? Math.min(frame[perpendicular], effectiveMaxPerpendicular) : frame[perpendicular];
39
39
  frame.docked = side;
40
- frame.collapsed = false;
40
+ frame.collapsed = void 0;
41
41
  const toExtract = [frame.id];
42
42
  const changes = getFillEmptySpaceInfo(win, oldFrame, [], [frameId]);
43
43
  if (changes instanceof Error) return changes;
@@ -17,7 +17,7 @@ export function getFrameUncollapseInfo(win, frameId) {
17
17
  }
18
18
  const toExtract = [frame.id];
19
19
  const storedSize = frame.collapsed;
20
- if (storedSize === false || storedSize === void 0) {
20
+ if (storedSize === void 0) {
21
21
  return new KnownError(
22
22
  LAYOUT_ERROR.CANT_UNCOLLAPSE_NOT_COLLAPSED,
23
23
  `Frame ${frameId} is not collapsed.`,
@@ -80,7 +80,7 @@ export function getFrameUncollapseInfo(win, frameId) {
80
80
  }
81
81
  pushIfNotIn(toExtract, framesToFix.map((_) => _.id));
82
82
  frame[sizeKey] = storedSize;
83
- frame.collapsed = false;
83
+ frame.collapsed = void 0;
84
84
  if (frame.docked === "right" || frame.docked === "bottom") {
85
85
  frame[posKey] -= expandAmount;
86
86
  }
@@ -17,7 +17,7 @@ export function getFrameUndockInfo(win, frameId) {
17
17
  if (frame.collapsed) {
18
18
  return new KnownError(LAYOUT_ERROR.CANT_UNDOCK_COLLAPSED_FRAME, `Can't undock collapsed frame ${frame.id}.`, { frame: frame.id });
19
19
  }
20
- const frameClone = { ...frame, docked: false, collapsed: false };
20
+ const frameClone = { ...frame, docked: void 0, collapsed: void 0 };
21
21
  const otherDockedFramesToResize = [];
22
22
  const dockedSidesToSearch = [
23
23
  ...frame[posKey] === 0 ? [shrinkStartKey] : [],
@@ -132,7 +132,7 @@ export declare const zLayoutFrame: z.ZodObject<{
132
132
  top: "top";
133
133
  bottom: "bottom";
134
134
  }>>;
135
- collapsed: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodNumber]>>;
135
+ collapsed: z.ZodOptional<z.ZodNumber>;
136
136
  }, z.core.$loose>;
137
137
  export declare const zLayoutFrameLoose: z.ZodObject<{
138
138
  width: z.ZodNumber;
@@ -146,7 +146,7 @@ export declare const zLayoutFrameLoose: z.ZodObject<{
146
146
  top: "top";
147
147
  bottom: "bottom";
148
148
  }>>;
149
- collapsed: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodNumber]>>;
149
+ collapsed: z.ZodOptional<z.ZodNumber>;
150
150
  }, z.core.$loose>;
151
151
  export interface Register {
152
152
  }
@@ -164,8 +164,8 @@ export type ExtendedWorkspace = Register extends {
164
164
  } ? T : unknown;
165
165
  export type BaseLayoutFrame = Size & Pos & {
166
166
  id: FrameId;
167
- docked?: EdgeSide | false;
168
- collapsed?: false | number;
167
+ docked?: EdgeSide;
168
+ collapsed?: number;
169
169
  };
170
170
  export type LayoutFrame = ExtendedLayoutFrame & BaseLayoutFrame;
171
171
  export type LayoutFrames = Record<string, LayoutFrame>;
@@ -184,7 +184,7 @@ export declare const zLayoutWindow: z.ZodObject<{
184
184
  top: "top";
185
185
  bottom: "bottom";
186
186
  }>>;
187
- collapsed: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodNumber]>>;
187
+ collapsed: z.ZodOptional<z.ZodNumber>;
188
188
  }, z.core.$loose>>;
189
189
  pxWidth: z.ZodNumber;
190
190
  pxHeight: z.ZodNumber;
@@ -206,7 +206,7 @@ export declare const zLayoutWindowLoose: z.ZodObject<{
206
206
  top: "top";
207
207
  bottom: "bottom";
208
208
  }>>;
209
- collapsed: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodNumber]>>;
209
+ collapsed: z.ZodOptional<z.ZodNumber>;
210
210
  }, z.core.$loose>>;
211
211
  pxWidth: z.ZodNumber;
212
212
  pxHeight: z.ZodNumber;
@@ -238,7 +238,7 @@ export declare const zWorkspace: z.ZodObject<{
238
238
  top: "top";
239
239
  bottom: "bottom";
240
240
  }>>;
241
- collapsed: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodNumber]>>;
241
+ collapsed: z.ZodOptional<z.ZodNumber>;
242
242
  }, z.core.$loose>>;
243
243
  }, z.core.$strict>;
244
244
  export declare const zWorkspaceLoose: z.ZodObject<{
@@ -255,7 +255,7 @@ export declare const zWorkspaceLoose: z.ZodObject<{
255
255
  top: "top";
256
256
  bottom: "bottom";
257
257
  }>>;
258
- collapsed: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodNumber]>>;
258
+ collapsed: z.ZodOptional<z.ZodNumber>;
259
259
  }, z.core.$loose>>;
260
260
  }, z.core.$loose>;
261
261
  export type Workspace = Pick<LayoutWindow, "activeFrame" | "frames"> & ExtendedWorkspace;
@@ -276,7 +276,7 @@ export declare const zLayout: z.ZodObject<{
276
276
  top: "top";
277
277
  bottom: "bottom";
278
278
  }>>;
279
- collapsed: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodNumber]>>;
279
+ collapsed: z.ZodOptional<z.ZodNumber>;
280
280
  }, z.core.$loose>>;
281
281
  pxWidth: z.ZodNumber;
282
282
  pxHeight: z.ZodNumber;
@@ -301,7 +301,7 @@ export declare const zInitializedLayout: z.ZodObject<{
301
301
  top: "top";
302
302
  bottom: "bottom";
303
303
  }>>;
304
- collapsed: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodNumber]>>;
304
+ collapsed: z.ZodOptional<z.ZodNumber>;
305
305
  }, z.core.$loose>>;
306
306
  pxWidth: z.ZodNumber;
307
307
  pxHeight: z.ZodNumber;
@@ -681,7 +681,7 @@ export declare const zWindowCreate: z.ZodObject<{
681
681
  top: "top";
682
682
  bottom: "bottom";
683
683
  }>>;
684
- collapsed: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodNumber]>>;
684
+ collapsed: z.ZodOptional<z.ZodNumber>;
685
685
  }, z.core.$loose>>>;
686
686
  }, z.core.$loose>;
687
687
  export declare const zLayoutCreate: z.ZodObject<{
@@ -701,7 +701,7 @@ export declare const zLayoutCreate: z.ZodObject<{
701
701
  top: "top";
702
702
  bottom: "bottom";
703
703
  }>>;
704
- collapsed: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodNumber]>>;
704
+ collapsed: z.ZodOptional<z.ZodNumber>;
705
705
  }, z.core.$loose>>;
706
706
  pxWidth: z.ZodNumber;
707
707
  pxHeight: z.ZodNumber;
@@ -721,7 +721,7 @@ export declare const zFrameCreate: z.ZodObject<{
721
721
  top: "top";
722
722
  bottom: "bottom";
723
723
  }>>;
724
- collapsed: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodNumber]>>;
724
+ collapsed: z.ZodOptional<z.ZodNumber>;
725
725
  }, z.core.$loose>;
726
726
  export type LayoutShapeSquareProps = {
727
727
  css: BaseSquareCss;
@@ -44,7 +44,7 @@ export const zBaseSquare = zSize.extend(zPos.shape);
44
44
  export const zLayoutFrame = zBaseSquare.extend({
45
45
  id: z.uuid(),
46
46
  docked: zSide.optional(),
47
- collapsed: z.union([z.literal(false), z.number()]).optional()
47
+ collapsed: z.number().min(1).optional()
48
48
  }).loose();
49
49
  export const zLayoutFrameLoose = zLayoutFrame.loose();
50
50
  const baseLayoutWindow = z.object({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@witchcraft/layout",
3
3
  "description": "Headless layout manager.",
4
- "version": "0.2.0",
4
+ "version": "0.3.0",
5
5
  "main": "./dist/runtime/index.js",
6
6
  "type": "module",
7
7
  "sideEffects": false,
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "peerDependencies": {
36
36
  "@witchcraft/nuxt-utils": "^0.3.6",
37
- "@witchcraft/ui": "^0.4.4"
37
+ "@witchcraft/ui": "^0.5.0"
38
38
  },
39
39
  "peerDependenciesMeta": {
40
40
  "@witchcraft/ui": {
@@ -61,7 +61,7 @@
61
61
  "@vitejs/plugin-vue": "^6.0.7",
62
62
  "@vitest/coverage-v8": "^4.1.0",
63
63
  "@witchcraft/nuxt-utils": "^0.3.6",
64
- "@witchcraft/ui": "^0.4.4",
64
+ "@witchcraft/ui": "^0.5.0",
65
65
  "concurrently": "^9.2.1",
66
66
  "cross-env": "^10.1.0",
67
67
  "fast-glob": "^3.3.3",
@@ -79,12 +79,12 @@
79
79
  </FrameDragHandle>
80
80
  <div class="flex gap-1 px-2 py-1 flex-wrap">
81
81
  <button
82
- v-if="f.docked && f.collapsed === false"
82
+ v-if="f.docked && !f.collapsed"
83
83
  class="bg-neutral-200 dark:bg-neutral-700 px-2 py-0.5 text-xs rounded"
84
84
  @click="handleUndock(f.id)"
85
85
  >Undock</button>
86
86
  <button
87
- v-if="f.docked && f.collapsed === false"
87
+ v-if="f.docked && !f.collapsed"
88
88
  class="bg-neutral-200 dark:bg-neutral-700 px-2 py-0.5 text-xs rounded"
89
89
  @click="handleCollapse(f.id)"
90
90
  >Collapse</button>
@@ -174,4 +174,4 @@ export interface UseFramesContext {
174
174
  }
175
175
 
176
176
 
177
- export const dragContextInjectionKey = Symbol("dragContext") as InjectionKey<UseFramesContext>
177
+ export const dragContextInjectionKey = Symbol.for("@witchcraft/layout:dragContext") as InjectionKey<UseFramesContext>
@@ -68,7 +68,7 @@ export function getFrameDockInfo(
68
68
  const perpendicularLength = otherFrameIds.length > 0 ? Math.min(frame[perpendicular], effectiveMaxPerpendicular) : frame[perpendicular]
69
69
 
70
70
  frame.docked = side
71
- frame.collapsed = false
71
+ frame.collapsed = undefined
72
72
 
73
73
  const toExtract = [frame.id]
74
74
 
@@ -32,7 +32,7 @@ export function getFrameUncollapseInfo(
32
32
  const toExtract = [frame.id]
33
33
 
34
34
  const storedSize = frame.collapsed
35
- if (storedSize === false || storedSize === undefined) {
35
+ if (storedSize === undefined) {
36
36
  return new KnownError(
37
37
  LAYOUT_ERROR.CANT_UNCOLLAPSE_NOT_COLLAPSED,
38
38
  `Frame ${frameId} is not collapsed.`,
@@ -150,7 +150,7 @@ export function getFrameUncollapseInfo(
150
150
  pushIfNotIn(toExtract, framesToFix.map(_ => _.id))
151
151
 
152
152
  frame[sizeKey] = storedSize
153
- frame.collapsed = false
153
+ frame.collapsed = undefined
154
154
 
155
155
  if (frame.docked === "right" || frame.docked === "bottom") {
156
156
  frame[posKey] -= expandAmount
@@ -33,7 +33,7 @@ export function getFrameUndockInfo(
33
33
  if (frame.collapsed) {
34
34
  return new KnownError(LAYOUT_ERROR.CANT_UNDOCK_COLLAPSED_FRAME, `Can't undock collapsed frame ${frame.id}.`, { frame: frame.id })
35
35
  }
36
- const frameClone: LayoutFrame = { ...frame, docked: false, collapsed: false }
36
+ const frameClone: LayoutFrame = { ...frame, docked: undefined, collapsed: undefined }
37
37
  const otherDockedFramesToResize = []
38
38
  // if the frame is touching either corner, there could be other docked frames that will need to get expanded like here, * means docked, and B and D would need expanding if we undock A.
39
39
  /**
@@ -114,7 +114,7 @@ export type IntersectionEntry = {
114
114
  export const zLayoutFrame = zBaseSquare.extend({
115
115
  id: z.uuid(),
116
116
  docked: zSide.optional(),
117
- collapsed: z.union([z.literal(false), z.number()]).optional()
117
+ collapsed: z.number().min(1).optional()
118
118
  }).loose()
119
119
 
120
120
  export const zLayoutFrameLoose = zLayoutFrame.loose()
@@ -130,8 +130,8 @@ export type ExtendedWorkspace = Register extends { ExtendedWorkspace: infer T }
130
130
 
131
131
  export type BaseLayoutFrame = Size & Pos & {
132
132
  id: FrameId
133
- docked?: EdgeSide | false
134
- collapsed?: false | number
133
+ docked?: EdgeSide
134
+ collapsed?: number
135
135
  }
136
136
  export type LayoutFrame = ExtendedLayoutFrame & BaseLayoutFrame
137
137
  export type LayoutFrames = Record<string, LayoutFrame>