@dxos/ui-types 0.0.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/LICENSE +8 -0
- package/README.md +25 -0
- package/package.json +33 -0
- package/src/anchor.ts +20 -0
- package/src/density.ts +5 -0
- package/src/elevation.ts +6 -0
- package/src/index.ts +14 -0
- package/src/menu.ts +25 -0
- package/src/message.ts +5 -0
- package/src/palette.ts +27 -0
- package/src/size.ts +40 -0
- package/src/theme.ts +26 -0
- package/src/translations.ts +20 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
Copyright (c) 2022 DXOS
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
5
|
+
|
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# @dxos/ui-types
|
|
2
|
+
|
|
3
|
+
Types for DXOS UI and its themes.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm i @dxos/ui-types
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Documentation
|
|
12
|
+
|
|
13
|
+
- [📖 Developer Guide](https://docs.dxos.org/guide/react/aurora/)
|
|
14
|
+
|
|
15
|
+
## DXOS Resources
|
|
16
|
+
|
|
17
|
+
- [Website](https://dxos.org)
|
|
18
|
+
- [Developer Documentation](https://docs.dxos.org)
|
|
19
|
+
- Talk to us on [Discord](https://dxos.org/discord)
|
|
20
|
+
|
|
21
|
+
## Contributions
|
|
22
|
+
|
|
23
|
+
Your ideas, issues, and code are most welcome. Please take a look at our [community code of conduct](https://github.com/dxos/dxos/blob/main/CODE_OF_CONDUCT.md), the [issue guide](https://github.com/dxos/dxos/blob/main/CONTRIBUTING.md#submitting-issues), and the [PR contribution guide](https://github.com/dxos/dxos/blob/main/CONTRIBUTING.md#submitting-prs).
|
|
24
|
+
|
|
25
|
+
License: [MIT](./LICENSE) Copyright 2022 © DXOS
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dxos/ui-types",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Types for DXOS UI and theme.",
|
|
5
|
+
"homepage": "https://dxos.org",
|
|
6
|
+
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"author": "DXOS.org",
|
|
9
|
+
"sideEffects": false,
|
|
10
|
+
"type": "module",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"source": "./src/index.ts",
|
|
14
|
+
"types": "./dist/types/src/index.d.ts",
|
|
15
|
+
"browser": "./dist/lib/browser/index.mjs",
|
|
16
|
+
"node": "./dist/lib/node-esm/index.mjs"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"types": "dist/types/src/index.d.ts",
|
|
20
|
+
"typesVersions": {
|
|
21
|
+
"*": {}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"src"
|
|
26
|
+
],
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"i18next": "^21.10.0"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
}
|
|
33
|
+
}
|
package/src/anchor.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
export const DX_ANCHOR_ACTIVATE = 'dx-anchor-activate';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Global event to trigger a popover.
|
|
9
|
+
*/
|
|
10
|
+
export class DxAnchorActivate extends Event {
|
|
11
|
+
public readonly refId: string;
|
|
12
|
+
public readonly label: string;
|
|
13
|
+
public readonly trigger: HTMLElement;
|
|
14
|
+
constructor(props: { refId: string; label: string; trigger: HTMLElement }) {
|
|
15
|
+
super(DX_ANCHOR_ACTIVATE);
|
|
16
|
+
this.refId = props.refId;
|
|
17
|
+
this.label = props.label;
|
|
18
|
+
this.trigger = props.trigger;
|
|
19
|
+
}
|
|
20
|
+
}
|
package/src/density.ts
ADDED
package/src/elevation.ts
ADDED
package/src/index.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
export * from './anchor';
|
|
6
|
+
export * from './menu';
|
|
7
|
+
export * from './translations';
|
|
8
|
+
|
|
9
|
+
export type * from './density';
|
|
10
|
+
export type * from './elevation';
|
|
11
|
+
export type * from './message';
|
|
12
|
+
export type * from './palette';
|
|
13
|
+
export type * from './size';
|
|
14
|
+
export type * from './theme';
|
package/src/menu.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type ClassNameValue } from './theme';
|
|
6
|
+
import { type Label } from './translations';
|
|
7
|
+
|
|
8
|
+
export type MenuActionProperties = {
|
|
9
|
+
label: Label;
|
|
10
|
+
icon?: string;
|
|
11
|
+
value?: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
hidden?: boolean;
|
|
14
|
+
iconOnly?: boolean;
|
|
15
|
+
testId?: string;
|
|
16
|
+
variant?: 'action' | 'toggle';
|
|
17
|
+
checked?: boolean;
|
|
18
|
+
classNames?: ClassNameValue;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type MenuItemGroupProperties = {
|
|
22
|
+
label: Label;
|
|
23
|
+
icon?: string;
|
|
24
|
+
iconOnly?: boolean;
|
|
25
|
+
};
|
package/src/message.ts
ADDED
package/src/palette.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
export type ChromaticPalette =
|
|
6
|
+
| 'red'
|
|
7
|
+
| 'orange'
|
|
8
|
+
| 'amber'
|
|
9
|
+
| 'yellow'
|
|
10
|
+
| 'lime'
|
|
11
|
+
| 'green'
|
|
12
|
+
| 'emerald'
|
|
13
|
+
| 'teal'
|
|
14
|
+
| 'cyan'
|
|
15
|
+
| 'sky'
|
|
16
|
+
| 'blue'
|
|
17
|
+
| 'indigo'
|
|
18
|
+
| 'violet'
|
|
19
|
+
| 'purple'
|
|
20
|
+
| 'fuchsia'
|
|
21
|
+
| 'pink'
|
|
22
|
+
| 'rose';
|
|
23
|
+
|
|
24
|
+
export type PrimaryPalette = 'primary';
|
|
25
|
+
export type NeutralPalette = 'neutral';
|
|
26
|
+
|
|
27
|
+
export type Palette = ChromaticPalette | PrimaryPalette | NeutralPalette;
|
package/src/size.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
export type Size =
|
|
6
|
+
| 0
|
|
7
|
+
| 'px'
|
|
8
|
+
| 0.5
|
|
9
|
+
| 1
|
|
10
|
+
| 1.5
|
|
11
|
+
| 2
|
|
12
|
+
| 2.5
|
|
13
|
+
| 3
|
|
14
|
+
| 3.5
|
|
15
|
+
| 4
|
|
16
|
+
| 5
|
|
17
|
+
| 6
|
|
18
|
+
| 7
|
|
19
|
+
| 8
|
|
20
|
+
| 9
|
|
21
|
+
| 10
|
|
22
|
+
| 11
|
|
23
|
+
| 12
|
|
24
|
+
| 14
|
|
25
|
+
| 16
|
|
26
|
+
| 20
|
|
27
|
+
| 24
|
|
28
|
+
| 28
|
|
29
|
+
| 32
|
|
30
|
+
| 36
|
|
31
|
+
| 40
|
|
32
|
+
| 44
|
|
33
|
+
| 48
|
|
34
|
+
| 52
|
|
35
|
+
| 56
|
|
36
|
+
| 60
|
|
37
|
+
| 64
|
|
38
|
+
| 72
|
|
39
|
+
| 80
|
|
40
|
+
| 96;
|
package/src/theme.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
export type ClassNameValue = ClassNameArray | string | null | undefined | 0 | false;
|
|
6
|
+
export type ClassNameArray = ClassNameValue[];
|
|
7
|
+
|
|
8
|
+
export type ComponentFunction<P extends Record<string, any>> = (styleProps: P, ...etc: ClassNameArray) => string;
|
|
9
|
+
export type ComponentFragment<P extends Record<string, any>> = (styleProps: P) => ClassNameValue[];
|
|
10
|
+
|
|
11
|
+
export type Theme<P extends Record<string, any>> = { [key: string]: Theme<P> | ComponentFunction<P> };
|
|
12
|
+
export type ThemeMode = 'dark' | 'light';
|
|
13
|
+
export type ThemeFunction<P extends Record<string, any>> = (
|
|
14
|
+
path: string,
|
|
15
|
+
defaultClassName: string,
|
|
16
|
+
styleProps?: P,
|
|
17
|
+
...etc: ClassNameArray
|
|
18
|
+
) => string;
|
|
19
|
+
|
|
20
|
+
export type ThemedClassName<P = {}> = Omit<P, 'className'> & { classNames?: ClassNameValue };
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* For components that are children of Radix-style asChild primitives.
|
|
24
|
+
* className={mx('', className, classNames)}
|
|
25
|
+
*/
|
|
26
|
+
export type SlottableClassName<P = {}> = P & { className?: string; classNames?: ClassNameValue };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type TFunction } from 'i18next';
|
|
6
|
+
|
|
7
|
+
// TODO(thure): `Parameters<TFunction>` causes typechecking issues because `TFunction` has so many signatures.
|
|
8
|
+
export type Label = string | [string, { ns: string; count?: number; defaultValue?: string }];
|
|
9
|
+
|
|
10
|
+
export const isLabel = (o: any): o is Label =>
|
|
11
|
+
typeof o === 'string' ||
|
|
12
|
+
(Array.isArray(o) &&
|
|
13
|
+
o.length === 2 &&
|
|
14
|
+
typeof o[0] === 'string' &&
|
|
15
|
+
!!o[1] &&
|
|
16
|
+
typeof o[1] === 'object' &&
|
|
17
|
+
'ns' in o[1] &&
|
|
18
|
+
typeof o[1].ns === 'string');
|
|
19
|
+
|
|
20
|
+
export const toLocalizedString = (label: Label, t: TFunction) => (Array.isArray(label) ? t(...label) : label);
|