@lumen-design/button 0.0.2

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.
@@ -0,0 +1,61 @@
1
+ <script lang="ts">
2
+ import Icon from '@lumen-design/icon'
3
+ import { LoaderCircle } from 'lucide'
4
+ import type { ButtonProps } from './types'
5
+
6
+ let {
7
+ type = 'default',
8
+ size = 'medium',
9
+ disabled = false,
10
+ plain = false,
11
+ round = false,
12
+ circle = false,
13
+ loading = false,
14
+ children,
15
+ onclick,
16
+ class: cls = '',
17
+ 'aria-label': ariaLabel,
18
+ 'aria-current': ariaCurrent,
19
+ 'aria-expanded': ariaExpanded,
20
+ 'aria-haspopup': ariaHaspopup,
21
+ 'aria-controls': ariaControls,
22
+ ...attrs
23
+ }: ButtonProps = $props()
24
+
25
+ const classes = $derived(
26
+ `lm-button lm-button--${type} lm-button--${size}${disabled ? ' is-disabled' : ''}${loading ? ' is-loading' : ''}${plain ? ' is-plain' : ''}${round ? ' is-round' : ''}${circle ? ' is-circle' : ''}${cls ? ` ${cls}` : ''}`
27
+ )
28
+
29
+ const handleClick = (e: MouseEvent): void => {
30
+ if (disabled || loading) {
31
+ e.preventDefault()
32
+ e.stopPropagation()
33
+ return
34
+ }
35
+ onclick?.(e)
36
+ }
37
+ </script>
38
+
39
+ <button
40
+ {...attrs}
41
+ class={classes}
42
+ type="button"
43
+ aria-disabled={disabled || loading || undefined}
44
+ aria-label={ariaLabel}
45
+ aria-current={ariaCurrent}
46
+ aria-expanded={ariaExpanded}
47
+ aria-haspopup={ariaHaspopup}
48
+ aria-controls={ariaControls}
49
+ disabled={disabled || loading}
50
+ onclick={handleClick}
51
+ >
52
+ {#if loading}
53
+ <span class="lm-button__loading" aria-hidden="true">
54
+ <Icon icon={LoaderCircle} size={16} />
55
+ </span>
56
+ {/if}
57
+
58
+ {#if children && !loading}
59
+ {@render children()}
60
+ {/if}
61
+ </button>
@@ -0,0 +1,5 @@
1
+ import type { ButtonProps } from './types';
2
+ declare const Button: import("svelte").Component<ButtonProps, {}, "">;
3
+ type Button = ReturnType<typeof Button>;
4
+ export default Button;
5
+ //# sourceMappingURL=Button.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.svelte.d.ts","sourceRoot":"","sources":["Button.svelte.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAsD3C,QAAA,MAAM,MAAM,iDAAwC,CAAC;AACrD,KAAK,MAAM,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC;AACxC,eAAe,MAAM,CAAC"}
@@ -0,0 +1,4 @@
1
+ import Button from './Button.svelte';
2
+ export { Button };
3
+ export type { ButtonProps, ButtonSize, ButtonType } from './types';
4
+ export default Button;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAA;AAEpC,OAAO,EAAE,MAAM,EAAE,CAAA;AACjB,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAClE,eAAe,MAAM,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ import Button from './Button.svelte';
2
+ export { Button };
3
+ export default Button;
@@ -0,0 +1,42 @@
1
+ import type { Snippet } from 'svelte';
2
+ /** Button 尺寸 */
3
+ export type ButtonSize = 'small' | 'medium' | 'large';
4
+ /** Button 类型 */
5
+ export type ButtonType = 'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info';
6
+ /** Button 属性 */
7
+ export interface ButtonProps {
8
+ /** 按钮类型 */
9
+ type?: ButtonType;
10
+ /** 按钮尺寸 */
11
+ size?: ButtonSize;
12
+ /** 是否朴素按钮 */
13
+ plain?: boolean;
14
+ /** 是否圆角按钮 */
15
+ round?: boolean;
16
+ /** 是否圆形按钮 */
17
+ circle?: boolean;
18
+ /** 是否加载中 */
19
+ loading?: boolean;
20
+ /** 是否禁用 */
21
+ disabled?: boolean;
22
+ /** 图标 */
23
+ icon?: string;
24
+ /** 子内容 */
25
+ children?: Snippet;
26
+ /** 自定义类名 */
27
+ class?: string;
28
+ /** 原生样式字符串(透传到 button) */
29
+ style?: string;
30
+ /** 点击事件 */
31
+ onclick?: (event: MouseEvent) => void;
32
+ /** 无障碍标签 */
33
+ 'aria-label'?: string;
34
+ /** 当前状态(用于分页等) */
35
+ 'aria-current'?: 'page' | 'step' | 'location' | 'date' | 'time' | 'true' | 'false' | boolean;
36
+ /** 是否展开(用于可折叠区域) */
37
+ 'aria-expanded'?: boolean;
38
+ /** 弹出窗口类型 */
39
+ 'aria-haspopup'?: boolean | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog';
40
+ /** 控制的元素 ID */
41
+ 'aria-controls'?: string;
42
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAErC,gBAAgB;AAChB,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAA;AAErD,gBAAgB;AAChB,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAA;AAE1F,gBAAgB;AAChB,MAAM,WAAW,WAAW;IACxB,WAAW;IACX,IAAI,CAAC,EAAE,UAAU,CAAA;IACjB,WAAW;IACX,IAAI,CAAC,EAAE,UAAU,CAAA;IACjB,aAAa;IACb,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,aAAa;IACb,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,aAAa;IACb,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,YAAY;IACZ,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,WAAW;IACX,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS;IACT,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU;IACV,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,YAAY;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,0BAA0B;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW;IACX,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;IACrC,YAAY;IACZ,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,kBAAkB;IAClB,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAA;IAC5F,oBAAoB;IACpB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,aAAa;IACb,eAAe,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAA;IAC3E,eAAe;IACf,eAAe,CAAC,EAAE,MAAM,CAAA;CAC3B"}
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@lumen-design/button",
3
+ "version": "0.0.2",
4
+ "description": "Button component for Lumen UI",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "module": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "svelte": "./dist/index.js",
13
+ "import": "./dist/index.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "scripts": {
20
+ "build": "svelte-package -i src -o dist --types",
21
+ "build:watch": "svelte-package -i src -o dist --types -w"
22
+ },
23
+ "devDependencies": {
24
+ "@sveltejs/package": "^2.5.7",
25
+ "svelte": "5.48.2"
26
+ },
27
+ "peerDependencies": {
28
+ "svelte": "^5.0.0"
29
+ },
30
+ "dependencies": {
31
+ "lucide": "^0.563.0"
32
+ }
33
+ }