solid-ctrl-flow 7.0.1 → 7.0.2

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/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Accessor } from 'solid-js';
2
+ import { ComponentProps } from 'solid-js';
2
3
  import { Context } from 'solid-js';
3
4
  import { JSX } from 'solid-js';
4
5
  import { MemoOptions } from 'solid-js';
@@ -20,6 +21,9 @@ export declare function Case(props: ParentProps<{
20
21
  */
21
22
  export declare function disposeWithOwner<T>(outer: Owner, f: Accessor<T>): T;
22
23
 
24
+ /** Handy type alias */
25
+ declare type div = ComponentProps<"div">;
26
+
23
27
  /**
24
28
  * Eventually wraps its content into a template if a certain condition is met.
25
29
  * If you set {@link Standard.recycled} to `true`, the content will be memoized in the beginning and will be recycled even if the wrapper changes.
@@ -169,6 +173,15 @@ export declare namespace OrderedLinkedList {
169
173
  }
170
174
  }
171
175
 
176
+ /**
177
+ * Simple {@link HTMLDivElement} that accepts another set of attributes to merge with the base ones.
178
+ * Specifically, {@link div.ref}, {@link div.class}, {@link div.classList}, and {@link div.style} are combined rather than overwritten by the second set of attributes.
179
+ * Used for customizable structural parts of components
180
+ */
181
+ export declare function Part(props: {
182
+ props: div | undefined;
183
+ } & div): JSX;
184
+
172
185
  /**
173
186
  * Executes {@link f} with the provided value for the specified {@link Context}.
174
187
  * You can pass `undefined` to {@link value} in order to get back the default value for {@link ctx}.
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { untrack, getOwner, createRoot, runWithOwner, onCleanup, createMemo, Show, createContext, useContext, For, createRenderEffect, on, splitProps, createSignal, batch, createSelector, equalFn, Match } from "solid-js";
2
- import { createComponent, memo, mergeProps, spread } from "solid-js/web";
1
+ import { untrack, getOwner, createRoot, runWithOwner, onCleanup, createMemo, Show, createContext, useContext, For, createRenderEffect, on, splitProps, createSignal, batch, mergeProps as mergeProps$1, createSelector, equalFn, Match } from "solid-js";
2
+ import { createComponent, memo, mergeProps, use, spread, template } from "solid-js/web";
3
3
  function untrackCall(f, ...args) {
4
4
  return untrack(() => f.apply(this, args));
5
5
  }
@@ -226,30 +226,6 @@ function SameContextSource(props) {
226
226
  }
227
227
  }));
228
228
  }
229
- const ctx = createContext(void 0, {
230
- name: "on-case"
231
- });
232
- function On(props) {
233
- const memo2 = memoProps(props);
234
- const selector = createSelector(() => memo2.value, (a, b) => (memo2.onCompare ?? equalFn)(a, b));
235
- return createComponent(ctx.Provider, {
236
- value: selector,
237
- get children() {
238
- return props.children;
239
- }
240
- });
241
- }
242
- function Case(props) {
243
- const selector = useContext(ctx);
244
- return createComponent(Match, {
245
- get when() {
246
- return selector(props.value);
247
- },
248
- get children() {
249
- return props.children;
250
- }
251
- });
252
- }
253
229
  const memoProps = (obj, equals) => new Proxy(obj, new MemoPropsHandler(getOwner(), equals));
254
230
  const splitAndMemoProps = (obj, ...keys) => splitAndMemoSomeProps(obj, keys.length, ...keys);
255
231
  function splitAndMemoSomeProps(obj, n, ...keys) {
@@ -285,6 +261,64 @@ class MemoPropsHandler {
285
261
  return runWithOwner(this.owner, () => createMemo(() => t[k], void 0, opts));
286
262
  }
287
263
  }
264
+ var _tmpl$ = /* @__PURE__ */ template(`<div>`);
265
+ function Part(props) {
266
+ const [mine, first, second, other, user] = processProps(props);
267
+ return (() => {
268
+ var _el$ = _tmpl$();
269
+ use((x) => createComponent(Spread, {
270
+ target: x,
271
+ ref(r$) {
272
+ var _ref$ = mine.ref;
273
+ typeof _ref$ === "function" ? _ref$(r$) : mine.ref = r$;
274
+ },
275
+ get style() {
276
+ return mine.style;
277
+ }
278
+ }), _el$);
279
+ spread(_el$, mergeProps(other, user, {
280
+ get classList() {
281
+ return {
282
+ [first.class ?? ""]: true,
283
+ [second.class ?? ""]: true,
284
+ // A key containing only spaces breaks, so the optional classes are kept as separate properties
285
+ ...first.classList,
286
+ ...second.classList
287
+ };
288
+ }
289
+ }), false, false);
290
+ return _el$;
291
+ })();
292
+ }
293
+ function processProps(props) {
294
+ const [mine, temp, other] = splitProps(props, ["ref", "style", "props"], ["class", "classList"]), first = memoProps(temp);
295
+ const [second, user] = splitAndMemoProps(mergeProps$1(() => mine.props), ["class", "classList"]);
296
+ return [mine, first, second, other, user];
297
+ }
298
+ const ctx = createContext(void 0, {
299
+ name: "on-case"
300
+ });
301
+ function On(props) {
302
+ const memo2 = memoProps(props);
303
+ const selector = createSelector(() => memo2.value, (a, b) => (memo2.onCompare ?? equalFn)(a, b));
304
+ return createComponent(ctx.Provider, {
305
+ value: selector,
306
+ get children() {
307
+ return props.children;
308
+ }
309
+ });
310
+ }
311
+ function Case(props) {
312
+ const selector = useContext(ctx);
313
+ return createComponent(Match, {
314
+ get when() {
315
+ return selector(props.value);
316
+ },
317
+ get children() {
318
+ return props.children;
319
+ }
320
+ });
321
+ }
288
322
  class TransitionMonitor {
289
323
  #signal = createSignal(false);
290
324
  /** Whether a transition is currently in progress */
@@ -328,6 +362,7 @@ export {
328
362
  Extractor,
329
363
  On,
330
364
  OrderedLinkedList,
365
+ Part,
331
366
  SameContext,
332
367
  Spread,
333
368
  TransitionMonitor,
package/dist/index.umd.js CHANGED
@@ -228,30 +228,6 @@
228
228
  }
229
229
  }));
