@reykjavik/webtools 0.2.5 → 0.2.7
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 +15 -0
- package/README.md +139 -16
- package/errorhandling.d.ts +11 -3
- package/errorhandling.js +2 -2
- package/esm/errorhandling.d.ts +11 -3
- package/esm/errorhandling.js +2 -2
- package/esm/fixIcelandicLocale.js +4 -0
- package/esm/http.d.ts +1 -0
- package/esm/http.js +1 -1
- package/esm/react-router/Wait.d.ts +2 -2
- package/esm/react-router/Wait.js +1 -1
- package/esm/vanillaExtract.d.ts +7 -0
- package/esm/vanillaExtract.js +16 -0
- package/fixIcelandicLocale.js +4 -0
- package/http.d.ts +1 -0
- package/http.js +1 -1
- package/package.json +1 -1
- package/react-router/Wait.d.ts +2 -2
- package/react-router/Wait.js +1 -1
- package/vanillaExtract.d.ts +7 -0
- package/vanillaExtract.js +18 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,21 @@
|
|
|
4
4
|
|
|
5
5
|
- ... <!-- Add new lines here. -->
|
|
6
6
|
|
|
7
|
+
## 0.2.7
|
|
8
|
+
|
|
9
|
+
_2025-09-01_
|
|
10
|
+
|
|
11
|
+
- `@reykjavik/webtools/fixIcelandicLocale`:
|
|
12
|
+
- fix: Check for support of each Intl class separately
|
|
13
|
+
- docs: Improve JSDocs and README for `asError()` and `ErrorFromPayload`
|
|
14
|
+
|
|
15
|
+
## 0.2.6
|
|
16
|
+
|
|
17
|
+
_2025-06-20_
|
|
18
|
+
|
|
19
|
+
- `@reykjavik/webtools/next/vanillaExtract`:
|
|
20
|
+
- feat: Add `vanillaVars` helper to generate privately scoped CSS variables
|
|
21
|
+
|
|
7
22
|
## 0.2.5
|
|
8
23
|
|
|
9
24
|
_2025-05-21_
|
package/README.md
CHANGED
|
@@ -51,6 +51,7 @@ bun add @reykjavik/webtools
|
|
|
51
51
|
- [`vanillaClass`](#vanillaclass)
|
|
52
52
|
- [`vanillaGlobal`](#vanillaglobal)
|
|
53
53
|
- [`vanillaProps`](#vanillaprops)
|
|
54
|
+
- [`vanillaVars`](#vanillavars)
|
|
54
55
|
- [Framework Specific Tools](#framework-specific-tools)
|
|
55
56
|
- [React-Router Tools](#react-router-tools)
|
|
56
57
|
- [Next.js Tools](#nextjs-tools)
|
|
@@ -385,7 +386,8 @@ Guarantees that a caught (`catch (e)`) value of `unknown` type, is indeed an
|
|
|
385
386
|
|
|
386
387
|
If the input is an `Error` instance, it is returned as-is. If the input is
|
|
387
388
|
something else it is wrapped in a new `ErrorFromPayload` instance, and the
|
|
388
|
-
original value is stored in as a `payload` property
|
|
389
|
+
original value is stored in as a `payload` property, and it's `.toString()` is
|
|
390
|
+
used for the `message` property.
|
|
389
391
|
|
|
390
392
|
```ts
|
|
391
393
|
import { asError, type ErrorFromPayload } from '@reykjavik/webtools/errorhandling';
|
|
@@ -394,21 +396,23 @@ const theError = new Error('Something went wrong');
|
|
|
394
396
|
try {
|
|
395
397
|
throw theError;
|
|
396
398
|
} catch (err) {
|
|
399
|
+
// theError is an instance of Error so it's returned as-is
|
|
397
400
|
const error = asError(theError);
|
|
398
401
|
console.error(error === theError); // true
|
|
399
|
-
console.error('
|
|
402
|
+
console.error('payload' in error); // false
|
|
400
403
|
}
|
|
401
404
|
|
|
402
|
-
const someObject = ['Something went wrong'];
|
|
405
|
+
const someObject = ['Oops', 'Something went wrong'];
|
|
403
406
|
try {
|
|
404
407
|
throw someObject;
|
|
405
408
|
} catch (err) {
|
|
409
|
+
// the thrown someObject is not an Error so an `ErrorFromPayload` is returned
|
|
406
410
|
const error = asError(someObject);
|
|
407
411
|
console.error(error === someObject); // false
|
|
408
|
-
console.error(error.message === someObject.join(',')); // false
|
|
409
412
|
console.error(error instanceOf ErrorFromPayload); // true
|
|
410
413
|
|
|
411
414
|
console.error(error.payload === someObject); // true
|
|
415
|
+
console.error(error.message === someObject.join(',')); // true
|
|
412
416
|
}
|
|
413
417
|
```
|
|
414
418
|
|
|
@@ -821,14 +825,26 @@ To opt out of the `&&` replacement, use the callback function signature.
|
|
|
821
825
|
// someFile.css.ts
|
|
822
826
|
import { vanillaClass } from '@reykjavik/webtools/vanillaExtract';
|
|
823
827
|
|
|
824
|
-
// Simple class selector block
|
|
828
|
+
// 1) Simple class selector block — no sub-selectors — auto-wrapped
|
|
829
|
+
// in a class-name selector block.
|
|
825
830
|
export const myClass = vanillaClass(`
|
|
826
831
|
background-color: #ccc;
|
|
827
832
|
padding: .5em 1em;
|
|
828
833
|
`);
|
|
834
|
+
// Generated CSS:
|
|
835
|
+
/*
|
|
836
|
+
.x1y2z3 {
|
|
837
|
+
background-color: #ccc;
|
|
838
|
+
padding: .5em 1em;
|
|
839
|
+
}
|
|
840
|
+
*/
|
|
841
|
+
|
|
842
|
+
// ---------------------------------------------------------------------------
|
|
829
843
|
|
|
830
|
-
//
|
|
831
|
-
|
|
844
|
+
// 2) More advanced usage with `&&` tokens that get replaced with the
|
|
845
|
+
// generated class-name selector (prefixed with a dot).
|
|
846
|
+
export const myClasWithAmp = vanillaClass(
|
|
847
|
+
`
|
|
832
848
|
&& {
|
|
833
849
|
background-color: #ccc;
|
|
834
850
|
padding: .5em 1em;
|
|
@@ -836,10 +852,38 @@ export const myClasWithAmp = vanillaClass(`
|
|
|
836
852
|
&& > strong {
|
|
837
853
|
color: #c00;
|
|
838
854
|
}
|
|
839
|
-
|
|
855
|
+
@media (min-width: 800px) {
|
|
856
|
+
&& {
|
|
857
|
+
background-color: #eee;
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
/* NOTE: Root-level CSS rules are NOT auto-wrapped when ` &&
|
|
861
|
+
` tokens are otherwise present */
|
|
862
|
+
color: blue;
|
|
863
|
+
`
|
|
864
|
+
);
|
|
865
|
+
// Generated CSS:
|
|
866
|
+
/*
|
|
867
|
+
.y2X1z3 {
|
|
868
|
+
background-color: #ccc;
|
|
869
|
+
padding: .5em 1em;
|
|
870
|
+
}
|
|
871
|
+
.y2X1z3 > strong {
|
|
872
|
+
color: #c00;
|
|
873
|
+
}
|
|
874
|
+
@media (min-width: 800px) {
|
|
875
|
+
.y2X1z3 {
|
|
876
|
+
background-color: #eee;
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
/* NOTE: Root-level CSS rules are NOT auto-wrapped when `&&` tokens are otherwise present */
|
|
880
|
+
color: blue;
|
|
881
|
+
*/
|
|
840
882
|
|
|
841
|
-
//
|
|
842
|
-
|
|
883
|
+
// ---------------------------------------------------------------------------
|
|
884
|
+
|
|
885
|
+
// 3) Advanced use: Pass a function to get the raw generated class-name,
|
|
886
|
+
// plus a more convenient dot-prefixed selector for the class-name.
|
|
843
887
|
export const myOtherClass = vanillaClass(
|
|
844
888
|
(classNameRaw, classNameSelector) => `
|
|
845
889
|
${classNameSelector} {
|
|
@@ -855,22 +899,48 @@ export const myOtherClass = vanillaClass(
|
|
|
855
899
|
}
|
|
856
900
|
}
|
|
857
901
|
/* NOTE: '&&' tokens returned from a callback function are NOT replaced */
|
|
858
|
-
&& {
|
|
902
|
+
&& { this-is-not: interpolated; }
|
|
859
903
|
`
|
|
860
904
|
);
|
|
905
|
+
// Generated CSS:
|
|
906
|
+
/*
|
|
907
|
+
.y3z1X2 {
|
|
908
|
+
background-color: #ccc;
|
|
909
|
+
padding: .5em 1em;
|
|
910
|
+
}
|
|
911
|
+
[class="y3z1X2"] > strong {
|
|
912
|
+
color: #c00;
|
|
913
|
+
}
|
|
914
|
+
@media (min-width: 800px) {
|
|
915
|
+
.y3z1X2 {
|
|
916
|
+
background-color: #eee;
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
/* NOTE: '&&' tokens returned from a callback function are NOT replaced */
|
|
920
|
+
&& { this-is-not: interpolated; }
|
|
921
|
+
*/
|
|
922
|
+
|
|
923
|
+
// ---------------------------------------------------------------------------
|
|
861
924
|
|
|
862
|
-
//
|
|
925
|
+
// 4) ...with a human readable debugId
|
|
863
926
|
export const humanReadableClass = vanillaClass(
|
|
864
|
-
'
|
|
927
|
+
'HumanReadable__classNamePrefix',
|
|
865
928
|
`
|
|
866
929
|
border: 1px dashed hotpink;
|
|
867
930
|
cursor: pointer;
|
|
868
931
|
`
|
|
869
932
|
);
|
|
933
|
+
// Generated CSS:
|
|
934
|
+
/*
|
|
935
|
+
.HumanReadable__classNamePrefix_x2y1z3 {
|
|
936
|
+
border: 1px dashed hotpink;
|
|
937
|
+
cursor: pointer;
|
|
938
|
+
}
|
|
939
|
+
*/
|
|
870
940
|
```
|
|
871
941
|
|
|
872
|
-
(NOTE: The dot-prefixed `&&` pattern
|
|
873
|
-
`&` token in modern nested CSS.)
|
|
942
|
+
(NOTE: The dot-prefixed `&&` pattern was chosen as to not conflict with the
|
|
943
|
+
bare `&` token in modern nested CSS.)
|
|
874
944
|
|
|
875
945
|
### `vanillaGlobal`
|
|
876
946
|
|
|
@@ -914,6 +984,59 @@ const myStyle = style({
|
|
|
914
984
|
});
|
|
915
985
|
```
|
|
916
986
|
|
|
987
|
+
### `vanillaVars`
|
|
988
|
+
|
|
989
|
+
**Syntax:**
|
|
990
|
+
`` vanillaVars(...varNames: Array<T>): Record <`var${Capitalize<T>}`, string> ``
|
|
991
|
+
|
|
992
|
+
Returns an object with privately scoped CSS variables props. Pass them around
|
|
993
|
+
and use them in your CSS.
|
|
994
|
+
|
|
995
|
+
```ts
|
|
996
|
+
// MyComponent.css.ts
|
|
997
|
+
import {
|
|
998
|
+
vanillaVars,
|
|
999
|
+
vanillaGlobal,
|
|
1000
|
+
} from '@reykjavik/webtools/vanillaExtract';
|
|
1001
|
+
|
|
1002
|
+
export const { varPrimaryColor, varSecondaryColor } = vanillaVars(
|
|
1003
|
+
'primaryColor',
|
|
1004
|
+
'secondaryColor'
|
|
1005
|
+
);
|
|
1006
|
+
|
|
1007
|
+
vanillaGlobal(`
|
|
1008
|
+
:root {
|
|
1009
|
+
${varPrimaryColor}: #ff0000;
|
|
1010
|
+
${varSecondaryColor}: #00ff00;
|
|
1011
|
+
}
|
|
1012
|
+
body {
|
|
1013
|
+
background-color: var(${varPrimaryColor});
|
|
1014
|
+
color: var(${varSecondaryColor});
|
|
1015
|
+
}
|
|
1016
|
+
`);
|
|
1017
|
+
```
|
|
1018
|
+
|
|
1019
|
+
…and then in your component:
|
|
1020
|
+
|
|
1021
|
+
```ts
|
|
1022
|
+
// MyComponent.tsx
|
|
1023
|
+
import React from 'react';
|
|
1024
|
+
import * as cl from './someFile.css.ts';
|
|
1025
|
+
|
|
1026
|
+
export function MyComponent() {
|
|
1027
|
+
return (
|
|
1028
|
+
<div
|
|
1029
|
+
style={{
|
|
1030
|
+
[cl.varPrimaryColor]: 'yellow',
|
|
1031
|
+
[cl.varSecondaryColor]: 'blue',
|
|
1032
|
+
}}
|
|
1033
|
+
>
|
|
1034
|
+
...children...
|
|
1035
|
+
</div>
|
|
1036
|
+
);
|
|
1037
|
+
}
|
|
1038
|
+
```
|
|
1039
|
+
|
|
917
1040
|
---
|
|
918
1041
|
|
|
919
1042
|
## Framework Specific Tools
|
|
@@ -921,7 +1044,7 @@ const myStyle = style({
|
|
|
921
1044
|
### React-Router Tools
|
|
922
1045
|
|
|
923
1046
|
See [README-rr.md](./README-rr.md) for helpers and components specifically
|
|
924
|
-
designed for use in
|
|
1047
|
+
designed for use in React-router projects.
|
|
925
1048
|
|
|
926
1049
|
(NOTE: If you're still using [Remix.run](https://remix.run) you can install
|
|
927
1050
|
version `"^0.1.22"` of this package.)
|
package/errorhandling.d.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Error subclass for thrown values that got
|
|
3
|
-
* Error, with the thrown value as the `payload` property.
|
|
2
|
+
* Error subclass for thrown NON-Error values that got turned into an actual
|
|
3
|
+
* Error, with the original thrown value as the `payload` property.
|
|
4
4
|
*
|
|
5
5
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#aserror
|
|
6
6
|
*/
|
|
7
7
|
export declare class ErrorFromPayload extends Error {
|
|
8
|
+
/**
|
|
9
|
+
* This payload property is only set if the original `throw` value was NOT
|
|
10
|
+
* `instanceof Error`.
|
|
11
|
+
*
|
|
12
|
+
* In such cases it contains the thrown value as is, and the `message`
|
|
13
|
+
* property of this `ErrorFromPayload` instance is set to the `.toString()`
|
|
14
|
+
* representation of the payload.
|
|
15
|
+
*/
|
|
8
16
|
payload?: unknown;
|
|
9
17
|
constructor(payload: unknown);
|
|
10
18
|
name: string;
|
|
@@ -50,7 +58,7 @@ export type ResultTupleObj<T, E extends Error = Error> = SuccessResult<T> | Fail
|
|
|
50
58
|
* `[error, results]` tuple with the `result` and `error` also attached as
|
|
51
59
|
* named properties.
|
|
52
60
|
*
|
|
53
|
-
* Works on both promises and
|
|
61
|
+
* Works on both promises and (synchronous) callback functions.
|
|
54
62
|
*
|
|
55
63
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resultcatch
|
|
56
64
|
*/
|
package/errorhandling.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Result = exports.asError = exports.ErrorFromPayload = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* Error subclass for thrown values that got
|
|
6
|
-
* Error, with the thrown value as the `payload` property.
|
|
5
|
+
* Error subclass for thrown NON-Error values that got turned into an actual
|
|
6
|
+
* Error, with the original thrown value as the `payload` property.
|
|
7
7
|
*
|
|
8
8
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#aserror
|
|
9
9
|
*/
|
package/esm/errorhandling.d.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Error subclass for thrown values that got
|
|
3
|
-
* Error, with the thrown value as the `payload` property.
|
|
2
|
+
* Error subclass for thrown NON-Error values that got turned into an actual
|
|
3
|
+
* Error, with the original thrown value as the `payload` property.
|
|
4
4
|
*
|
|
5
5
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#aserror
|
|
6
6
|
*/
|
|
7
7
|
export declare class ErrorFromPayload extends Error {
|
|
8
|
+
/**
|
|
9
|
+
* This payload property is only set if the original `throw` value was NOT
|
|
10
|
+
* `instanceof Error`.
|
|
11
|
+
*
|
|
12
|
+
* In such cases it contains the thrown value as is, and the `message`
|
|
13
|
+
* property of this `ErrorFromPayload` instance is set to the `.toString()`
|
|
14
|
+
* representation of the payload.
|
|
15
|
+
*/
|
|
8
16
|
payload?: unknown;
|
|
9
17
|
constructor(payload: unknown);
|
|
10
18
|
name: string;
|
|
@@ -50,7 +58,7 @@ export type ResultTupleObj<T, E extends Error = Error> = SuccessResult<T> | Fail
|
|
|
50
58
|
* `[error, results]` tuple with the `result` and `error` also attached as
|
|
51
59
|
* named properties.
|
|
52
60
|
*
|
|
53
|
-
* Works on both promises and
|
|
61
|
+
* Works on both promises and (synchronous) callback functions.
|
|
54
62
|
*
|
|
55
63
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resultcatch
|
|
56
64
|
*/
|
package/esm/errorhandling.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Error subclass for thrown values that got
|
|
3
|
-
* Error, with the thrown value as the `payload` property.
|
|
2
|
+
* Error subclass for thrown NON-Error values that got turned into an actual
|
|
3
|
+
* Error, with the original thrown value as the `payload` property.
|
|
4
4
|
*
|
|
5
5
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#aserror
|
|
6
6
|
*/
|
|
@@ -7,8 +7,12 @@ import { _PatchedCollator, _PatchedDateTimeFormat, _patchedDateToLocaleDateStrin
|
|
|
7
7
|
if (!Intl.Collator.supportedLocalesOf(['is']).length) {
|
|
8
8
|
Intl.Collator = _PatchedCollator;
|
|
9
9
|
String.prototype.localeCompare = _patchedStringLocaleCompare;
|
|
10
|
+
}
|
|
11
|
+
if (!Intl.NumberFormat.supportedLocalesOf(['is']).length) {
|
|
10
12
|
Intl.NumberFormat = _PatchedNumberFormat;
|
|
11
13
|
Number.prototype.toLocaleString = _patchedNumberToLocaleString;
|
|
14
|
+
}
|
|
15
|
+
if (!Intl.DateTimeFormat.supportedLocalesOf(['is']).length) {
|
|
12
16
|
Intl.DateTimeFormat = _PatchedDateTimeFormat;
|
|
13
17
|
Date.prototype.toLocaleString = _patchedDateToLocaleString;
|
|
14
18
|
Date.prototype.toLocaleDateString = _patchedDateToLocaleDateString;
|
package/esm/http.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare const HTTP_103_EarlyHints = 103;
|
|
|
11
11
|
export declare const HTTP_200_OK = 200;
|
|
12
12
|
/** The request succeeded, and a new resource was created as a result. This is typically the response sent after POST or PUT requests. */
|
|
13
13
|
export declare const HTTP_201_Created = 201;
|
|
14
|
+
/** The request has been received but not yet acted upon. Another process or server handles the request. */
|
|
14
15
|
export declare const HTTP_202_Accepted = 202;
|
|
15
16
|
/** The returned metadata is not necessarily complete. */
|
|
16
17
|
export declare const HTTP_203_NonAuthoritativeInformation = 203;
|
package/esm/http.js
CHANGED
|
@@ -12,7 +12,7 @@ export const HTTP_103_EarlyHints = 103;
|
|
|
12
12
|
export const HTTP_200_OK = 200;
|
|
13
13
|
/** The request succeeded, and a new resource was created as a result. This is typically the response sent after POST or PUT requests. */
|
|
14
14
|
export const HTTP_201_Created = 201;
|
|
15
|
-
|
|
15
|
+
/** The request has been received but not yet acted upon. Another process or server handles the request. */
|
|
16
16
|
export const HTTP_202_Accepted = 202;
|
|
17
17
|
/** The returned metadata is not necessarily complete. */
|
|
18
18
|
export const HTTP_203_NonAuthoritativeInformation = 203;
|
|
@@ -27,7 +27,7 @@ type WaitFallbacks = {
|
|
|
27
27
|
};
|
|
28
28
|
export type WaitProps<T> = WaitPropsBase<T> & WaitFallbacks;
|
|
29
29
|
/**
|
|
30
|
-
* A function component that wraps `@reykjavik/webtools/
|
|
30
|
+
* A function component that wraps `@reykjavik/webtools/react-router/Wait` to provide
|
|
31
31
|
* custom properties for `meanwhile` and `error` fallbacks, and/or other
|
|
32
32
|
* behaviors.
|
|
33
33
|
*
|
|
@@ -37,7 +37,7 @@ export type WaitComponent<CustomProps extends Record<string, unknown> = Record<n
|
|
|
37
37
|
displayName?: string;
|
|
38
38
|
};
|
|
39
39
|
/**
|
|
40
|
-
* A thin wrapper around [
|
|
40
|
+
* A thin wrapper around [React-router's `Await`](https://reactrouter.com/api/components/Await)
|
|
41
41
|
* component, to provide a more ergonomic API.
|
|
42
42
|
*
|
|
43
43
|
* If the awaited promise (`props.for`) resolves to an object with a truthy
|
package/esm/react-router/Wait.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { Suspense } from 'react';
|
|
2
2
|
import { Await } from 'react-router';
|
|
3
3
|
/**
|
|
4
|
-
* A thin wrapper around [
|
|
4
|
+
* A thin wrapper around [React-router's `Await`](https://reactrouter.com/api/components/Await)
|
|
5
5
|
* component, to provide a more ergonomic API.
|
|
6
6
|
*
|
|
7
7
|
* If the awaited promise (`props.for`) resolves to an object with a truthy
|
package/esm/vanillaExtract.d.ts
CHANGED
|
@@ -31,4 +31,11 @@ classNameSelector: string) => string;
|
|
|
31
31
|
*/
|
|
32
32
|
export declare function vanillaClass(css: string | ClassNameCallback): string;
|
|
33
33
|
export declare function vanillaClass(debugId: string, css: string | ClassNameCallback): string;
|
|
34
|
+
/**
|
|
35
|
+
* Returns an object with privately scoped CSS variables props.
|
|
36
|
+
* Pass them around and use them in your CSS.
|
|
37
|
+
*
|
|
38
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#vanillacvars
|
|
39
|
+
*/
|
|
40
|
+
export declare const vanillaVars: <T extends string>(...varNames: Array<T>) => Record<`var${Capitalize<T>}`, string>;
|
|
34
41
|
export {};
|
package/esm/vanillaExtract.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { capitalize } from '@reykjavik/hanna-utils';
|
|
1
2
|
import { globalStyle, style } from '@vanilla-extract/css';
|
|
2
3
|
/**
|
|
3
4
|
* Adds free-form CSS as a globalStyle
|
|
@@ -25,3 +26,18 @@ export function vanillaClass(cssOrDebugId, css) {
|
|
|
25
26
|
: css.replace(/&&/g, `.${className}`));
|
|
26
27
|
return className;
|
|
27
28
|
}
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
/**
|
|
31
|
+
* Returns an object with privately scoped CSS variables props.
|
|
32
|
+
* Pass them around and use them in your CSS.
|
|
33
|
+
*
|
|
34
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#vanillacvars
|
|
35
|
+
*/
|
|
36
|
+
export const vanillaVars = (...varNames) => {
|
|
37
|
+
const id = vanillaClass(``);
|
|
38
|
+
const vars = {};
|
|
39
|
+
for (const name of varNames) {
|
|
40
|
+
vars[`var${capitalize(name)}`] = `--${id}--${name}`;
|
|
41
|
+
}
|
|
42
|
+
return vars;
|
|
43
|
+
};
|
package/fixIcelandicLocale.js
CHANGED
|
@@ -9,8 +9,12 @@ const fixIcelandicLocale_privates_js_1 = require("./fixIcelandicLocale.privates.
|
|
|
9
9
|
if (!Intl.Collator.supportedLocalesOf(['is']).length) {
|
|
10
10
|
Intl.Collator = fixIcelandicLocale_privates_js_1._PatchedCollator;
|
|
11
11
|
String.prototype.localeCompare = fixIcelandicLocale_privates_js_1._patchedStringLocaleCompare;
|
|
12
|
+
}
|
|
13
|
+
if (!Intl.NumberFormat.supportedLocalesOf(['is']).length) {
|
|
12
14
|
Intl.NumberFormat = fixIcelandicLocale_privates_js_1._PatchedNumberFormat;
|
|
13
15
|
Number.prototype.toLocaleString = fixIcelandicLocale_privates_js_1._patchedNumberToLocaleString;
|
|
16
|
+
}
|
|
17
|
+
if (!Intl.DateTimeFormat.supportedLocalesOf(['is']).length) {
|
|
14
18
|
Intl.DateTimeFormat = fixIcelandicLocale_privates_js_1._PatchedDateTimeFormat;
|
|
15
19
|
Date.prototype.toLocaleString = fixIcelandicLocale_privates_js_1._patchedDateToLocaleString;
|
|
16
20
|
Date.prototype.toLocaleDateString = fixIcelandicLocale_privates_js_1._patchedDateToLocaleDateString;
|
package/http.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare const HTTP_103_EarlyHints = 103;
|
|
|
11
11
|
export declare const HTTP_200_OK = 200;
|
|
12
12
|
/** The request succeeded, and a new resource was created as a result. This is typically the response sent after POST or PUT requests. */
|
|
13
13
|
export declare const HTTP_201_Created = 201;
|
|
14
|
+
/** The request has been received but not yet acted upon. Another process or server handles the request. */
|
|
14
15
|
export declare const HTTP_202_Accepted = 202;
|
|
15
16
|
/** The returned metadata is not necessarily complete. */
|
|
16
17
|
export declare const HTTP_203_NonAuthoritativeInformation = 203;
|
package/http.js
CHANGED
|
@@ -16,7 +16,7 @@ exports.HTTP_103_EarlyHints = 103;
|
|
|
16
16
|
exports.HTTP_200_OK = 200;
|
|
17
17
|
/** The request succeeded, and a new resource was created as a result. This is typically the response sent after POST or PUT requests. */
|
|
18
18
|
exports.HTTP_201_Created = 201;
|
|
19
|
-
|
|
19
|
+
/** The request has been received but not yet acted upon. Another process or server handles the request. */
|
|
20
20
|
exports.HTTP_202_Accepted = 202;
|
|
21
21
|
/** The returned metadata is not necessarily complete. */
|
|
22
22
|
exports.HTTP_203_NonAuthoritativeInformation = 203;
|
package/package.json
CHANGED
package/react-router/Wait.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ type WaitFallbacks = {
|
|
|
27
27
|
};
|
|
28
28
|
export type WaitProps<T> = WaitPropsBase<T> & WaitFallbacks;
|
|
29
29
|
/**
|
|
30
|
-
* A function component that wraps `@reykjavik/webtools/
|
|
30
|
+
* A function component that wraps `@reykjavik/webtools/react-router/Wait` to provide
|
|
31
31
|
* custom properties for `meanwhile` and `error` fallbacks, and/or other
|
|
32
32
|
* behaviors.
|
|
33
33
|
*
|
|
@@ -37,7 +37,7 @@ export type WaitComponent<CustomProps extends Record<string, unknown> = Record<n
|
|
|
37
37
|
displayName?: string;
|
|
38
38
|
};
|
|
39
39
|
/**
|
|
40
|
-
* A thin wrapper around [
|
|
40
|
+
* A thin wrapper around [React-router's `Await`](https://reactrouter.com/api/components/Await)
|
|
41
41
|
* component, to provide a more ergonomic API.
|
|
42
42
|
*
|
|
43
43
|
* If the awaited promise (`props.for`) resolves to an object with a truthy
|
package/react-router/Wait.js
CHANGED
|
@@ -37,7 +37,7 @@ exports.Wait = void 0;
|
|
|
37
37
|
const react_1 = __importStar(require("react"));
|
|
38
38
|
const react_router_1 = require("react-router");
|
|
39
39
|
/**
|
|
40
|
-
* A thin wrapper around [
|
|
40
|
+
* A thin wrapper around [React-router's `Await`](https://reactrouter.com/api/components/Await)
|
|
41
41
|
* component, to provide a more ergonomic API.
|
|
42
42
|
*
|
|
43
43
|
* If the awaited promise (`props.for`) resolves to an object with a truthy
|
package/vanillaExtract.d.ts
CHANGED
|
@@ -31,4 +31,11 @@ classNameSelector: string) => string;
|
|
|
31
31
|
*/
|
|
32
32
|
export declare function vanillaClass(css: string | ClassNameCallback): string;
|
|
33
33
|
export declare function vanillaClass(debugId: string, css: string | ClassNameCallback): string;
|
|
34
|
+
/**
|
|
35
|
+
* Returns an object with privately scoped CSS variables props.
|
|
36
|
+
* Pass them around and use them in your CSS.
|
|
37
|
+
*
|
|
38
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#vanillacvars
|
|
39
|
+
*/
|
|
40
|
+
export declare const vanillaVars: <T extends string>(...varNames: Array<T>) => Record<`var${Capitalize<T>}`, string>;
|
|
34
41
|
export {};
|
package/vanillaExtract.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.vanillaProps = exports.vanillaGlobal = void 0;
|
|
3
|
+
exports.vanillaVars = exports.vanillaProps = exports.vanillaGlobal = void 0;
|
|
4
4
|
exports.vanillaClass = vanillaClass;
|
|
5
|
+
const hanna_utils_1 = require("@reykjavik/hanna-utils");
|
|
5
6
|
const css_1 = require("@vanilla-extract/css");
|
|
6
7
|
/**
|
|
7
8
|
* Adds free-form CSS as a globalStyle
|
|
@@ -31,3 +32,19 @@ function vanillaClass(cssOrDebugId, css) {
|
|
|
31
32
|
: css.replace(/&&/g, `.${className}`));
|
|
32
33
|
return className;
|
|
33
34
|
}
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
/**
|
|
37
|
+
* Returns an object with privately scoped CSS variables props.
|
|
38
|
+
* Pass them around and use them in your CSS.
|
|
39
|
+
*
|
|
40
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#vanillacvars
|
|
41
|
+
*/
|
|
42
|
+
const vanillaVars = (...varNames) => {
|
|
43
|
+
const id = vanillaClass(``);
|
|
44
|
+
const vars = {};
|
|
45
|
+
for (const name of varNames) {
|
|
46
|
+
vars[`var${(0, hanna_utils_1.capitalize)(name)}`] = `--${id}--${name}`;
|
|
47
|
+
}
|
|
48
|
+
return vars;
|
|
49
|
+
};
|
|
50
|
+
exports.vanillaVars = vanillaVars;
|