From 22a42a52eb5382ea47d0ec2a33d61f7695dfef88 Mon Sep 17 00:00:00 2001 From: MaxtuneLee Date: Fri, 29 Mar 2024 18:47:21 +0800 Subject: [PATCH 1/2] feat: select component --- docs/docs/components/universal/_meta.json | 3 +- docs/docs/components/universal/select.mdx | 71 ++++++++ .../lib/components/Input/index.ts | 14 +- .../lib/components/Select/index.scss | 87 ++++++++++ .../lib/components/Select/index.ts | 153 ++++++++++++++++++ packages/ui-universal/lib/index.ts | 1 + 6 files changed, 320 insertions(+), 9 deletions(-) create mode 100644 docs/docs/components/universal/select.mdx create mode 100644 packages/ui-universal/lib/components/Select/index.scss create mode 100644 packages/ui-universal/lib/components/Select/index.ts diff --git a/docs/docs/components/universal/_meta.json b/docs/docs/components/universal/_meta.json index 0f88905..cbdcc5e 100644 --- a/docs/docs/components/universal/_meta.json +++ b/docs/docs/components/universal/_meta.json @@ -5,5 +5,6 @@ "input", "badge", "calendar", - "card" + "card", + "select" ] \ No newline at end of file diff --git a/docs/docs/components/universal/select.mdx b/docs/docs/components/universal/select.mdx new file mode 100644 index 0000000..59c3022 --- /dev/null +++ b/docs/docs/components/universal/select.mdx @@ -0,0 +1,71 @@ +import Wraper from '../../tools/wraper/index' +import { Select } from '@sast/ui-universal' + +# Select Component + +The Select component provides a dropdown menu with selectable options. + + +
+ console.log("Selected option:", value)} + selectKey={0} + width={400} + placeHolder="Please select" + /> +
+ ); +} +``` \ No newline at end of file diff --git a/packages/ui-universal/lib/components/Input/index.ts b/packages/ui-universal/lib/components/Input/index.ts index 4624567..027a39b 100644 --- a/packages/ui-universal/lib/components/Input/index.ts +++ b/packages/ui-universal/lib/components/Input/index.ts @@ -5,6 +5,7 @@ import { ifDefined } from "lit/directives/if-defined.js"; import { createComponent } from "@lit/react"; import React from "react"; import { classMap } from "lit/directives/class-map.js"; +import { live } from "lit/directives/live.js"; export interface InputProps { /** @@ -42,11 +43,7 @@ export interface InputProps { /** * value ,the value of the input */ - value: string; - /** - * defaultValue, the defaultValue of the input - */ - defaultValue?: string; + value?: string; /** * isBorder? have the border of the input */ @@ -58,14 +55,14 @@ export class AInput extends LitElement { static styles = styles; @property({ type: Number }) width: InputProps["width"] = 250; @property({ type: Boolean }) fill: InputProps["fill"] = false; - @property({ type: Boolean }) disabled: InputProps["disabled"] = false; + @property({ type: Boolean, reflect: true }) disabled: InputProps["disabled"] = + false; @property({ type: String }) label: InputProps["label"] = "输入框"; @property({ type: String }) mode: InputProps["mode"] = "text"; @property({ type: String }) placeholder: InputProps["placeholder"]; @property({ type: Number }) fontsize: InputProps["fontsize"] = 16; @property({ type: Boolean }) isFillFather: InputProps["isFillFather"] = false; @property({ type: String }) value: InputProps["value"] = ""; - @property({ type: String }) defaultValue: InputProps["defaultValue"]; @property({ type: Boolean }) isBorder: InputProps["isBorder"] = true; @state() isFocus = false; @@ -94,6 +91,7 @@ export class AInput extends LitElement { style="width:${this.fill ? "100%" : `${this.width}px`};--input-font-size:${this.fontsize}px;" + aria-disabled="${this.disabled ? "true" : "false"}" > ${this.label ? html`