230
230
  }
231
- const ctx = solidJs.createContext(void 0, {
232
- name: "on-case"
233
- });
234
- function On(props) {
235
- const memo = memoProps(props);
236
- const selector = solidJs.createSelector(() => memo.value, (a, b) => (memo.onCompare ?? solidJs.equalFn)(a, b));
237
- return web.createComponent(ctx.Provider, {
238
- value: selector,
239
- get children() {
240
- return props.children;
241
- }
242
- });
243
- }
244
- function Case(props) {
245
- const selector = solidJs.useContext(ctx);
246
- return web.createComponent(solidJs.Match, {
247
- get when() {
248
- return selector(props.value);
249
- },
250
- get children() {
251
- return props.children;
252
- }
253
- });
254
- }
255
231
  const memoProps = (obj, equals) => new Proxy(obj, new MemoPropsHandler(solidJs.getOwner(), equals));
256
232
  const splitAndMemoProps = (obj, ...keys) => splitAndMemoSomeProps(obj, keys.length, ...keys);
257
233
  function splitAndMemoSomeProps(obj, n, ...keys) {
@@ -287,6 +263,64 @@
287
263
  return solidJs.runWithOwner(this.owner, () => solidJs.createMemo(() => t[k], void 0, opts));
288
264
  }
289
265
  }
266
+ var _tmpl$ = /* @__PURE__ */ web.template(`<div>`);
267
+ function Part(props) {
268
+ const [mine, first, second, other, user] = processProps(props);
269
+ return (() => {
270
+ var _el$ = _tmpl$();
271
+ web.use((x) => web.createComponent(Spread, {
272
+ target: x,
273
+ ref(r$) {
274
+ var _ref$ = mine.ref;
275
+ typeof _ref$ === "function" ? _ref$(r$) : mine.ref = r$;
276
+ },
277
+ get style() {
278
+ return mine.style;
279
+ }
280
+ }), _el$);
281
+ web.spread(_el$, web.mergeProps(other, user, {
282
+ get classList() {
283
+ return {
284
+ [first.class ?? ""]: true,
285
+ [second.class ?? ""]: true,
286
+ // A key containing only spaces breaks, so the optional classes are kept as separate properties
287
+ ...first.classList,
288
+ ...second.classList
289
+ };
290
+ }
291
+ }), false, false);
292
+ return _el$;
293
+ })();
294
+ }
295
+ function processProps(props) {
296
+ const [mine, temp, other] = solidJs.splitProps(props, ["ref", "style", "props"], ["class", "classList"]), first = memoProps(temp);
297
+ const [second, user] = splitAndMemoProps(solidJs.mergeProps(() => mine.props), ["class", "classList"]);
298
+ return [mine, first, second, other, user];
299
+ }
300
+ const ctx = solidJs.createContext(void 0, {
301
+ name: "on-case"
302
+ });
303
+ function On(props) {
304
+ const memo = memoProps(props);
305
+ const selector = solidJs.createSelector(() => memo.value, (a, b) => (memo.onCompare ?? solidJs.equalFn)(a, b));
306
+ return web.createComponent(ctx.Provider, {
307
+ value: selector,
308
+ get children() {
309
+ return props.children;
310
+ }
311
+ });
312
+ }
313
+ function Case(props) {
314
+ const selector = solidJs.useContext(ctx);
315
+ return web.createComponent(solidJs.Match, {
316
+ get when() {
317
+ return selector(props.value);
318
+ },
319
+ get children() {
320
+ return props.children;
321
+ }
322
+ });
323
+ }
290
324
  class TransitionMonitor {
291
325
  #signal = solidJs.createSignal(false);
292
326
  /** Whether a transition is currently in progress */
@@ -329,6 +363,7 @@
329
363
  exports2.Extractor = Extractor;
330
364
  exports2.On = On;
331
365
  exports2.OrderedLinkedList = OrderedLinkedList;
366
+ exports2.Part = Part;
332
367
  exports2.SameContext = SameContext;
333
368
  exports2.Spread = Spread;
334
369
  exports2.TransitionMonitor = TransitionMonitor;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solid-ctrl-flow",
3
- "version": "7.0.1",
3
+ "version": "7.0.2",
4
4
  "description": "Control flow components for solid-js",
5
5
  "author": "AFatNiBBa",
6
6
  "license": "ISC",