@fibrae/semi-foundation 0.3.0 → 0.3.1
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
CHANGED
|
@@ -20,65 +20,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
20
20
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
21
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
SOFTWARE.
|
|
23
|
-
|
|
24
|
-
The code implementation of the external library is referenced by DouyinFe are:
|
|
25
|
-
|
|
26
|
-
- animate.css
|
|
27
|
-
|
|
28
|
-
The MIT License (MIT)
|
|
29
|
-
|
|
30
|
-
Copyright (c) 2020 Daniel Eden
|
|
31
|
-
|
|
32
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
33
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
34
|
-
in the Software without restriction, including without limitation the rights
|
|
35
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
36
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
37
|
-
furnished to do so, subject to the following conditions:
|
|
38
|
-
|
|
39
|
-
The above copyright notice and this permission notice shall be included in all
|
|
40
|
-
copies or substantial portions of the Software.
|
|
41
|
-
|
|
42
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
43
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
44
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
45
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
46
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
47
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
48
|
-
SOFTWARE.
|
|
49
|
-
|
|
50
|
-
- Ant Design
|
|
51
|
-
MIT LICENSE
|
|
52
|
-
|
|
53
|
-
Copyright (c) 2015-present Ant UED, https://xtech.antfin.com/
|
|
54
|
-
|
|
55
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
56
|
-
a copy of this software and associated documentation files (the
|
|
57
|
-
"Software"), to deal in the Software without restriction, including
|
|
58
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
59
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
60
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
61
|
-
the following conditions:
|
|
62
|
-
|
|
63
|
-
The above copyright notice and this permission notice shall be
|
|
64
|
-
included in all copies or substantial portions of the Software.
|
|
65
|
-
|
|
66
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
67
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
68
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
69
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
70
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
71
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
72
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
73
|
-
|
|
74
|
-
- rc-tree
|
|
75
|
-
|
|
76
|
-
MIT LICENSE
|
|
77
|
-
|
|
78
|
-
Copyright (c) 2015-present Alipay.com, https://www.alipay.com/
|
|
79
|
-
|
|
80
|
-
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:
|
|
81
|
-
|
|
82
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
83
|
-
|
|
84
|
-
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
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
# @fibrae/semi-foundation
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[简体中文](README.zh-CN.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The framework-agnostic part of Semi Design Next: component logic (Foundation), SCSS styles, theme tokens and locale packs. The component libraries of every framework share it. Applications usually use it through a UI package rather than depending on it directly.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Foundation and Adapter
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
- Adapter:Foundation 所需方法的接口,由各框架包用本框架的原生机制实现(如 React 的 hook、Vue 的 composable)。
|
|
9
|
+
The JavaScript of each component has two parts so it can be reused across frameworks:
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
- Foundation: holds the component's business logic and references no DOM. Logic that needs the DOM is delegated to the Adapter.
|
|
12
|
+
- Adapter: the interface of the methods a Foundation needs, implemented by each framework package with its native mechanism (such as a React hook or a Vue composable).
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
This is why the package depends on no framework or UI package.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
15
17
|
|
|
16
18
|
```sh
|
|
17
19
|
pnpm add @fibrae/semi-foundation
|
|
18
20
|
```
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
Build plugins need it to resolve `semi:` addresses, and the UI packages already depend on it.
|
|
21
23
|
|
|
22
|
-
##
|
|
24
|
+
## Usage
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
This package has no root entry. It offers only deep file paths, which map one-to-one to the directories under `src/` and come with type declarations:
|
|
25
27
|
|
|
26
28
|
```ts
|
|
27
29
|
import BaseFoundation from '@fibrae/semi-foundation/base/foundation';
|
|
@@ -30,48 +32,48 @@ import en_GB from '@fibrae/semi-foundation/locale/source/en_GB';
|
|
|
30
32
|
import { utcToZonedTime } from '@fibrae/semi-foundation/utils/date-fns-extra';
|
|
31
33
|
```
|
|
32
34
|
|
|
33
|
-
`exports`
|
|
35
|
+
`exports` also includes `./*.css` and `./*.scss`. The component CSS is compiled by `vp pack`. The published `.scss` contains `semi:` addresses and cannot be compiled by Sass directly; it goes through a build plugin or `@fibrae/semi-scss-compile`.
|
|
34
36
|
|
|
35
|
-
##
|
|
37
|
+
## Directories
|
|
36
38
|
|
|
37
|
-
`src/`
|
|
39
|
+
`src/` has one directory per component, containing `foundation.ts`, `constants.ts` and `*.scss` as needed (`variables.scss`, `mixin.scss`, `rtl.scss` and similar ship only as source). Shared directories:
|
|
38
40
|
|
|
39
|
-
|
|
|
40
|
-
| --------- |
|
|
41
|
-
| `base/` | `BaseFoundation`
|
|
42
|
-
| `theme/` |
|
|
43
|
-
| `locale/` |
|
|
44
|
-
| `utils/` |
|
|
41
|
+
| Directory | Contents |
|
|
42
|
+
| --------- | ------------------------------------------------------------------------------------------------ |
|
|
43
|
+
| `base/` | `BaseFoundation` and common constants |
|
|
44
|
+
| `theme/` | The one theme: global tokens, palettes and mixins, loaded by component SCSS through `semi:theme` |
|
|
45
|
+
| `locale/` | Locale packs and the `Locale` type |
|
|
46
|
+
| `utils/` | Focus, layer stack, date, DOM and other utilities |
|
|
45
47
|
|
|
46
|
-
##
|
|
48
|
+
## Locale packs
|
|
47
49
|
|
|
48
|
-
`src/locale/source/`
|
|
50
|
+
`src/locale/source/` holds 57 locale packs. Each file default-exports a `Locale`, whose type is in `src/locale/interface.ts`:
|
|
49
51
|
|
|
50
|
-
- `code
|
|
51
|
-
- `dateFnsLocale
|
|
52
|
-
- `currency
|
|
53
|
-
-
|
|
52
|
+
- `code`: the language code.
|
|
53
|
+
- `dateFnsLocale`: the date-fns locale object used to format and parse dates.
|
|
54
|
+
- `currency`: the ISO 4217 currency code, passed by InputNumber to `Intl.NumberFormat`.
|
|
55
|
+
- The other keys are grouped by component and hold built-in text and accessible names. Values with `${name}` are placeholders; do not translate the placeholder itself.
|
|
54
56
|
|
|
55
|
-
|
|
57
|
+
To use a pack, pass it to the UI package's `LocaleProvider`:
|
|
56
58
|
|
|
57
59
|
```tsx
|
|
58
|
-
import en_GB from '@fibrae/semi-foundation/locale/source/en_GB';
|
|
59
60
|
import { LocaleProvider } from '@fibrae/semi-ui-react';
|
|
61
|
+
import en_GB from '@fibrae/semi-ui-react/locale/source/en_GB';
|
|
60
62
|
|
|
61
63
|
<LocaleProvider locale={en_GB}>
|
|
62
64
|
<App />
|
|
63
65
|
</LocaleProvider>;
|
|
64
66
|
```
|
|
65
67
|
|
|
66
|
-
Vue
|
|
68
|
+
The Vue package's `LocaleProvider` has the same name and takes `:locale`. For adding text or accessible names and filling in every locale pack, see [locale-text](../../.agents/skills/locale-text/SKILL.md).
|
|
67
69
|
|
|
68
|
-
##
|
|
70
|
+
## Related packages
|
|
69
71
|
|
|
70
|
-
-
|
|
71
|
-
-
|
|
72
|
+
- Depends on `@fibrae/semi-json-viewer-core`. Framework-agnostic rendering logic for Markdown, MDX, Lottie and code highlighting also lives here.
|
|
73
|
+
- Used by the UI package of each framework, `@fibrae/semi-ai-foundation` and the AI component packages.
|
|
72
74
|
|
|
73
|
-
##
|
|
75
|
+
## Development
|
|
74
76
|
|
|
75
|
-
`pnpm --filter @fibrae/semi-foundation build`
|
|
77
|
+
`pnpm --filter @fibrae/semi-foundation build` runs `vp pack`: `src/**/*.ts` emits ESM and type declarations file by file, component SCSS compiles to CSS, and theme tokens compile into `base/tokens.css`. Type checks in the UI packages read the types built here.
|
|
76
78
|
|
|
77
|
-
|
|
79
|
+
For general commands, see [CONTRIBUTING.md](../../CONTRIBUTING.md#常用命令) at the repository root. For how to write styles, the `semi:` importer and the theme token protocol, see the 「组件 SCSS」, 「Sass 模块与 semi: importer」 and 「主题 token 协议」 sections of [styles](../../.agents/references/styles.md).
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# @fibrae/semi-foundation
|
|
2
|
+
|
|
3
|
+
[English](README.md)
|
|
4
|
+
|
|
5
|
+
Semi Design Next 中与框架无关的部分:组件逻辑(Foundation)、SCSS 样式、主题 token 和语言包。各框架的组件库共用它,使用方通常不直接依赖,而是经 UI 包间接使用。
|
|
6
|
+
|
|
7
|
+
## Foundation 与 Adapter
|
|
8
|
+
|
|
9
|
+
每个组件的 JavaScript 分成两部分,以便在不同框架间复用:
|
|
10
|
+
|
|
11
|
+
- Foundation:承载组件的业务逻辑,不引用任何 DOM。需要操作 DOM 的逻辑,委托给 Adapter。
|
|
12
|
+
- Adapter:Foundation 所需方法的接口,由各框架包用本框架的原生机制实现(如 React 的 hook、Vue 的 composable)。
|
|
13
|
+
|
|
14
|
+
因此本包不依赖任何框架和 UI 包。
|
|
15
|
+
|
|
16
|
+
## 安装
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
pnpm add @fibrae/semi-foundation
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
构建插件解析 `semi:` 地址时需要它,UI 包已把它作为依赖。
|
|
23
|
+
|
|
24
|
+
## 使用
|
|
25
|
+
|
|
26
|
+
本包没有根入口,只提供逐文件的深路径,与 `src/` 下的目录一一对应,同时提供类型声明:
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import BaseFoundation from '@fibrae/semi-foundation/base/foundation';
|
|
30
|
+
import type { Locale } from '@fibrae/semi-foundation/locale/interface';
|
|
31
|
+
import en_GB from '@fibrae/semi-foundation/locale/source/en_GB';
|
|
32
|
+
import { utcToZonedTime } from '@fibrae/semi-foundation/utils/date-fns-extra';
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`exports` 还包含 `./*.css` 与 `./*.scss`:组件 CSS 是 `vp pack` 编译的产物;发布的 `.scss` 含有 `semi:` 地址,不能直接用 Sass 编译,需要经构建插件或 `@fibrae/semi-scss-compile`。
|
|
36
|
+
|
|
37
|
+
## 目录
|
|
38
|
+
|
|
39
|
+
`src/` 下每个组件一个目录,按需包含 `foundation.ts`、`constants.ts` 与 `*.scss`(`variables.scss`、`mixin.scss`、`rtl.scss` 等只按源文件发布)。公共目录:
|
|
40
|
+
|
|
41
|
+
| 目录 | 内容 |
|
|
42
|
+
| --------- | ------------------------------------------------------------------- |
|
|
43
|
+
| `base/` | `BaseFoundation` 与通用常量 |
|
|
44
|
+
| `theme/` | 唯一的主题:全局 token、色板、mixin,组件 SCSS 经 `semi:theme` 加载 |
|
|
45
|
+
| `locale/` | 语言包与 `Locale` 类型 |
|
|
46
|
+
| `utils/` | 焦点、层栈、日期、DOM 等工具 |
|
|
47
|
+
|
|
48
|
+
## 语言包
|
|
49
|
+
|
|
50
|
+
`src/locale/source/` 下有 57 个语言包,每个文件默认导出一个 `Locale`,类型在 `src/locale/interface.ts`:
|
|
51
|
+
|
|
52
|
+
- `code`:语言代码。
|
|
53
|
+
- `dateFnsLocale`:格式化和解析日期时使用的 date-fns locale 对象。
|
|
54
|
+
- `currency`:ISO 4217 货币代码,InputNumber 传给 `Intl.NumberFormat`。
|
|
55
|
+
- 其余键按组件分组,是组件的内置文案和可访问名称。含 `${名字}` 的值是占位符,翻译时不要替换占位符本身。
|
|
56
|
+
|
|
57
|
+
使用时把语言包传给 UI 包的 `LocaleProvider`:
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import { LocaleProvider } from '@fibrae/semi-ui-react';
|
|
61
|
+
import en_GB from '@fibrae/semi-ui-react/locale/source/en_GB';
|
|
62
|
+
|
|
63
|
+
<LocaleProvider locale={en_GB}>
|
|
64
|
+
<App />
|
|
65
|
+
</LocaleProvider>;
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Vue 包的 `LocaleProvider` 同名,通过 `:locale` 传入。新增文案或可访问名称、补齐全部语言包的步骤见 [locale-text](../../.agents/skills/locale-text/SKILL.md)。
|
|
69
|
+
|
|
70
|
+
## 与其他包的关系
|
|
71
|
+
|
|
72
|
+
- 依赖 `@fibrae/semi-json-viewer-core`;Markdown、MDX、Lottie 与代码高亮等与框架无关的渲染逻辑也在本包。
|
|
73
|
+
- 被各框架的 UI 包、`@fibrae/semi-ai-foundation` 及 AI 组件包使用。
|
|
74
|
+
|
|
75
|
+
## 开发
|
|
76
|
+
|
|
77
|
+
`pnpm --filter @fibrae/semi-foundation build` 执行 `vp pack`:`src/**/*.ts` 逐文件输出 ESM 与类型声明,组件 SCSS 编译为 CSS,主题 token 编译进 `base/tokens.css`。各框架 UI 包的类型检查读取这里已构建的类型。
|
|
78
|
+
|
|
79
|
+
通用命令见根目录 [CONTRIBUTING.md](../../CONTRIBUTING.md#常用命令)。样式写法、`semi:` importer 与主题 token 协议见 [styles](../../.agents/references/styles.md) 的「组件 SCSS」「Sass 模块与 semi: importer」「主题 token 协议」等节。
|
|
@@ -11,7 +11,7 @@ export declare function needConfirm({ type, needConfirm: confirm }: {
|
|
|
11
11
|
type?: Type;
|
|
12
12
|
needConfirm?: boolean;
|
|
13
13
|
}): boolean;
|
|
14
|
-
export declare function isYearOrMonthType(type?: Type): type is "
|
|
14
|
+
export declare function isYearOrMonthType(type?: Type): type is "year" | "month" | "monthRange";
|
|
15
15
|
/** monthRange shows its range in one trigger input; the other range types split it into a start and an end input */
|
|
16
16
|
export declare function isSplitRangeInputs(type?: Type): boolean;
|
|
17
17
|
/** An empty range (cleared) or one with two valid dates; a half-picked range is neither committed nor confirmed */
|
|
@@ -4,7 +4,7 @@ export type DropdownSelectionMode = 'single' | 'multiple';
|
|
|
4
4
|
* Role and checked state of a menu item, from the menu's selectionMode (as React Aria Menu) and showTick. Without a
|
|
5
5
|
* selectionMode a tick shows a checked state, so showTick alone makes the items checkboxes.
|
|
6
6
|
*/
|
|
7
|
-
export declare function getItemRole(selectionMode?: DropdownSelectionMode, showTick?: boolean): "
|
|
7
|
+
export declare function getItemRole(selectionMode?: DropdownSelectionMode, showTick?: boolean): "menuitemradio" | "menuitemcheckbox" | "menuitem";
|
|
8
8
|
/**
|
|
9
9
|
* What a Dropdown provides to everything inside its popup, read by the menus there and by a Dropdown whose trigger is
|
|
10
10
|
* one of their items. A framework adapter passes it as the foundation context, with the reading direction added.
|
|
@@ -35,13 +35,13 @@ export default class NotificationListStore {
|
|
|
35
35
|
icon?: any;
|
|
36
36
|
getPopupContainer?: () => HTMLElement;
|
|
37
37
|
theme?: NoticeTheme;
|
|
38
|
-
direction?: "
|
|
38
|
+
direction?: "ltr" | "rtl";
|
|
39
39
|
className?: string;
|
|
40
40
|
style?: any;
|
|
41
41
|
stack?: boolean | number;
|
|
42
|
-
top?: number | string;
|
|
43
42
|
left?: number | string;
|
|
44
43
|
right?: number | string;
|
|
44
|
+
top?: number | string;
|
|
45
45
|
bottom?: number | string;
|
|
46
46
|
};
|
|
47
47
|
subscribe: (listener: () => void) => () => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibrae/semi-foundation",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://semi-design-next.pages.dev",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@date-fns/tz": "^1.5.0",
|
|
27
27
|
"@dnd-kit/dom": "~0.5.1",
|
|
28
|
-
"@fibrae/semi-json-viewer-core": "0.3.
|
|
28
|
+
"@fibrae/semi-json-viewer-core": "0.3.1",
|
|
29
29
|
"@mdx-js/mdx": "^3.1.1",
|
|
30
30
|
"@shikijs/core": "^4.5.0",
|
|
31
31
|
"async-validator": "^4.2.5",
|