@lumen-design/checkbox 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.
- package/dist/Checkbox.svelte +55 -0
- package/dist/Checkbox.svelte.d.ts +16 -0
- package/dist/Checkbox.svelte.d.ts.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/types.d.ts +24 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/package.json +31 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Icon from '@lumen-design/icon'
|
|
3
|
+
import { Check, Minus } from 'lucide'
|
|
4
|
+
import type { Snippet } from 'svelte'
|
|
5
|
+
|
|
6
|
+
interface CheckboxProps {
|
|
7
|
+
checked?: boolean
|
|
8
|
+
value?: string | number
|
|
9
|
+
disabled?: boolean
|
|
10
|
+
indeterminate?: boolean
|
|
11
|
+
size?: 'small' | 'medium' | 'large'
|
|
12
|
+
label?: string
|
|
13
|
+
children?: Snippet
|
|
14
|
+
onchange?: (checked: boolean) => void
|
|
15
|
+
class?: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let { checked = $bindable(false), value, disabled = false, indeterminate = false, size = 'medium', label, children, onchange, class: cls = '', ...attrs }: CheckboxProps = $props()
|
|
19
|
+
|
|
20
|
+
let inputRef: HTMLInputElement | null = $state(null)
|
|
21
|
+
|
|
22
|
+
const classes = $derived(`lm-checkbox lm-checkbox--${size}${checked ? ' is-checked' : ''}${disabled ? ' is-disabled' : ''}${indeterminate ? ' is-indeterminate' : ''}${cls ? ` ${cls}` : ''}`)
|
|
23
|
+
|
|
24
|
+
const handleChange = (e: Event): void => {
|
|
25
|
+
checked = (e.currentTarget as HTMLInputElement).checked
|
|
26
|
+
onchange?.(checked)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
$effect(() => {
|
|
30
|
+
if (inputRef) inputRef.indeterminate = indeterminate
|
|
31
|
+
})
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<label class={classes}>
|
|
35
|
+
<span class="lm-checkbox__input">
|
|
36
|
+
<input bind:this={inputRef} bind:checked {...attrs} type="checkbox" class="lm-checkbox__original" {value} {disabled} onchange={handleChange} />
|
|
37
|
+
<span class="lm-checkbox__inner">
|
|
38
|
+
{#if checked}
|
|
39
|
+
<Icon icon={Check} size={12} />
|
|
40
|
+
{:else if indeterminate}
|
|
41
|
+
<Icon icon={Minus} size={12} />
|
|
42
|
+
{/if}
|
|
43
|
+
</span>
|
|
44
|
+
</span>
|
|
45
|
+
|
|
46
|
+
{#if children || label}
|
|
47
|
+
<span class="lm-checkbox__label">
|
|
48
|
+
{#if children}
|
|
49
|
+
{@render children()}
|
|
50
|
+
{:else if label}
|
|
51
|
+
{label}
|
|
52
|
+
{/if}
|
|
53
|
+
</span>
|
|
54
|
+
{/if}
|
|
55
|
+
</label>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
interface CheckboxProps {
|
|
3
|
+
checked?: boolean;
|
|
4
|
+
value?: string | number;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
indeterminate?: boolean;
|
|
7
|
+
size?: 'small' | 'medium' | 'large';
|
|
8
|
+
label?: string;
|
|
9
|
+
children?: Snippet;
|
|
10
|
+
onchange?: (checked: boolean) => void;
|
|
11
|
+
class?: string;
|
|
12
|
+
}
|
|
13
|
+
declare const Checkbox: import("svelte").Component<CheckboxProps, {}, "checked">;
|
|
14
|
+
type Checkbox = ReturnType<typeof Checkbox>;
|
|
15
|
+
export default Checkbox;
|
|
16
|
+
//# sourceMappingURL=Checkbox.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.svelte.d.ts","sourceRoot":"","sources":["Checkbox.svelte.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAGlC,UAAU,aAAa;IACnB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAA;IACnC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,KAAK,CAAC,EAAE,MAAM,CAAA;CACjB;AAgDL,QAAA,MAAM,QAAQ,0DAAwC,CAAC;AACvD,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC5C,eAAe,QAAQ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,mBAAmB,CAAA;AAExC,OAAO,EAAE,QAAQ,EAAE,CAAA;AACnB,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC1D,eAAe,QAAQ,CAAA"}
|
package/dist/index.js
ADDED
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
/** Checkbox 尺寸 */
|
|
3
|
+
export type CheckboxSize = 'small' | 'medium' | 'large';
|
|
4
|
+
/** Checkbox 属性 */
|
|
5
|
+
export interface CheckboxProps {
|
|
6
|
+
/** 是否选中 */
|
|
7
|
+
checked?: boolean;
|
|
8
|
+
/** 值 */
|
|
9
|
+
value?: string | number;
|
|
10
|
+
/** 是否禁用 */
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
/** 是否为不确定状态 */
|
|
13
|
+
indeterminate?: boolean;
|
|
14
|
+
/** 尺寸 */
|
|
15
|
+
size?: CheckboxSize;
|
|
16
|
+
/** 标签文字 */
|
|
17
|
+
label?: string;
|
|
18
|
+
/** 子内容 */
|
|
19
|
+
children?: Snippet;
|
|
20
|
+
/** 变化回调 */
|
|
21
|
+
onchange?: (checked: boolean) => void;
|
|
22
|
+
/** 自定义类名 */
|
|
23
|
+
class?: string;
|
|
24
|
+
}
|
|
@@ -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,kBAAkB;AAClB,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAA;AAEvD,kBAAkB;AAClB,MAAM,WAAW,aAAa;IAC1B,WAAW;IACX,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ;IACR,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,WAAW;IACX,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,eAAe;IACf,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,SAAS;IACT,IAAI,CAAC,EAAE,YAAY,CAAA;IACnB,WAAW;IACX,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU;IACV,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW;IACX,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,YAAY;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;CACjB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lumen-design/checkbox",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Checkbox 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
|
+
"lucide": "^0.563.0"
|
|
30
|
+
}
|
|
31
|
+
}
|