@tempots/ui 2.1.0 → 2.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/index.cjs +1 -1
- package/index.js +555 -524
- package/package.json +1 -1
- package/renderables/appearance.d.ts +3 -17
- package/renderables/router/browser-location.d.ts +9 -6
- package/renderables/router/headless-location.d.ts +5 -2
- package/renderables/router/location.d.ts +3 -16
- package/browser-location-Td-R3jYM.cjs +0 -1
- package/browser-location-Wn6jT0ta.js +0 -39
- package/headless-location-24MkNdBT.cjs +0 -1
- package/headless-location-CR5zPUNK.js +0 -21
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Signal,
|
|
1
|
+
import { Signal, Provider } from '@tempots/dom';
|
|
2
2
|
/**
|
|
3
3
|
* Defines the possible appearance types for the application.
|
|
4
4
|
*
|
|
@@ -6,12 +6,7 @@ import { Signal, TNode, Renderable } from '@tempots/dom';
|
|
|
6
6
|
*/
|
|
7
7
|
export type AppearanceType = 'light' | 'dark';
|
|
8
8
|
/**
|
|
9
|
-
* A provider
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
export declare const appearanceMarker: import('@tempots/dom').ProviderMark<Signal<AppearanceType>>;
|
|
13
|
-
/**
|
|
14
|
-
* Provides a child component with an appearance context, which can be used to
|
|
9
|
+
* A provider that provides a child component with an appearance context, which can be used to
|
|
15
10
|
* determine the current appearance (light or dark) based on the user's system
|
|
16
11
|
* preferences.
|
|
17
12
|
*
|
|
@@ -22,13 +17,4 @@ export declare const appearanceMarker: import('@tempots/dom').ProviderMark<Signa
|
|
|
22
17
|
* @returns The child component with the appearance context.
|
|
23
18
|
* @public
|
|
24
19
|
*/
|
|
25
|
-
export declare const
|
|
26
|
-
/**
|
|
27
|
-
* Makes the AppearanceType available to the child component by consuming the signal provided by the parent.
|
|
28
|
-
* The result of the function is returned as the final output.
|
|
29
|
-
*
|
|
30
|
-
* @param fn - A function that accepts the `AppearanceType` signal and returns a `TNode` element.
|
|
31
|
-
* @returns The `TNode` element returned by the provided function.
|
|
32
|
-
* @public
|
|
33
|
-
*/
|
|
34
|
-
export declare const UseAppearance: (fn: (appearance: Signal<AppearanceType>) => TNode) => TNode;
|
|
20
|
+
export declare const Appearance: Provider<Signal<AppearanceType>>;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { TNode, Prop } from '@tempots/dom';
|
|
2
1
|
import { LocationData } from './location-data';
|
|
3
2
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @
|
|
3
|
+
* Creates a location prop that represents the current browser location.
|
|
4
|
+
* The location prop is updated whenever the browser location changes.
|
|
5
|
+
*
|
|
6
|
+
* @returns The location prop.
|
|
7
|
+
* @internal
|
|
8
8
|
*/
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const makeBrowserLocationProp: () => {
|
|
10
|
+
value: import('@tempots/dom').Prop<LocationData>;
|
|
11
|
+
dispose: () => void;
|
|
12
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HeadlessContext } from '@tempots/dom';
|
|
2
2
|
import { LocationData } from './location-data';
|
|
3
3
|
export declare const isAbsoluteURL: (url: string) => boolean;
|
|
4
4
|
/**
|
|
@@ -7,4 +7,7 @@ export declare const isAbsoluteURL: (url: string) => boolean;
|
|
|
7
7
|
* @returns The wrapped component with the location context.
|
|
8
8
|
* @public
|
|
9
9
|
*/
|
|
10
|
-
export declare const
|
|
10
|
+
export declare const makeHeadlessLocationProp: (ctx: HeadlessContext) => {
|
|
11
|
+
value: import('@tempots/dom').Prop<LocationData>;
|
|
12
|
+
dispose: () => void;
|
|
13
|
+
};
|
|
@@ -1,22 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Prop, Provider } from '@tempots/dom';
|
|
2
2
|
import { LocationData } from './location-data';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
export declare const LocationProviderMarker: import('@tempots/dom').ProviderMark<Prop<LocationData>>;
|
|
9
|
-
/**
|
|
10
|
-
* Provides the location context to the child component.
|
|
4
|
+
* Provider for the location context.
|
|
11
5
|
* @param child - The child component to be wrapped with the location context.
|
|
12
6
|
* @returns The wrapped component with the location context.
|
|
13
7
|
* @public
|
|
14
8
|
*/
|
|
15
|
-
export declare const
|
|
16
|
-
/**
|
|
17
|
-
* A hook that provides the current location data to the given function.
|
|
18
|
-
* @param fn - The function that receives the location data.
|
|
19
|
-
* @returns A function that can be used to clean up the resources when the location changes.
|
|
20
|
-
* @public
|
|
21
|
-
*/
|
|
22
|
-
export declare const UseLocation: (fn: (location: Prop<LocationData>) => TNode) => import('@tempots/dom').Renderable;
|
|
9
|
+
export declare const Location: Provider<Prop<LocationData>>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@tempots/dom"),r=require("./index.cjs"),c=()=>{const o=a.getWindow(),e=(o==null?void 0:o.location.hash)===""?void 0:(o==null?void 0:o.location.hash.substring(1))??void 0;return{pathname:(o==null?void 0:o.location.pathname)??"",search:Object.fromEntries(new URLSearchParams((o==null?void 0:o.location.search)??"").entries()),hash:e}},i=()=>{const o=a.prop(c(),r.areLocationsEqual),e=a.getWindow(),s=()=>{let t=(e==null?void 0:e.location.hash)??"";t.startsWith("#")&&(t=t.substring(1));const n={pathname:(e==null?void 0:e.location.pathname)??"",search:Object.fromEntries(new URLSearchParams((e==null?void 0:e.location.search)??"").entries()),hash:t===""?void 0:t};o.set(n)};return e==null||e.addEventListener("popstate",s),o.onDispose(()=>{e==null||e.removeEventListener("popstate",s)}),o.on(t=>{e==null||e.history.pushState({},"",r.urlFromLocation(t))}),o},h=o=>{const e=i();return a.Fragment(a.OnDispose(e.dispose),a.SetProvider(r.LocationProviderMarker,e,o))};exports.ProvideBrowserLocation=h;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Fragment as n, OnDispose as c, SetProvider as h, prop as i, getWindow as r } from "@tempots/dom";
|
|
2
|
-
import { LocationProviderMarker as p, areLocationsEqual as m, urlFromLocation as d } from "./index.js";
|
|
3
|
-
const l = () => {
|
|
4
|
-
const t = r(), o = (t == null ? void 0 : t.location.hash) === "" ? void 0 : (t == null ? void 0 : t.location.hash.substring(1)) ?? void 0;
|
|
5
|
-
return {
|
|
6
|
-
pathname: (t == null ? void 0 : t.location.pathname) ?? "",
|
|
7
|
-
search: Object.fromEntries(
|
|
8
|
-
new URLSearchParams((t == null ? void 0 : t.location.search) ?? "").entries()
|
|
9
|
-
),
|
|
10
|
-
hash: o
|
|
11
|
-
};
|
|
12
|
-
}, u = () => {
|
|
13
|
-
const t = i(l(), m), o = r(), a = () => {
|
|
14
|
-
let e = (o == null ? void 0 : o.location.hash) ?? "";
|
|
15
|
-
e.startsWith("#") && (e = e.substring(1));
|
|
16
|
-
const s = {
|
|
17
|
-
pathname: (o == null ? void 0 : o.location.pathname) ?? "",
|
|
18
|
-
search: Object.fromEntries(
|
|
19
|
-
new URLSearchParams((o == null ? void 0 : o.location.search) ?? "").entries()
|
|
20
|
-
),
|
|
21
|
-
hash: e === "" ? void 0 : e
|
|
22
|
-
};
|
|
23
|
-
t.set(s);
|
|
24
|
-
};
|
|
25
|
-
return o == null || o.addEventListener("popstate", a), t.onDispose(() => {
|
|
26
|
-
o == null || o.removeEventListener("popstate", a);
|
|
27
|
-
}), t.on((e) => {
|
|
28
|
-
o == null || o.history.pushState({}, "", d(e));
|
|
29
|
-
}), t;
|
|
30
|
-
}, v = (t) => {
|
|
31
|
-
const o = u();
|
|
32
|
-
return n(
|
|
33
|
-
c(o.dispose),
|
|
34
|
-
h(p, o, t)
|
|
35
|
-
);
|
|
36
|
-
};
|
|
37
|
-
export {
|
|
38
|
-
v as ProvideBrowserLocation
|
|
39
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@tempots/dom"),e=require("./index.cjs"),i=t=>t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//"),u=(t,a)=>{const n=t.iso(o=>e.locationFromURL(o),o=>{if(i(o.pathname))return e.urlFromLocation(o);const s=new URL(o.pathname,t.value),c=s.origin+s.pathname;return e.urlFromLocation({...o,pathname:c})});return r.Fragment(r.OnDispose(n.dispose),r.SetProvider(e.LocationProviderMarker,n,a))};exports.ProvideHeadlessLocation=u;exports.isAbsoluteURL=i;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Fragment as a, OnDispose as m, SetProvider as p } from "@tempots/dom";
|
|
2
|
-
import { locationFromURL as c, urlFromLocation as e, LocationProviderMarker as h } from "./index.js";
|
|
3
|
-
const L = (t) => t.startsWith("http://") || t.startsWith("https://") || t.startsWith("//"), v = (t, s) => {
|
|
4
|
-
const r = t.iso(
|
|
5
|
-
(o) => c(o),
|
|
6
|
-
(o) => {
|
|
7
|
-
if (L(o.pathname))
|
|
8
|
-
return e(o);
|
|
9
|
-
const n = new URL(o.pathname, t.value), i = n.origin + n.pathname;
|
|
10
|
-
return e({ ...o, pathname: i });
|
|
11
|
-
}
|
|
12
|
-
);
|
|
13
|
-
return a(
|
|
14
|
-
m(r.dispose),
|
|
15
|
-
p(h, r, s)
|
|
16
|
-
);
|
|
17
|
-
};
|
|
18
|
-
export {
|
|
19
|
-
v as ProvideHeadlessLocation,
|
|
20
|
-
L as isAbsoluteURL
|
|
21
|
-
};
|