@humuchen/mac-ui 0.0.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/README.md +940 -0
- package/dist/favicon.svg +1 -0
- package/dist/mac-ui.cjs.js +12367 -0
- package/dist/mac-ui.cjs.js.map +1 -0
- package/dist/mac-ui.es.js +18444 -0
- package/dist/mac-ui.es.js.map +1 -0
- package/dist/mac-ui.umd.js +12367 -0
- package/dist/mac-ui.umd.js.map +1 -0
- package/dist/types/components/alert/index.d.ts +1 -0
- package/dist/types/components/alert/mac-alert.d.ts +38 -0
- package/dist/types/components/alert/mac-alert.stories.d.ts +15 -0
- package/dist/types/components/animation/animations.d.ts +97 -0
- package/dist/types/components/animation/index.d.ts +3 -0
- package/dist/types/components/animation/mac-animation.d.ts +67 -0
- package/dist/types/components/animation/mac-animation.stories.d.ts +9 -0
- package/dist/types/components/button/index.d.ts +1 -0
- package/dist/types/components/button/mac-button.d.ts +37 -0
- package/dist/types/components/button/mac-button.stories.d.ts +14 -0
- package/dist/types/components/card/index.d.ts +1 -0
- package/dist/types/components/card/mac-card.d.ts +38 -0
- package/dist/types/components/card/mac-card.stories.d.ts +14 -0
- package/dist/types/components/carousel/index.d.ts +1 -0
- package/dist/types/components/carousel/mac-carousel.d.ts +105 -0
- package/dist/types/components/carousel/mac-carousel.stories.d.ts +18 -0
- package/dist/types/components/checkbox/index.d.ts +2 -0
- package/dist/types/components/checkbox/mac-checkbox.d.ts +94 -0
- package/dist/types/components/checkbox/mac-checkbox.stories.d.ts +17 -0
- package/dist/types/components/config-provider/index.d.ts +1 -0
- package/dist/types/components/config-provider/mac-config-provider.d.ts +23 -0
- package/dist/types/components/config-provider/mac-config-provider.stories.d.ts +12 -0
- package/dist/types/components/confirm/index.d.ts +2 -0
- package/dist/types/components/confirm/mac-confirm.d.ts +86 -0
- package/dist/types/components/confirm/mac-confirm.stories.d.ts +15 -0
- package/dist/types/components/data-table/index.d.ts +2 -0
- package/dist/types/components/data-table/mac-data-table.d.ts +212 -0
- package/dist/types/components/data-table/mac-data-table.stories.d.ts +18 -0
- package/dist/types/components/date-picker/date-picker-utils.d.ts +13 -0
- package/dist/types/components/date-picker/index.d.ts +3 -0
- package/dist/types/components/date-picker/mac-date-picker.d.ts +72 -0
- package/dist/types/components/date-picker/mac-date-picker.stories.d.ts +28 -0
- package/dist/types/components/date-picker/mac-date-range-picker.d.ts +58 -0
- package/dist/types/components/date-picker/mac-date-range-picker.stories.d.ts +13 -0
- package/dist/types/components/descriptions/mac-descriptions.d.ts +99 -0
- package/dist/types/components/descriptions/mac-descriptions.stories.d.ts +21 -0
- package/dist/types/components/desktop/index.d.ts +2 -0
- package/dist/types/components/desktop/mac-desktop.d.ts +88 -0
- package/dist/types/components/desktop/mac-desktop.stories.d.ts +17 -0
- package/dist/types/components/desktop-icon/index.d.ts +1 -0
- package/dist/types/components/desktop-icon/mac-desktop-icon.d.ts +46 -0
- package/dist/types/components/desktop-icon/mac-desktop-icon.stories.d.ts +8 -0
- package/dist/types/components/dock/index.d.ts +2 -0
- package/dist/types/components/dock/mac-dock-item.d.ts +37 -0
- package/dist/types/components/dock/mac-dock.d.ts +74 -0
- package/dist/types/components/dock/mac-dock.stories.d.ts +13 -0
- package/dist/types/components/drawer/mac-drawer.d.ts +87 -0
- package/dist/types/components/drawer/mac-drawer.stories.d.ts +15 -0
- package/dist/types/components/dropdown/index.d.ts +2 -0
- package/dist/types/components/dropdown/mac-dropdown.d.ts +77 -0
- package/dist/types/components/dropdown/mac-dropdown.stories.d.ts +13 -0
- package/dist/types/components/dynamic-tags/index.d.ts +1 -0
- package/dist/types/components/dynamic-tags/mac-dynamic-tags.d.ts +64 -0
- package/dist/types/components/dynamic-tags/mac-dynamic-tags.stories.d.ts +16 -0
- package/dist/types/components/form/index.d.ts +3 -0
- package/dist/types/components/form/mac-form-item.d.ts +67 -0
- package/dist/types/components/form/mac-form.d.ts +64 -0
- package/dist/types/components/form/mac-form.stories.d.ts +18 -0
- package/dist/types/components/group-button/index.d.ts +2 -0
- package/dist/types/components/group-button/mac-group-button.d.ts +50 -0
- package/dist/types/components/group-button/mac-group-button.stories.d.ts +13 -0
- package/dist/types/components/infinite-scroll/index.d.ts +1 -0
- package/dist/types/components/infinite-scroll/mac-infinite-scroll.d.ts +57 -0
- package/dist/types/components/infinite-scroll/mac-infinite-scroll.stories.d.ts +11 -0
- package/dist/types/components/input/index.d.ts +1 -0
- package/dist/types/components/input/mac-input.d.ts +73 -0
- package/dist/types/components/input/mac-input.stories.d.ts +19 -0
- package/dist/types/components/input-number/index.d.ts +1 -0
- package/dist/types/components/input-number/mac-input-number.d.ts +81 -0
- package/dist/types/components/input-number/mac-input-number.stories.d.ts +18 -0
- package/dist/types/components/lazy-image/index.d.ts +1 -0
- package/dist/types/components/lazy-image/mac-lazy-image.d.ts +86 -0
- package/dist/types/components/lazy-image/mac-lazy-image.stories.d.ts +15 -0
- package/dist/types/components/menu/index.d.ts +2 -0
- package/dist/types/components/menu/mac-menu.d.ts +63 -0
- package/dist/types/components/menu/mac-menu.stories.d.ts +11 -0
- package/dist/types/components/modal/index.d.ts +1 -0
- package/dist/types/components/modal/mac-modal.d.ts +96 -0
- package/dist/types/components/modal/mac-modal.stories.d.ts +12 -0
- package/dist/types/components/number-animation/mac-number-animation.d.ts +64 -0
- package/dist/types/components/number-animation/mac-number-animation.stories.d.ts +15 -0
- package/dist/types/components/popconfirm/mac-popconfirm.d.ts +77 -0
- package/dist/types/components/popconfirm/mac-popconfirm.stories.d.ts +14 -0
- package/dist/types/components/progress/index.d.ts +1 -0
- package/dist/types/components/progress/mac-progress.d.ts +76 -0
- package/dist/types/components/progress/mac-progress.stories.d.ts +25 -0
- package/dist/types/components/radio/index.d.ts +2 -0
- package/dist/types/components/radio/mac-radio.d.ts +90 -0
- package/dist/types/components/radio/mac-radio.stories.d.ts +17 -0
- package/dist/types/components/rating/mac-rating.d.ts +56 -0
- package/dist/types/components/rating/mac-rating.stories.d.ts +15 -0
- package/dist/types/components/select/index.d.ts +1 -0
- package/dist/types/components/select/mac-select.d.ts +97 -0
- package/dist/types/components/select/mac-select.stories.d.ts +18 -0
- package/dist/types/components/split/index.d.ts +1 -0
- package/dist/types/components/split/mac-split.d.ts +69 -0
- package/dist/types/components/split/mac-split.stories.d.ts +13 -0
- package/dist/types/components/tabs/mac-tabs.d.ts +119 -0
- package/dist/types/components/tabs/mac-tabs.stories.d.ts +15 -0
- package/dist/types/components/tag/index.d.ts +1 -0
- package/dist/types/components/tag/mac-tag.d.ts +40 -0
- package/dist/types/components/tag/mac-tag.stories.d.ts +20 -0
- package/dist/types/components/text-ellipsis/mac-text-ellipsis.d.ts +47 -0
- package/dist/types/components/text-ellipsis/mac-text-ellipsis.stories.d.ts +15 -0
- package/dist/types/components/tree/index.d.ts +2 -0
- package/dist/types/components/tree/mac-tree.d.ts +79 -0
- package/dist/types/components/tree/mac-tree.stories.d.ts +12 -0
- package/dist/types/components/tree-select/index.d.ts +2 -0
- package/dist/types/components/tree-select/mac-tree-select.d.ts +59 -0
- package/dist/types/components/tree-select/mac-tree-select.stories.d.ts +19 -0
- package/dist/types/internal/base-element.d.ts +18 -0
- package/dist/types/internal/property-converters.d.ts +7 -0
- package/dist/types/mac-ui.d.ts +60 -0
- package/dist/types/styles/shared-styles.d.ts +2 -0
- package/dist/types/styles/theme.d.ts +11 -0
- package/dist/types/test/setup.d.ts +1 -0
- package/package.json +86 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { BaseElement } from '../../internal/base-element';
|
|
2
|
+
import type { MacFormItem } from './mac-form-item';
|
|
3
|
+
export interface FormRule {
|
|
4
|
+
required?: boolean;
|
|
5
|
+
message?: string;
|
|
6
|
+
trigger?: 'blur' | 'change' | 'input' | ('blur' | 'change' | 'input')[];
|
|
7
|
+
validator?: (value: unknown) => boolean | string | Promise<boolean | string>;
|
|
8
|
+
min?: number;
|
|
9
|
+
max?: number;
|
|
10
|
+
len?: number;
|
|
11
|
+
pattern?: RegExp;
|
|
12
|
+
type?: 'string' | 'number' | 'boolean' | 'array' | 'email' | 'url' | 'date';
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @tag mac-form
|
|
16
|
+
* @summary 一个表单组件,用于收集和验证用户输入。
|
|
17
|
+
*
|
|
18
|
+
* @slot - 表单项和控件。
|
|
19
|
+
*
|
|
20
|
+
* @csspart base - 表单的基础容器。
|
|
21
|
+
*
|
|
22
|
+
* @event mac-change - 字段值变化时触发。Detail: { model, path, value }
|
|
23
|
+
* @event mac-submit - 表单提交时触发。Detail: { model }
|
|
24
|
+
*/
|
|
25
|
+
export declare class MacForm extends BaseElement {
|
|
26
|
+
static styles: import("lit").CSSResult[];
|
|
27
|
+
/** 表单数据模型。 */
|
|
28
|
+
model: Record<string, unknown>;
|
|
29
|
+
/** 验证规则。 */
|
|
30
|
+
rules: Record<string, FormRule | FormRule[]>;
|
|
31
|
+
/** 标签宽度。 */
|
|
32
|
+
labelWidth: string;
|
|
33
|
+
/** 标签对齐方式。 */
|
|
34
|
+
labelAlign: 'left' | 'right' | 'top';
|
|
35
|
+
/** 是否显示标签。 */
|
|
36
|
+
showLabel: boolean;
|
|
37
|
+
/** 是否显示反馈(错误信息)。 */
|
|
38
|
+
showFeedback: boolean;
|
|
39
|
+
/** 表单尺寸。 */
|
|
40
|
+
size?: 'sm' | 'md' | 'lg';
|
|
41
|
+
/** 禁用所有表单项。 */
|
|
42
|
+
disabled: boolean;
|
|
43
|
+
private _items;
|
|
44
|
+
willUpdate(): void;
|
|
45
|
+
_registerItem(item: MacFormItem): void;
|
|
46
|
+
_unregisterItem(item: MacFormItem): void;
|
|
47
|
+
/** 根据路径获取字段值。 */
|
|
48
|
+
getValue(path: string): unknown;
|
|
49
|
+
/** 根据路径设置字段值。 */
|
|
50
|
+
setValue(path: string, value: unknown): void;
|
|
51
|
+
/** 验证所有表单项。 */
|
|
52
|
+
validate(): Promise<boolean>;
|
|
53
|
+
/** 重置所有表单项的验证状态。 */
|
|
54
|
+
reset(): void;
|
|
55
|
+
/** 清空表单模型。 */
|
|
56
|
+
clear(): void;
|
|
57
|
+
render(): import("lit").TemplateResult<1>;
|
|
58
|
+
private _handleSubmit;
|
|
59
|
+
}
|
|
60
|
+
declare global {
|
|
61
|
+
interface HTMLElementTagNameMap {
|
|
62
|
+
'mac-form': MacForm;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/web-components';
|
|
2
|
+
import './mac-form';
|
|
3
|
+
import './mac-form-item';
|
|
4
|
+
import '../input/mac-input';
|
|
5
|
+
import '../input-number/mac-input-number';
|
|
6
|
+
import '../radio/mac-radio';
|
|
7
|
+
import '../button/mac-button';
|
|
8
|
+
declare const meta: Meta;
|
|
9
|
+
export default meta;
|
|
10
|
+
type Story = StoryObj;
|
|
11
|
+
export declare const Default: Story;
|
|
12
|
+
export declare const LabelAlign: Story;
|
|
13
|
+
export declare const Sizes: Story;
|
|
14
|
+
export declare const ValidationRules: Story;
|
|
15
|
+
export declare const InlineRules: Story;
|
|
16
|
+
export declare const Disabled: Story;
|
|
17
|
+
export declare const NoFeedback: Story;
|
|
18
|
+
export declare const NoLabel: Story;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { PropertyValues } from 'lit';
|
|
2
|
+
import { BaseElement } from '../../internal/base-element';
|
|
3
|
+
export interface GroupButtonItem {
|
|
4
|
+
value: string;
|
|
5
|
+
label: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* @tag mac-group-button
|
|
10
|
+
* @summary 一个 macOS 风格的分段控制组件。
|
|
11
|
+
*
|
|
12
|
+
* @slot - 默认插槽,用于分组按钮项。
|
|
13
|
+
*
|
|
14
|
+
* @csspart container - 主容器。
|
|
15
|
+
* @csspart slider - 滑动背景指示器。
|
|
16
|
+
* @csspart button - 单个按钮元素。
|
|
17
|
+
*
|
|
18
|
+
* @event mac-change - 选中值变化时触发。
|
|
19
|
+
*/
|
|
20
|
+
export declare class MacGroupButton extends BaseElement {
|
|
21
|
+
static styles: import("lit").CSSResult[];
|
|
22
|
+
/** 按钮项数组。 */
|
|
23
|
+
items: GroupButtonItem[];
|
|
24
|
+
/** 当前选中的值。 */
|
|
25
|
+
value: string;
|
|
26
|
+
/** 按钮的尺寸。 */
|
|
27
|
+
size?: 'sm' | 'md' | 'lg';
|
|
28
|
+
/** 禁用所有按钮。 */
|
|
29
|
+
disabled: boolean;
|
|
30
|
+
private slider;
|
|
31
|
+
private buttons;
|
|
32
|
+
private _selectedIndex;
|
|
33
|
+
willUpdate(): void;
|
|
34
|
+
protected firstUpdated(changedProperties: PropertyValues): void;
|
|
35
|
+
protected updated(changedProperties: PropertyValues): void;
|
|
36
|
+
private _setInitialValue;
|
|
37
|
+
private _updateSliderPosition;
|
|
38
|
+
private _handleButtonClick;
|
|
39
|
+
private _handleKeyDown;
|
|
40
|
+
private _getPreviousEnabledIndex;
|
|
41
|
+
private _getNextEnabledIndex;
|
|
42
|
+
private _getFirstEnabledIndex;
|
|
43
|
+
private _getLastEnabledIndex;
|
|
44
|
+
render(): import("lit").TemplateResult<1>;
|
|
45
|
+
}
|
|
46
|
+
declare global {
|
|
47
|
+
interface HTMLElementTagNameMap {
|
|
48
|
+
'mac-group-button': MacGroupButton;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/web-components';
|
|
2
|
+
import './mac-group-button';
|
|
3
|
+
declare const meta: Meta;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Small: Story;
|
|
8
|
+
export declare const Large: Story;
|
|
9
|
+
export declare const WithDisabledItems: Story;
|
|
10
|
+
export declare const Disabled: Story;
|
|
11
|
+
export declare const TwoButtons: Story;
|
|
12
|
+
export declare const ManyButtons: Story;
|
|
13
|
+
export declare const AllSizes: Story;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MacInfiniteScroll } from './mac-infinite-scroll';
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { BaseElement } from '../../internal/base-element';
|
|
2
|
+
/**
|
|
3
|
+
* @tag mac-infinite-scroll
|
|
4
|
+
* @summary 无限滚动组件,滚动到底部时触发加载更多数据。
|
|
5
|
+
*
|
|
6
|
+
* @slot - 默认插槽,用于列表内容。
|
|
7
|
+
* @slot loading - 自定义加载指示器内容。
|
|
8
|
+
* @slot finished - 没有更多数据时显示的自定义内容。
|
|
9
|
+
* @slot error - 加载失败时显示的自定义内容。添加点击监听器以触发重试。
|
|
10
|
+
*
|
|
11
|
+
* @csspart loading - 加载状态容器。
|
|
12
|
+
* @csspart finished - 完成状态容器。
|
|
13
|
+
* @csspart error - 错误状态容器。
|
|
14
|
+
*
|
|
15
|
+
* @cssproperty --md-infinite-scroll-padding - 状态区域内边距。
|
|
16
|
+
* @cssproperty --md-infinite-scroll-color - 状态文字颜色。
|
|
17
|
+
* @cssproperty --md-infinite-scroll-font-size - 状态字体大小。
|
|
18
|
+
* @cssproperty --md-infinite-scroll-gap - 旋转器与文字之间的间距。
|
|
19
|
+
* @cssproperty --md-infinite-scroll-spinner-size - 旋转器大小。
|
|
20
|
+
*
|
|
21
|
+
* @event mac-load-more - 应该加载更多数据时触发。
|
|
22
|
+
* @event mac-retry - 点击重试按钮时触发。
|
|
23
|
+
*/
|
|
24
|
+
export declare class MacInfiniteScroll extends BaseElement {
|
|
25
|
+
static styles: import("lit").CSSResult[];
|
|
26
|
+
/** 是否还有更多数据可加载。 */
|
|
27
|
+
hasMore: boolean;
|
|
28
|
+
/** 当前是否正在加载数据。 */
|
|
29
|
+
loading: boolean;
|
|
30
|
+
/** 上次加载尝试是否失败。 */
|
|
31
|
+
error: boolean;
|
|
32
|
+
/** 距离底部触发加载的像素距离。 */
|
|
33
|
+
threshold: number;
|
|
34
|
+
/** 挂载后是否立即检查,当内容未填满容器时。 */
|
|
35
|
+
immediateCheck: boolean;
|
|
36
|
+
/** 是否禁用自动加载。 */
|
|
37
|
+
disabled: boolean;
|
|
38
|
+
private _internalLoading;
|
|
39
|
+
private _observer?;
|
|
40
|
+
private _sentinelEl?;
|
|
41
|
+
firstUpdated(): void;
|
|
42
|
+
updated(changed: Map<string, unknown>): void;
|
|
43
|
+
disconnectedCallback(): void;
|
|
44
|
+
private _setupObserver;
|
|
45
|
+
private _cleanupObserver;
|
|
46
|
+
private _handleScroll;
|
|
47
|
+
private _checkIfNeedLoad;
|
|
48
|
+
private _tryLoadMore;
|
|
49
|
+
private _handleRetry;
|
|
50
|
+
render(): import("lit").TemplateResult<1>;
|
|
51
|
+
private _renderStatus;
|
|
52
|
+
}
|
|
53
|
+
declare global {
|
|
54
|
+
interface HTMLElementTagNameMap {
|
|
55
|
+
'mac-infinite-scroll': MacInfiniteScroll;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/web-components';
|
|
2
|
+
import './mac-infinite-scroll';
|
|
3
|
+
declare const meta: Meta;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj;
|
|
6
|
+
export declare const Basic: Story;
|
|
7
|
+
export declare const CustomSlots: Story;
|
|
8
|
+
export declare const FinishedState: Story;
|
|
9
|
+
export declare const ErrorState: Story;
|
|
10
|
+
export declare const LoadingState: Story;
|
|
11
|
+
export declare const Disabled: Story;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MacInput } from './mac-input';
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { BaseElement } from '../../internal/base-element';
|
|
2
|
+
/**
|
|
3
|
+
* @tag mac-input
|
|
4
|
+
* @summary macOS 风格的文本输入组件。
|
|
5
|
+
*
|
|
6
|
+
* @slot prefix - 输入框前的内容。
|
|
7
|
+
* @slot suffix - 输入框后的内容。
|
|
8
|
+
*
|
|
9
|
+
* @csspart base - 输入框的基础容器。
|
|
10
|
+
* @csspart input - 原生输入元素。
|
|
11
|
+
* @csspart label - 标签元素。
|
|
12
|
+
* @csspart helper-text - 辅助文本元素。
|
|
13
|
+
*/
|
|
14
|
+
export declare class MacInput extends BaseElement {
|
|
15
|
+
static styles: import("lit").CSSResult[];
|
|
16
|
+
/** 输入框的值。 */
|
|
17
|
+
value: string;
|
|
18
|
+
/** 输入框的占位符。 */
|
|
19
|
+
placeholder: string;
|
|
20
|
+
/** 输入框的类型。 */
|
|
21
|
+
type: 'text' | 'password' | 'email' | 'number' | 'tel' | 'url';
|
|
22
|
+
/** 输入框的尺寸。 */
|
|
23
|
+
size?: 'sm' | 'md' | 'lg';
|
|
24
|
+
/** 视觉变体。 */
|
|
25
|
+
variant: 'default' | 'filled' | 'glass' | 'underline';
|
|
26
|
+
/** 输入框的标签。 */
|
|
27
|
+
label: string;
|
|
28
|
+
/** 显示必填指示器。 */
|
|
29
|
+
required: boolean;
|
|
30
|
+
/** 禁用输入框。 */
|
|
31
|
+
disabled: boolean;
|
|
32
|
+
/** 使输入框只读。 */
|
|
33
|
+
readonly: boolean;
|
|
34
|
+
/** 输入框的错误状态。 */
|
|
35
|
+
error: boolean;
|
|
36
|
+
/** 输入框的成功状态。 */
|
|
37
|
+
success: boolean;
|
|
38
|
+
/** 输入框的辅助文本。 */
|
|
39
|
+
helperText: string;
|
|
40
|
+
/** 输入框的名称(用于表单)。 */
|
|
41
|
+
name: string;
|
|
42
|
+
/** 显示清除按钮。 */
|
|
43
|
+
clearable: boolean;
|
|
44
|
+
/** 显示密码切换按钮。 */
|
|
45
|
+
showPasswordToggle: boolean;
|
|
46
|
+
/** 显示字符计数器。 */
|
|
47
|
+
showCharCounter: boolean;
|
|
48
|
+
/** 最大字符长度。 */
|
|
49
|
+
maxLength?: number;
|
|
50
|
+
/** 显示加载状态。 */
|
|
51
|
+
loading: boolean;
|
|
52
|
+
/** 启用浮动标签。 */
|
|
53
|
+
floating: boolean;
|
|
54
|
+
private _hasFocus;
|
|
55
|
+
private _showPassword;
|
|
56
|
+
private _input;
|
|
57
|
+
willUpdate(): void;
|
|
58
|
+
render(): import("lit").TemplateResult<1>;
|
|
59
|
+
private _handleInput;
|
|
60
|
+
private _handleFocus;
|
|
61
|
+
private _handleBlur;
|
|
62
|
+
private _clearInput;
|
|
63
|
+
private _togglePassword;
|
|
64
|
+
/** 设置输入框焦点。 */
|
|
65
|
+
focus(): void;
|
|
66
|
+
/** 移除输入框焦点。 */
|
|
67
|
+
blur(): void;
|
|
68
|
+
}
|
|
69
|
+
declare global {
|
|
70
|
+
interface HTMLElementTagNameMap {
|
|
71
|
+
'mac-input': MacInput;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/web-components';
|
|
2
|
+
import './mac-input';
|
|
3
|
+
declare const meta: Meta;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj;
|
|
6
|
+
export declare const Basic: Story;
|
|
7
|
+
export declare const Variants: Story;
|
|
8
|
+
export declare const Sizes: Story;
|
|
9
|
+
export declare const States: Story;
|
|
10
|
+
export declare const WithLabel: Story;
|
|
11
|
+
export declare const FloatingLabel: Story;
|
|
12
|
+
export declare const Clearable: Story;
|
|
13
|
+
export declare const PasswordToggle: Story;
|
|
14
|
+
export declare const CharacterCounter: Story;
|
|
15
|
+
export declare const Loading: Story;
|
|
16
|
+
export declare const WithIcons: Story;
|
|
17
|
+
export declare const InputTypes: Story;
|
|
18
|
+
export declare const CompleteExample: Story;
|
|
19
|
+
export declare const GlassInputs: Story;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MacInputNumber } from './mac-input-number';
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { BaseElement } from '../../internal/base-element';
|
|
2
|
+
/**
|
|
3
|
+
* @tag mac-input-number
|
|
4
|
+
* @summary macOS 风格的数字输入组件。
|
|
5
|
+
*
|
|
6
|
+
* @slot prefix - 输入框前的内容。
|
|
7
|
+
* @slot suffix - 输入框后的内容。
|
|
8
|
+
*
|
|
9
|
+
* @csspart base - 输入框的基础容器。
|
|
10
|
+
* @csspart input - 原生输入元素。
|
|
11
|
+
* @csspart buttons - 步进按钮容器。
|
|
12
|
+
* @csspart button-plus - 加号步进按钮。
|
|
13
|
+
* @csspart button-minus - 减号步进按钮。
|
|
14
|
+
*/
|
|
15
|
+
export declare class MacInputNumber extends BaseElement {
|
|
16
|
+
static styles: import("lit").CSSResult[];
|
|
17
|
+
/** 输入框的值。 */
|
|
18
|
+
value?: number;
|
|
19
|
+
/** 非受控模式的默认值。 */
|
|
20
|
+
defaultValue?: number;
|
|
21
|
+
/** 最小值。 */
|
|
22
|
+
min?: number;
|
|
23
|
+
/** 最大值。 */
|
|
24
|
+
max?: number;
|
|
25
|
+
/** 步进值。 */
|
|
26
|
+
step: number;
|
|
27
|
+
/** 精度(小数位数)。 */
|
|
28
|
+
precision?: number;
|
|
29
|
+
/** 输入框的占位符。 */
|
|
30
|
+
placeholder: string;
|
|
31
|
+
/** 输入框的尺寸。 */
|
|
32
|
+
size?: 'sm' | 'md' | 'lg';
|
|
33
|
+
/** 视觉变体。 */
|
|
34
|
+
variant: 'default' | 'filled' | 'glass' | 'underline';
|
|
35
|
+
/** 输入框的状态。 */
|
|
36
|
+
status?: 'error' | 'warning' | 'success';
|
|
37
|
+
/** 禁用输入框。 */
|
|
38
|
+
disabled: boolean;
|
|
39
|
+
/** 使输入框只读。 */
|
|
40
|
+
readonly: boolean;
|
|
41
|
+
/** 显示步进按钮。 */
|
|
42
|
+
showButton: boolean;
|
|
43
|
+
/** 按钮位置。 */
|
|
44
|
+
buttonPlacement: 'inside' | 'outside';
|
|
45
|
+
/** 显示清除按钮。 */
|
|
46
|
+
clearable: boolean;
|
|
47
|
+
/** 输入框的名称(用于表单)。 */
|
|
48
|
+
name: string;
|
|
49
|
+
/** 启用键盘控制(方向键、Page Up/Down)。 */
|
|
50
|
+
keyboard: boolean;
|
|
51
|
+
private _displayValue;
|
|
52
|
+
private _hasFocus;
|
|
53
|
+
private _input;
|
|
54
|
+
private get _isControlled();
|
|
55
|
+
private get _resolvedValue();
|
|
56
|
+
connectedCallback(): void;
|
|
57
|
+
willUpdate(changed: Map<string, unknown>): void;
|
|
58
|
+
private _syncDisplayValue;
|
|
59
|
+
private _formatValue;
|
|
60
|
+
private _parseValue;
|
|
61
|
+
private _clampAndRound;
|
|
62
|
+
private _stepValue;
|
|
63
|
+
private _setValue;
|
|
64
|
+
private _handleInput;
|
|
65
|
+
private _handleChange;
|
|
66
|
+
private _handleFocus;
|
|
67
|
+
private _handleBlur;
|
|
68
|
+
private _handleKeydown;
|
|
69
|
+
private _clearInput;
|
|
70
|
+
private _renderButtons;
|
|
71
|
+
render(): import("lit").TemplateResult<1>;
|
|
72
|
+
/** 设置输入框焦点。 */
|
|
73
|
+
focus(): void;
|
|
74
|
+
/** 移除输入框焦点。 */
|
|
75
|
+
blur(): void;
|
|
76
|
+
}
|
|
77
|
+
declare global {
|
|
78
|
+
interface HTMLElementTagNameMap {
|
|
79
|
+
'mac-input-number': MacInputNumber;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/web-components';
|
|
2
|
+
import './mac-input-number';
|
|
3
|
+
declare const meta: Meta;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const MinMax: Story;
|
|
8
|
+
export declare const Precision: Story;
|
|
9
|
+
export declare const Sizes: Story;
|
|
10
|
+
export declare const Variants: Story;
|
|
11
|
+
export declare const Status: Story;
|
|
12
|
+
export declare const ButtonPlacement: Story;
|
|
13
|
+
export declare const HideButton: Story;
|
|
14
|
+
export declare const Disabled: Story;
|
|
15
|
+
export declare const Clearable: Story;
|
|
16
|
+
export declare const PrefixSuffix: Story;
|
|
17
|
+
export declare const Keyboard: Story;
|
|
18
|
+
export declare const Uncontrolled: Story;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MacLazyImage } from './mac-lazy-image';
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { BaseElement } from '../../internal/base-element';
|
|
2
|
+
/**
|
|
3
|
+
* @tag mac-lazy-image
|
|
4
|
+
* @summary 懒加载图片组件,支持占位图、错误状态、悬停动画和点击预览。
|
|
5
|
+
*
|
|
6
|
+
* @slot placeholder - 加载时显示的自定义占位内容。
|
|
7
|
+
* @slot error - 图片加载失败时显示的自定义错误内容。
|
|
8
|
+
*
|
|
9
|
+
* @csspart image - 图片元素。
|
|
10
|
+
* @csspart placeholder - 占位容器。
|
|
11
|
+
* @csspart error - 错误容器。
|
|
12
|
+
* @csspart preview-overlay - 预览遮罩容器。
|
|
13
|
+
* @csspart preview-image - 预览图片元素。
|
|
14
|
+
*
|
|
15
|
+
* @cssproperty --md-lazy-image-object-fit - 对象适配样式。
|
|
16
|
+
* @cssproperty --md-lazy-image-placeholder-bg - 占位背景颜色。
|
|
17
|
+
* @cssproperty --md-lazy-image-placeholder-color - 占位图标颜色。
|
|
18
|
+
* @cssproperty --md-lazy-image-placeholder-icon-size - 占位图标大小。
|
|
19
|
+
* @cssproperty --md-lazy-image-error-icon-size - 错误图标大小。
|
|
20
|
+
* @cssproperty --md-lazy-image-shimmer-bg - 微光动画高亮颜色。
|
|
21
|
+
* @cssproperty --md-lazy-image-hover-scale - 悬停缩放变换(默认:1.05)。
|
|
22
|
+
* @cssproperty --md-lazy-image-hover-duration - 悬停动画时长(默认:300ms)。
|
|
23
|
+
* @cssproperty --md-lazy-image-hover-easing - 悬停动画缓动(默认:ease-out)。
|
|
24
|
+
* @cssproperty --md-lazy-image-hover-filter - 悬停滤镜效果(默认:none)。
|
|
25
|
+
* @cssproperty --md-lazy-image-preview-bg - 预览遮罩背景(默认:rgba(0,0,0,0.85))。
|
|
26
|
+
* @cssproperty --md-lazy-image-preview-duration - 预览打开/关闭动画时长(默认:250ms)。
|
|
27
|
+
*
|
|
28
|
+
* @event mac-load - 图片成功加载时触发。
|
|
29
|
+
* @event mac-error - 图片加载失败时触发。
|
|
30
|
+
* @event mac-preview-open - 预览遮罩打开时触发。
|
|
31
|
+
* @event mac-preview-close - 预览遮罩关闭时触发。
|
|
32
|
+
*/
|
|
33
|
+
export declare class MacLazyImage extends BaseElement {
|
|
34
|
+
static styles: import("lit").CSSResult[];
|
|
35
|
+
/** 图片源地址。 */
|
|
36
|
+
src: string;
|
|
37
|
+
/** 图片替代文本。 */
|
|
38
|
+
alt: string;
|
|
39
|
+
/** 图片宽度。 */
|
|
40
|
+
width?: string;
|
|
41
|
+
/** 图片高度。 */
|
|
42
|
+
height?: string;
|
|
43
|
+
/** CSS object-fit 值。 */
|
|
44
|
+
objectFit: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';
|
|
45
|
+
/** 加载时显示的占位图片地址。 */
|
|
46
|
+
placeholder?: string;
|
|
47
|
+
/** IntersectionObserver 的 rootMargin。 */
|
|
48
|
+
rootMargin: string;
|
|
49
|
+
/** IntersectionObserver 的 threshold。 */
|
|
50
|
+
threshold: number;
|
|
51
|
+
/** 是否启用点击预览。 */
|
|
52
|
+
preview: boolean;
|
|
53
|
+
/** 预览模式的图片地址。未设置时回退到 src。 */
|
|
54
|
+
previewSrc: string;
|
|
55
|
+
private _loaded;
|
|
56
|
+
private _loading;
|
|
57
|
+
private _error;
|
|
58
|
+
private _inView;
|
|
59
|
+
private _previewOpen;
|
|
60
|
+
private _previewAnimating;
|
|
61
|
+
private _observer?;
|
|
62
|
+
private _imgEl?;
|
|
63
|
+
private _onKeydownBound;
|
|
64
|
+
connectedCallback(): void;
|
|
65
|
+
disconnectedCallback(): void;
|
|
66
|
+
willUpdate(changedProperties: Map<string, unknown>): void;
|
|
67
|
+
private _updatePreviewAttr;
|
|
68
|
+
private _setupObserver;
|
|
69
|
+
private _cleanupObserver;
|
|
70
|
+
private _loadImage;
|
|
71
|
+
render(): import("lit").TemplateResult<1>;
|
|
72
|
+
private _onImageClick;
|
|
73
|
+
private _openPreview;
|
|
74
|
+
private _closePreview;
|
|
75
|
+
private _onKeydown;
|
|
76
|
+
private _onPreviewBgClick;
|
|
77
|
+
private _renderPreview;
|
|
78
|
+
private _renderImage;
|
|
79
|
+
private _renderPlaceholder;
|
|
80
|
+
private _renderError;
|
|
81
|
+
}
|
|
82
|
+
declare global {
|
|
83
|
+
interface HTMLElementTagNameMap {
|
|
84
|
+
'mac-lazy-image': MacLazyImage;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/web-components';
|
|
2
|
+
import './mac-lazy-image';
|
|
3
|
+
declare const meta: Meta;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj;
|
|
6
|
+
export declare const Basic: Story;
|
|
7
|
+
export declare const WithPlaceholderImage: Story;
|
|
8
|
+
export declare const WithCustomPlaceholder: Story;
|
|
9
|
+
export declare const ErrorState: Story;
|
|
10
|
+
export declare const Gallery: Story;
|
|
11
|
+
export declare const ObjectFitVariants: Story;
|
|
12
|
+
export declare const WithPreview: Story;
|
|
13
|
+
export declare const WithCustomPreviewImage: Story;
|
|
14
|
+
export declare const WithHoverAnimation: Story;
|
|
15
|
+
export declare const GalleryWithPreview: Story;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { PropertyValues } from 'lit';
|
|
2
|
+
import { BaseElement } from '../../internal/base-element';
|
|
3
|
+
import type { DropdownItem } from '../dropdown/mac-dropdown';
|
|
4
|
+
/**
|
|
5
|
+
* @tag mac-menu
|
|
6
|
+
* @summary 一个独立的菜单组件,可以在任何位置显示。
|
|
7
|
+
*
|
|
8
|
+
* @csspart base - 菜单的基础容器。
|
|
9
|
+
* @csspart item - 菜单项。
|
|
10
|
+
*/
|
|
11
|
+
export declare class MacMenu extends BaseElement {
|
|
12
|
+
static styles: import("lit").CSSResult[];
|
|
13
|
+
/** 菜单项。 */
|
|
14
|
+
items: DropdownItem[];
|
|
15
|
+
/** 当前激活/选中的值。 */
|
|
16
|
+
value: string;
|
|
17
|
+
/** 菜单是否可见。 */
|
|
18
|
+
visible: boolean;
|
|
19
|
+
/** 菜单位置(x 坐标)。 */
|
|
20
|
+
x: number;
|
|
21
|
+
/** 菜单位置(y 坐标)。 */
|
|
22
|
+
y: number;
|
|
23
|
+
private _menuEl;
|
|
24
|
+
private _submenuOpen;
|
|
25
|
+
private static _stylesInjected;
|
|
26
|
+
private _scrollHandler;
|
|
27
|
+
private _resizeHandler;
|
|
28
|
+
/**
|
|
29
|
+
* 在指定位置显示菜单,使用给定的项。
|
|
30
|
+
* @param x - X 坐标
|
|
31
|
+
* @param y - Y 坐标
|
|
32
|
+
* @param items - 要显示的菜单项
|
|
33
|
+
*/
|
|
34
|
+
show(x: number, y: number, items?: DropdownItem[]): void;
|
|
35
|
+
/**
|
|
36
|
+
* 隐藏菜单。
|
|
37
|
+
*/
|
|
38
|
+
hide(): void;
|
|
39
|
+
/**
|
|
40
|
+
* 切换菜单可见性。
|
|
41
|
+
*/
|
|
42
|
+
toggle(x: number, y: number, items?: DropdownItem[]): void;
|
|
43
|
+
connectedCallback(): void;
|
|
44
|
+
disconnectedCallback(): void;
|
|
45
|
+
willUpdate(changedProperties: PropertyValues): void;
|
|
46
|
+
private static _injectStyles;
|
|
47
|
+
private _handleDocumentClick;
|
|
48
|
+
private _handleKeyDown;
|
|
49
|
+
private _getPortalTheme;
|
|
50
|
+
private _addScrollListener;
|
|
51
|
+
private _removeScrollListener;
|
|
52
|
+
private _createMenu;
|
|
53
|
+
private _removeMenu;
|
|
54
|
+
private _calcPosition;
|
|
55
|
+
private _renderItems;
|
|
56
|
+
private _attachItemListeners;
|
|
57
|
+
render(): import("lit").TemplateResult<1>;
|
|
58
|
+
}
|
|
59
|
+
declare global {
|
|
60
|
+
interface HTMLElementTagNameMap {
|
|
61
|
+
'mac-menu': MacMenu;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/web-components';
|
|
2
|
+
import './mac-menu';
|
|
3
|
+
declare const meta: Meta;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj;
|
|
6
|
+
export declare const Basic: Story;
|
|
7
|
+
export declare const WithActiveItem: Story;
|
|
8
|
+
export declare const Positioned: Story;
|
|
9
|
+
export declare const WithDanger: Story;
|
|
10
|
+
export declare const ProgrammaticControl: Story;
|
|
11
|
+
export declare const ThemeAdaptation: Story;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MacModal } from './mac-modal';
|