@odx/foundation 1.0.0-rc.0 → 1.0.0-rc.10
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/CHANGELOG.md +79 -0
- package/README.md +13 -1
- package/dist/lib/breakpoints.d.ts +46 -49
- package/dist/lib/breakpoints.js +139 -122
- package/dist/lib/format.d.ts +49 -50
- package/dist/lib/format.js +51 -50
- package/dist/lib/localization.d.ts +11 -11
- package/dist/lib/localization.js +13 -15
- package/dist/lib/models.d.ts +3 -39
- package/dist/lib/scroll-lock.d.ts +7 -0
- package/dist/lib/scroll-lock.js +27 -0
- package/dist/lib/signals.d.ts +13 -13
- package/dist/lib/signals.js +35 -32
- package/dist/lib/theming.d.ts +13 -15
- package/dist/lib/theming.js +21 -27
- package/dist/lib/utils/shared-media-observer.js +31 -35
- package/dist/main.d.ts +8 -7
- package/dist/main.js +7 -5
- package/dist/styles.css +1082 -1
- package/package.json +20 -21
- package/types/styles.d.ts +1 -0
- package/dist/lib/models.js +0 -34
- package/dist/lib/utils/breakpoint.d.ts +0 -38
- package/dist/lib/utils/breakpoint.js +0 -103
- package/dist/lib/utils/shared-media-observer.d.ts +0 -4
- package/dist/oss-licenses.json +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,82 @@
|
|
|
1
|
+
## 1.0.0-rc.10
|
|
2
|
+
|
|
3
|
+
### Patch Changes
|
|
4
|
+
|
|
5
|
+
- Fix types for styles entry point in `package.json` exports
|
|
6
|
+
|
|
7
|
+
## 1.0.0-rc.9
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Add `CHANGELOG.md` to package exports
|
|
12
|
+
- Fix exports field in `package.json` to resolve `type` imports first
|
|
13
|
+
|
|
14
|
+
## 1.0.0-rc.8
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
- Remove scroll lock gutter when scrollbar is not present to prevent unnecessary layout shift
|
|
19
|
+
|
|
20
|
+
## 1.0.0-rc.7
|
|
21
|
+
|
|
22
|
+
### Minor Changes
|
|
23
|
+
|
|
24
|
+
- Add `applyScrollLock` and `removeScrollLock` utilities to enable/disable scroll lock on the document
|
|
25
|
+
|
|
26
|
+
## 1.0.0-rc.6
|
|
27
|
+
|
|
28
|
+
### Minor Changes
|
|
29
|
+
|
|
30
|
+
- Rename CSS layers to remove dot notation:
|
|
31
|
+
- `odx.reset` to `odx-reset`
|
|
32
|
+
- `odx.base` to `odx-base`
|
|
33
|
+
- `odx.overrides` to `odx-overrides`
|
|
34
|
+
|
|
35
|
+
### Bug Fixes
|
|
36
|
+
|
|
37
|
+
- Remove debug info from rolldown build output
|
|
38
|
+
- Fix `.odx-cloak` if applied to `:root` element not working correctly
|
|
39
|
+
|
|
40
|
+
## 1.0.0-rc.5
|
|
41
|
+
|
|
42
|
+
### Major Changes
|
|
43
|
+
|
|
44
|
+
- Rename CSS utility classes `odx-text-primary|accent|...` to `odx-fg-*` to better reflect their purpose
|
|
45
|
+
|
|
46
|
+
### Minor Changes
|
|
47
|
+
|
|
48
|
+
- Add `.odx-cloak` class to prevent FOUC (Flash of Unstyled Content) during initial load, use `odx-cloak` class on the root element of your application to enable it
|
|
49
|
+
- Support `:visited` state for native links and anchors with `odx-link` class for better user experience
|
|
50
|
+
- Improve tabbable element detection
|
|
51
|
+
|
|
52
|
+
## 1.0.0-rc.4
|
|
53
|
+
|
|
54
|
+
### Bug Fixes
|
|
55
|
+
|
|
56
|
+
- Fix dark/light mode detection logic in `setTheme` function
|
|
57
|
+
|
|
58
|
+
## 1.0.0-rc.3
|
|
59
|
+
|
|
60
|
+
### Bug Fixes
|
|
61
|
+
|
|
62
|
+
- Add `package.json` package exports for better tooling support
|
|
63
|
+
|
|
64
|
+
## 1.0.0-rc.2
|
|
65
|
+
|
|
66
|
+
### Bug Fixes
|
|
67
|
+
|
|
68
|
+
- Fix default text alignment of title elements
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
## 1.0.0-rc.1
|
|
72
|
+
|
|
73
|
+
### Bug Fixes
|
|
74
|
+
|
|
75
|
+
- Fix `html.odx-root` selector not applying reset styles to `<body>` element
|
|
76
|
+
- Fix `toggleDarkMode` function never enabling light mode due to incorrect mode detection logic
|
|
77
|
+
- Fix `attachDarkModeToggle` icon not updating correctly when toggling dark mode
|
|
78
|
+
- Add side effects to `@odx/foundation` package to ensure theming and localization modules are included in the bundle when using tree shaking
|
|
79
|
+
|
|
1
80
|
## 1.0.0-rc.0
|
|
2
81
|
|
|
3
82
|
### Major Changes
|
package/README.md
CHANGED
|
@@ -86,6 +86,18 @@ setTheme({
|
|
|
86
86
|
});
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
+
### Page Cloak
|
|
90
|
+
|
|
91
|
+
To prevent unstyled content from flashing during the initial load of your application, you can use the `.odx-cloak` CSS class.
|
|
92
|
+
This class will temporarily hide the content of the `.odx-root` element until custom elements are fully loaded.
|
|
93
|
+
|
|
94
|
+
```html
|
|
95
|
+
<html class="odx-root odx-cloak">
|
|
96
|
+
</html>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
> The timeout can be set via the `--odx-cloak-timeout` custom property on the `:root` element, which defaults to `2s`.
|
|
100
|
+
|
|
89
101
|
### Documentation
|
|
90
102
|
|
|
91
|
-
For detailed documentation on how to use the `@odx/foundation` package,
|
|
103
|
+
For detailed documentation on how to use the `@odx/foundation` package, please visit our <a href="https://ca-odx-storybook-dev.yellowisland-7b13f2d7.westeurope.azurecontainerapps.io/" target="_blank" rel="noopener">storybook documentation</a>.
|
|
@@ -1,61 +1,58 @@
|
|
|
1
|
-
import { Signal } from
|
|
1
|
+
import { Signal } from "./signals.js";
|
|
2
2
|
declare global {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
3
|
+
namespace ODX.Breakpoints {
|
|
4
|
+
interface Config {
|
|
5
|
+
sm: true;
|
|
6
|
+
md: true;
|
|
7
|
+
lg: true;
|
|
8
|
+
xl: true;
|
|
9
|
+
xxl: true;
|
|
11
10
|
}
|
|
11
|
+
}
|
|
12
12
|
}
|
|
13
|
-
type FilteredKeys<T extends object> = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
max: number;
|
|
21
|
-
customQuery?: string;
|
|
13
|
+
type FilteredKeys<T extends object> = { [K in keyof T as T[K] extends true ? K : never]: T[K] };
|
|
14
|
+
type BreakpointOperator = '<' | '<=' | '>=' | '>';
|
|
15
|
+
interface BreakpointConfig {
|
|
16
|
+
name: keyof FilteredKeys<ODX.Breakpoints.Config>;
|
|
17
|
+
min: number;
|
|
18
|
+
max: number;
|
|
19
|
+
customQuery?: string;
|
|
22
20
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
interface Breakpoint extends BreakpointConfig {
|
|
22
|
+
id: BreakpointConfig['name'] | `${BreakpointOperator}${BreakpointConfig['name']}`;
|
|
23
|
+
query: string;
|
|
24
|
+
operator?: BreakpointOperator;
|
|
27
25
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
declare const registeredBreakpoints: ReadonlyMap<Breakpoint['id'], Breakpoint>;
|
|
27
|
+
declare const breakpointAttribute = "odx-breakpoint";
|
|
28
|
+
declare const defaultBreakpoints: [{
|
|
29
|
+
readonly name: "sm";
|
|
30
|
+
readonly min: 0;
|
|
31
|
+
readonly max: 479.98;
|
|
34
32
|
}, {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
readonly name: "md";
|
|
34
|
+
readonly min: 480;
|
|
35
|
+
readonly max: 768.98;
|
|
38
36
|
}, {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
readonly name: "lg";
|
|
38
|
+
readonly min: 769;
|
|
39
|
+
readonly max: 990.98;
|
|
42
40
|
}, {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
readonly name: "xl";
|
|
42
|
+
readonly min: 991;
|
|
43
|
+
readonly max: 1280.98;
|
|
46
44
|
}, {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
readonly name: "xxl";
|
|
46
|
+
readonly min: 1352;
|
|
47
|
+
readonly max: number;
|
|
50
48
|
}];
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
declare function buildBreakpoint(breakpoint: BreakpointConfig, operator?: BreakpointOperator): Breakpoint;
|
|
50
|
+
declare function expandBreakpoints(...breakpoints: BreakpointConfig[]): Breakpoint[];
|
|
51
|
+
declare function observeBreakpoint(id: Breakpoint['id'], initialValue?: boolean): Signal<Breakpoint & {
|
|
52
|
+
matches: boolean;
|
|
55
53
|
}>;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
declare function setupBreakpoints(breakpointsConfig?: BreakpointConfig[]): () => void;
|
|
55
|
+
declare function createBreakpointUpdater(breakpoints: Breakpoint[], update?: (target: HTMLElement, change: Breakpoint & {
|
|
56
|
+
matches: boolean;
|
|
59
57
|
}) => void): () => void;
|
|
60
|
-
export {};
|
|
61
|
-
//# sourceMappingURL=breakpoints.d.ts.map
|
|
58
|
+
export { Breakpoint, BreakpointConfig, BreakpointOperator, breakpointAttribute, buildBreakpoint, createBreakpointUpdater, defaultBreakpoints, expandBreakpoints, observeBreakpoint, registeredBreakpoints, setupBreakpoints };
|
package/dist/lib/breakpoints.js
CHANGED
|
@@ -1,139 +1,156 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { observeMedia } from
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { effect, signal } from "./signals.js";
|
|
2
|
+
import { observeMedia } from "./utils/shared-media-observer.js";
|
|
3
|
+
const operators = [
|
|
4
|
+
"<",
|
|
5
|
+
"<=",
|
|
6
|
+
">=",
|
|
7
|
+
">"
|
|
8
|
+
];
|
|
5
9
|
const registeredBreakpoints = /* @__PURE__ */ new Map();
|
|
6
10
|
const breakpointAttribute = "odx-breakpoint";
|
|
7
11
|
const defaultBreakpoints = [
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
{
|
|
13
|
+
name: "sm",
|
|
14
|
+
min: 0,
|
|
15
|
+
max: 479.98
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: "md",
|
|
19
|
+
min: 480,
|
|
20
|
+
max: 768.98
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: "lg",
|
|
24
|
+
min: 769,
|
|
25
|
+
max: 990.98
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: "xl",
|
|
29
|
+
min: 991,
|
|
30
|
+
max: 1280.98
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "xxl",
|
|
34
|
+
min: 1352,
|
|
35
|
+
max: Number.MAX_SAFE_INTEGER
|
|
36
|
+
}
|
|
13
37
|
];
|
|
14
38
|
function buildBreakpoint(breakpoint, operator) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
39
|
+
const id = operator ? `${operator}${breakpoint.name}` : breakpoint.name;
|
|
40
|
+
let query = `(min-width: ${breakpoint.min}px) and (max-width: ${breakpoint.max}px)`;
|
|
41
|
+
switch (operator) {
|
|
42
|
+
case "<":
|
|
43
|
+
query = `(max-width: ${breakpoint.min - .02}px)`;
|
|
44
|
+
break;
|
|
45
|
+
case "<=":
|
|
46
|
+
query = `(max-width: ${breakpoint.max}px)`;
|
|
47
|
+
break;
|
|
48
|
+
case ">=":
|
|
49
|
+
query = `(min-width: ${breakpoint.min}px)`;
|
|
50
|
+
break;
|
|
51
|
+
case ">":
|
|
52
|
+
query = `(min-width: ${breakpoint.max + .02}px)`;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
...breakpoint,
|
|
57
|
+
id,
|
|
58
|
+
operator,
|
|
59
|
+
query: [query, breakpoint.customQuery].filter(Boolean).join(" and ")
|
|
60
|
+
};
|
|
32
61
|
}
|
|
33
62
|
function expandBreakpoints(...breakpoints) {
|
|
34
|
-
|
|
63
|
+
return breakpoints.flatMap((breakpoint) => [void 0, ...operators].map((operator) => buildBreakpoint(breakpoint, operator)));
|
|
35
64
|
}
|
|
36
65
|
function observeBreakpoint(id, initialValue = false) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
66
|
+
const breakpoint = registeredBreakpoints.get(id);
|
|
67
|
+
let unobserveMedia;
|
|
68
|
+
const state = signal({
|
|
69
|
+
...breakpoint,
|
|
70
|
+
matches: initialValue
|
|
71
|
+
}, {
|
|
72
|
+
watched() {
|
|
73
|
+
if (!breakpoint) return;
|
|
74
|
+
unobserveMedia = observeMedia(breakpoint.query, ({ matches }) => {
|
|
75
|
+
state.set({
|
|
76
|
+
...breakpoint,
|
|
77
|
+
matches
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
unwatched() {
|
|
82
|
+
unobserveMedia?.();
|
|
83
|
+
unobserveMedia = void 0;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
return state;
|
|
55
87
|
}
|
|
56
88
|
function setupBreakpoints(breakpointsConfig = []) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
globalThis.addEventListener("DOMContentLoaded", initBreakpoints, { once: true });
|
|
80
|
-
} else {
|
|
81
|
-
initBreakpoints();
|
|
82
|
-
}
|
|
83
|
-
return destroyBreakpoints;
|
|
89
|
+
const directiveUpdater = createBreakpointUpdater(expandBreakpoints(...defaultBreakpoints, ...breakpointsConfig));
|
|
90
|
+
let mutationObserver;
|
|
91
|
+
let unobserveBreakpoints = () => {};
|
|
92
|
+
function initBreakpoints() {
|
|
93
|
+
destroyBreakpoints();
|
|
94
|
+
mutationObserver = new MutationObserver(directiveUpdater);
|
|
95
|
+
mutationObserver.observe(document.documentElement, {
|
|
96
|
+
attributes: true,
|
|
97
|
+
subtree: true,
|
|
98
|
+
childList: true,
|
|
99
|
+
attributeFilter: [breakpointAttribute]
|
|
100
|
+
});
|
|
101
|
+
unobserveBreakpoints = effect(directiveUpdater);
|
|
102
|
+
}
|
|
103
|
+
function destroyBreakpoints() {
|
|
104
|
+
unobserveBreakpoints();
|
|
105
|
+
mutationObserver?.disconnect();
|
|
106
|
+
globalThis.removeEventListener("DOMContentLoaded", initBreakpoints);
|
|
107
|
+
}
|
|
108
|
+
if (document.readyState === "loading") globalThis.addEventListener("DOMContentLoaded", initBreakpoints, { once: true });
|
|
109
|
+
else initBreakpoints();
|
|
110
|
+
return destroyBreakpoints;
|
|
84
111
|
}
|
|
85
112
|
function updateHostElement(host, active) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
host.slot = initialSlot;
|
|
108
|
-
} else {
|
|
109
|
-
host.slot = "_odx_breakpoint_hidden";
|
|
110
|
-
}
|
|
113
|
+
const attributeName = "data-odx-breakpoint-slot";
|
|
114
|
+
const classNames = host.getAttribute("odx-breakpoint-class");
|
|
115
|
+
if (classNames) {
|
|
116
|
+
for (const className of classNames.split(" ")) host.classList.toggle(className, active);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
host.hidden = !active;
|
|
120
|
+
let initialSlot = host.getAttribute(attributeName);
|
|
121
|
+
if (initialSlot == null) {
|
|
122
|
+
initialSlot = host.slot;
|
|
123
|
+
host.setAttribute(attributeName, initialSlot);
|
|
124
|
+
}
|
|
125
|
+
if (active) {
|
|
126
|
+
host.removeAttribute(attributeName);
|
|
127
|
+
if (initialSlot === "") {
|
|
128
|
+
host.removeAttribute("slot");
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
host.slot = "";
|
|
132
|
+
host.slot = initialSlot;
|
|
133
|
+
} else host.slot = "_odx_breakpoint_hidden";
|
|
111
134
|
}
|
|
112
135
|
function createBreakpointUpdater(breakpoints, update) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
breakpointCache.set(element, change.matches);
|
|
133
|
-
updateHostElement(element, change.matches);
|
|
134
|
-
update?.(element, change);
|
|
135
|
-
}
|
|
136
|
-
};
|
|
136
|
+
for (const breakpoint of breakpoints) registeredBreakpoints.set(breakpoint.id, breakpoint);
|
|
137
|
+
const breakpointCache = /* @__PURE__ */ new WeakMap();
|
|
138
|
+
const breakpointObservers = breakpoints.map((breakpoint) => observeBreakpoint(breakpoint.id, false));
|
|
139
|
+
return () => {
|
|
140
|
+
const elements = document.querySelectorAll(`[${breakpointAttribute}]`);
|
|
141
|
+
const changes = breakpointObservers.reduce((breakpoints, breakpoint) => {
|
|
142
|
+
breakpoints[breakpoint.get().id] = breakpoint.get();
|
|
143
|
+
return breakpoints;
|
|
144
|
+
}, {});
|
|
145
|
+
let i = elements.length;
|
|
146
|
+
while (i--) {
|
|
147
|
+
const element = elements[i];
|
|
148
|
+
const change = changes[element.getAttribute("odx-breakpoint") || ""];
|
|
149
|
+
if (!change || change.matches === breakpointCache.get(element)) continue;
|
|
150
|
+
breakpointCache.set(element, change.matches);
|
|
151
|
+
updateHostElement(element, change.matches);
|
|
152
|
+
update?.(element, change);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
137
155
|
}
|
|
138
|
-
|
|
139
156
|
export { breakpointAttribute, buildBreakpoint, createBreakpointUpdater, defaultBreakpoints, expandBreakpoints, observeBreakpoint, registeredBreakpoints, setupBreakpoints };
|
package/dist/lib/format.d.ts
CHANGED
|
@@ -1,58 +1,57 @@
|
|
|
1
|
-
import { UnitIdentifier } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { UnitIdentifier } from "./models.js";
|
|
2
|
+
interface FormatOptions {
|
|
3
|
+
dateTimeFormatOptions?: DateTimeFormatOptions;
|
|
4
|
+
numberFormatOptions?: NumberFormatOptions;
|
|
5
|
+
listFormatOptions?: ListFormatOptions;
|
|
6
|
+
relativeTimeFormatOptions?: RelativeTimeFormatOptions;
|
|
7
7
|
}
|
|
8
8
|
interface BaseFormatOptions {
|
|
9
|
-
|
|
9
|
+
locale?: Intl.Locale | Intl.UnicodeBCP47LocaleIdentifier;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
interface DateTimeFormatOptions extends Omit<Intl.DateTimeFormatOptions, 'dateStyle'>, BaseFormatOptions {
|
|
12
|
+
dateStyle?: 'iso8601' | Intl.DateTimeFormatOptions['dateStyle'];
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
declare function parseDate(value: number | string | Date): Date | null;
|
|
15
|
+
declare function formatDate(input: number | string | Date, options?: DateTimeFormatOptions): string;
|
|
16
|
+
interface NumberFormatOptions extends Intl.NumberFormatOptions, BaseFormatOptions {
|
|
17
|
+
unit?: UnitIdentifier;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export declare function formatList(input: string[], options?: ListFormatOptions): string;
|
|
19
|
+
declare function formatNumber(input: number | string, options?: NumberFormatOptions): string;
|
|
20
|
+
interface ListFormatOptions extends Intl.ListFormatOptions, BaseFormatOptions {}
|
|
21
|
+
declare function formatList(input: string[], options?: ListFormatOptions): string;
|
|
23
22
|
declare const TIME_UNIT_MAP: {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
23
|
+
readonly second: {
|
|
24
|
+
readonly max: 59000;
|
|
25
|
+
readonly value: 1000;
|
|
26
|
+
};
|
|
27
|
+
readonly minute: {
|
|
28
|
+
readonly max: 2760000;
|
|
29
|
+
readonly value: 60000;
|
|
30
|
+
};
|
|
31
|
+
readonly hour: {
|
|
32
|
+
readonly max: 72000000;
|
|
33
|
+
readonly value: 3600000;
|
|
34
|
+
};
|
|
35
|
+
readonly day: {
|
|
36
|
+
readonly max: 518400000;
|
|
37
|
+
readonly value: 86400000;
|
|
38
|
+
};
|
|
39
|
+
readonly week: {
|
|
40
|
+
readonly max: 2419200000;
|
|
41
|
+
readonly value: 604800000;
|
|
42
|
+
};
|
|
43
|
+
readonly month: {
|
|
44
|
+
readonly max: 28512000000;
|
|
45
|
+
readonly value: 2592000000;
|
|
46
|
+
};
|
|
47
|
+
readonly year: {
|
|
48
|
+
readonly max: number;
|
|
49
|
+
readonly value: 31536000000;
|
|
50
|
+
};
|
|
52
51
|
};
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
interface RelativeTimeFormatOptions extends Intl.RelativeTimeFormatOptions, BaseFormatOptions {
|
|
53
|
+
minUnit?: keyof typeof TIME_UNIT_MAP;
|
|
54
|
+
start?: number | string | Date;
|
|
55
55
|
}
|
|
56
|
-
|
|
57
|
-
export {};
|
|
58
|
-
//# sourceMappingURL=format.d.ts.map
|
|
56
|
+
declare function formatRelativeTime(input: number | string | Date, options?: RelativeTimeFormatOptions): string;
|
|
57
|
+
export { DateTimeFormatOptions, FormatOptions, ListFormatOptions, NumberFormatOptions, RelativeTimeFormatOptions, formatDate, formatList, formatNumber, formatRelativeTime, parseDate };
|