solely 0.7.0 → 0.8.0
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 +46 -4
- package/dist/compiler/index.d.ts +2 -2
- package/dist/compiler/ir/buildIR.d.ts +1 -1
- package/dist/compiler/ir/index.d.ts +1 -1
- package/dist/compiler/parser/index.d.ts +1 -1
- package/dist/compiler/parser/parser.d.ts +1 -1
- package/dist/components/commands/drawer/index.cjs +1 -1
- package/dist/components/commands/drawer/index.d.ts +1 -1
- package/dist/components/commands/drawer/index.js +1 -1
- package/dist/components/commands/drawer/style.css.cjs +1 -1
- package/dist/components/commands/drawer/style.css.js +1 -1
- package/dist/components/commands/index.d.ts +12 -12
- package/dist/components/commands/message/index.cjs +1 -1
- package/dist/components/commands/message/index.d.ts +1 -1
- package/dist/components/commands/message/index.js +1 -1
- package/dist/components/commands/message/style.css.cjs +1 -1
- package/dist/components/commands/message/style.css.js +1 -1
- package/dist/components/commands/message/types.d.ts +1 -1
- package/dist/components/commands/modal/index.cjs +1 -1
- package/dist/components/commands/modal/index.d.ts +1 -1
- package/dist/components/commands/modal/index.js +1 -1
- package/dist/components/commands/modal/style.css.cjs +1 -1
- package/dist/components/commands/modal/style.css.js +1 -1
- package/dist/components/commands/modal/types.d.ts +8 -3
- package/dist/components/commands/popconfirm/index.cjs +1 -1
- package/dist/components/commands/popconfirm/index.d.ts +1 -1
- package/dist/components/commands/popconfirm/index.js +1 -1
- package/dist/components/commands/popconfirm/style.css.cjs +1 -1
- package/dist/components/commands/popconfirm/style.css.js +1 -1
- package/dist/components/commands/popconfirm/types.d.ts +10 -3
- package/dist/components/commands/tooltip/index.cjs +1 -1
- package/dist/components/commands/tooltip/index.d.ts +1 -1
- package/dist/components/commands/tooltip/index.js +1 -1
- package/dist/components/commands/tooltip/style.css.cjs +1 -1
- package/dist/components/commands/tooltip/style.css.js +1 -1
- package/dist/components/commands/tooltip/types.d.ts +1 -3
- package/dist/components/commands/utils.cjs +1 -1
- package/dist/components/commands/utils.d.ts +11 -0
- package/dist/components/commands/utils.js +1 -1
- package/dist/components/elements/alert/index.cjs +1 -1
- package/dist/components/elements/alert/index.d.ts +68 -6
- package/dist/components/elements/alert/index.html.cjs +1 -1
- package/dist/components/elements/alert/index.html.js +1 -1
- package/dist/components/elements/alert/index.js +1 -1
- package/dist/components/elements/alert/style.css.cjs +1 -1
- package/dist/components/elements/alert/style.css.js +1 -1
- package/dist/components/elements/alert/types.d.ts +5 -1
- package/dist/components/elements/backtop/index.cjs +1 -1
- package/dist/components/elements/backtop/index.d.ts +14 -2
- package/dist/components/elements/backtop/index.html.cjs +1 -1
- package/dist/components/elements/backtop/index.html.js +1 -1
- package/dist/components/elements/backtop/index.js +1 -1
- package/dist/components/elements/backtop/style.css.cjs +1 -1
- package/dist/components/elements/backtop/style.css.js +1 -1
- package/dist/components/elements/badge/index.cjs +1 -1
- package/dist/components/elements/badge/index.d.ts +12 -6
- package/dist/components/elements/badge/index.html.cjs +1 -1
- package/dist/components/elements/badge/index.html.js +1 -1
- package/dist/components/elements/badge/index.js +1 -1
- package/dist/components/elements/badge/types.d.ts +2 -4
- package/dist/components/elements/breadcrumb/index.cjs +1 -1
- package/dist/components/elements/breadcrumb/index.d.ts +13 -3
- package/dist/components/elements/breadcrumb/index.html.cjs +1 -1
- package/dist/components/elements/breadcrumb/index.html.js +1 -1
- package/dist/components/elements/breadcrumb/index.js +1 -1
- package/dist/components/elements/breadcrumb/style.css.cjs +1 -1
- package/dist/components/elements/breadcrumb/style.css.js +1 -1
- package/dist/components/elements/breadcrumb/types.d.ts +2 -0
- package/dist/components/elements/button/index.cjs +1 -1
- package/dist/components/elements/button/index.d.ts +14 -2
- package/dist/components/elements/button/index.html.cjs +1 -1
- package/dist/components/elements/button/index.html.js +1 -1
- package/dist/components/elements/button/index.js +1 -1
- package/dist/components/elements/button/style.css.cjs +1 -1
- package/dist/components/elements/button/style.css.js +1 -1
- package/dist/components/elements/button/types.d.ts +4 -0
- package/dist/components/elements/card/index.cjs +1 -1
- package/dist/components/elements/card/index.d.ts +22 -2
- package/dist/components/elements/card/index.html.cjs +1 -1
- package/dist/components/elements/card/index.html.js +1 -1
- package/dist/components/elements/card/index.js +1 -1
- package/dist/components/elements/card/style.css.cjs +1 -1
- package/dist/components/elements/card/style.css.js +1 -1
- package/dist/components/elements/card/types.d.ts +4 -2
- package/dist/components/elements/checkbox/index.cjs +1 -1
- package/dist/components/elements/checkbox/index.d.ts +56 -3
- package/dist/components/elements/checkbox/index.html.cjs +1 -1
- package/dist/components/elements/checkbox/index.html.js +1 -1
- package/dist/components/elements/checkbox/index.js +1 -1
- package/dist/components/elements/checkbox/style.css.cjs +1 -1
- package/dist/components/elements/checkbox/style.css.js +1 -1
- package/dist/components/elements/checkbox/types.d.ts +10 -0
- package/dist/components/elements/coordinate-input/index.cjs +1 -1
- package/dist/components/elements/coordinate-input/index.d.ts +27 -2
- package/dist/components/elements/coordinate-input/index.html.cjs +1 -1
- package/dist/components/elements/coordinate-input/index.html.js +1 -1
- package/dist/components/elements/coordinate-input/index.js +1 -1
- package/dist/components/elements/coordinate-input/style.css.cjs +1 -1
- package/dist/components/elements/coordinate-input/style.css.js +1 -1
- package/dist/components/elements/coordinate-input/types.d.ts +4 -4
- package/dist/components/elements/divider/index.cjs +1 -1
- package/dist/components/elements/divider/index.d.ts +11 -2
- package/dist/components/elements/divider/index.js +1 -1
- package/dist/components/elements/empty/index.cjs +1 -1
- package/dist/components/elements/empty/index.d.ts +14 -2
- package/dist/components/elements/empty/index.html.cjs +1 -1
- package/dist/components/elements/empty/index.html.js +1 -1
- package/dist/components/elements/empty/index.js +1 -1
- package/dist/components/elements/empty/style.css.cjs +1 -1
- package/dist/components/elements/empty/style.css.js +1 -1
- package/dist/components/elements/empty/types.d.ts +4 -2
- package/dist/components/elements/fab/index.cjs +1 -1
- package/dist/components/elements/fab/index.d.ts +12 -3
- package/dist/components/elements/fab/index.html.cjs +1 -1
- package/dist/components/elements/fab/index.html.js +1 -1
- package/dist/components/elements/fab/index.js +1 -1
- package/dist/components/elements/fab/style.css.cjs +1 -1
- package/dist/components/elements/fab/style.css.js +1 -1
- package/dist/components/elements/icon/index.cjs +1 -1
- package/dist/components/elements/icon/index.d.ts +23 -2
- package/dist/components/elements/icon/index.js +1 -1
- package/dist/components/elements/icon/style.css.cjs +1 -1
- package/dist/components/elements/icon/style.css.js +1 -1
- package/dist/components/elements/index.cjs +1 -1
- package/dist/components/elements/index.d.ts +61 -60
- package/dist/components/elements/index.js +1 -1
- package/dist/components/elements/input/index.cjs +1 -1
- package/dist/components/elements/input/index.d.ts +120 -5
- package/dist/components/elements/input/index.html.cjs +1 -1
- package/dist/components/elements/input/index.html.js +1 -1
- package/dist/components/elements/input/index.js +1 -1
- package/dist/components/elements/input/style.css.cjs +1 -1
- package/dist/components/elements/input/style.css.js +1 -1
- package/dist/components/elements/input/types.d.ts +46 -7
- package/dist/components/elements/not-found/index.cjs +1 -1
- package/dist/components/elements/not-found/index.d.ts +38 -2
- package/dist/components/elements/not-found/index.html.cjs +1 -1
- package/dist/components/elements/not-found/index.html.js +1 -1
- package/dist/components/elements/not-found/index.js +1 -1
- package/dist/components/elements/not-found/style.css.cjs +1 -1
- package/dist/components/elements/not-found/style.css.js +1 -1
- package/dist/components/elements/not-found/types.d.ts +2 -0
- package/dist/components/elements/pagination/index.cjs +1 -1
- package/dist/components/elements/pagination/index.d.ts +52 -7
- package/dist/components/elements/pagination/index.html.cjs +1 -1
- package/dist/components/elements/pagination/index.html.js +1 -1
- package/dist/components/elements/pagination/index.js +1 -1
- package/dist/components/elements/pagination/style.css.cjs +1 -1
- package/dist/components/elements/pagination/style.css.js +1 -1
- package/dist/components/elements/pagination/types.d.ts +1 -1
- package/dist/components/elements/progress/index.cjs +1 -1
- package/dist/components/elements/progress/index.d.ts +16 -7
- package/dist/components/elements/progress/index.html.cjs +1 -1
- package/dist/components/elements/progress/index.html.js +1 -1
- package/dist/components/elements/progress/index.js +1 -1
- package/dist/components/elements/progress/style.css.cjs +1 -1
- package/dist/components/elements/progress/style.css.js +1 -1
- package/dist/components/elements/progress/types.d.ts +4 -2
- package/dist/components/elements/radio/index.cjs +1 -1
- package/dist/components/elements/radio/index.d.ts +82 -3
- package/dist/components/elements/radio/index.html.cjs +1 -1
- package/dist/components/elements/radio/index.html.js +1 -1
- package/dist/components/elements/radio/index.js +1 -1
- package/dist/components/elements/radio/style.css.cjs +1 -1
- package/dist/components/elements/radio/style.css.js +1 -1
- package/dist/components/elements/radio/types.d.ts +6 -0
- package/dist/components/elements/rate/index.cjs +1 -1
- package/dist/components/elements/rate/index.d.ts +75 -3
- package/dist/components/elements/rate/index.html.cjs +1 -1
- package/dist/components/elements/rate/index.html.js +1 -1
- package/dist/components/elements/rate/index.js +1 -1
- package/dist/components/elements/rate/style.css.cjs +1 -1
- package/dist/components/elements/rate/style.css.js +1 -1
- package/dist/components/elements/rate/types.d.ts +2 -0
- package/dist/components/elements/select/index.cjs +1 -1
- package/dist/components/elements/select/index.d.ts +197 -22
- package/dist/components/elements/select/index.html.cjs +1 -1
- package/dist/components/elements/select/index.html.js +1 -1
- package/dist/components/elements/select/index.js +1 -1
- package/dist/components/elements/select/option.cjs +1 -0
- package/dist/components/elements/select/option.d.ts +2 -2
- package/dist/components/elements/select/option.js +1 -0
- package/dist/components/elements/select/style.css.cjs +1 -1
- package/dist/components/elements/select/style.css.js +1 -1
- package/dist/components/elements/select/types.d.ts +42 -6
- package/dist/components/elements/skeleton/index.cjs +1 -1
- package/dist/components/elements/skeleton/index.d.ts +15 -2
- package/dist/components/elements/skeleton/index.html.cjs +1 -1
- package/dist/components/elements/skeleton/index.html.js +1 -1
- package/dist/components/elements/skeleton/index.js +1 -1
- package/dist/components/elements/skeleton/style.css.cjs +1 -1
- package/dist/components/elements/skeleton/style.css.js +1 -1
- package/dist/components/elements/skeleton/types.d.ts +2 -1
- package/dist/components/elements/slider/index.cjs +1 -1
- package/dist/components/elements/slider/index.d.ts +115 -11
- package/dist/components/elements/slider/index.html.cjs +1 -1
- package/dist/components/elements/slider/index.html.js +1 -1
- package/dist/components/elements/slider/index.js +1 -1
- package/dist/components/elements/slider/style.css.cjs +1 -1
- package/dist/components/elements/slider/style.css.js +1 -1
- package/dist/components/elements/slider/types.d.ts +15 -4
- package/dist/components/elements/steps/index.cjs +1 -1
- package/dist/components/elements/steps/index.d.ts +73 -10
- package/dist/components/elements/steps/index.html.cjs +1 -1
- package/dist/components/elements/steps/index.html.js +1 -1
- package/dist/components/elements/steps/index.js +1 -1
- package/dist/components/elements/steps/style.css.cjs +1 -1
- package/dist/components/elements/steps/style.css.js +1 -1
- package/dist/components/elements/steps/types.d.ts +9 -2
- package/dist/components/elements/switch/index.cjs +1 -1
- package/dist/components/elements/switch/index.d.ts +52 -9
- package/dist/components/elements/switch/index.html.cjs +1 -1
- package/dist/components/elements/switch/index.html.js +1 -1
- package/dist/components/elements/switch/index.js +1 -1
- package/dist/components/elements/switch/types.d.ts +12 -0
- package/dist/components/elements/table/index.cjs +1 -1
- package/dist/components/elements/table/index.d.ts +251 -4
- package/dist/components/elements/table/index.html.cjs +1 -1
- package/dist/components/elements/table/index.html.js +1 -1
- package/dist/components/elements/table/index.js +1 -1
- package/dist/components/elements/table/style.css.cjs +1 -1
- package/dist/components/elements/table/style.css.js +1 -1
- package/dist/components/elements/table/types.d.ts +152 -7
- package/dist/components/elements/tabs/index.cjs +1 -1
- package/dist/components/elements/tabs/index.d.ts +47 -4
- package/dist/components/elements/tabs/index.html.cjs +1 -1
- package/dist/components/elements/tabs/index.html.js +1 -1
- package/dist/components/elements/tabs/index.js +1 -1
- package/dist/components/elements/tabs/style.css.cjs +1 -1
- package/dist/components/elements/tabs/style.css.js +1 -1
- package/dist/components/elements/tabs/types.d.ts +10 -0
- package/dist/components/elements/tag/index.cjs +1 -1
- package/dist/components/elements/tag/index.d.ts +11 -3
- package/dist/components/elements/tag/index.html.cjs +1 -1
- package/dist/components/elements/tag/index.html.js +1 -1
- package/dist/components/elements/tag/index.js +1 -1
- package/dist/components/elements/tag/style.css.cjs +1 -1
- package/dist/components/elements/tag/style.css.js +1 -1
- package/dist/components/elements/timeline/index.cjs +1 -1
- package/dist/components/elements/timeline/index.d.ts +8 -2
- package/dist/components/elements/timeline/index.js +1 -1
- package/dist/components/elements/timeline/style.css.cjs +1 -1
- package/dist/components/elements/timeline/style.css.js +1 -1
- package/dist/components/elements/timeline/types.d.ts +0 -1
- package/dist/components/elements/tooltip/index.cjs +1 -1
- package/dist/components/elements/tooltip/index.d.ts +78 -5
- package/dist/components/elements/tooltip/index.html.cjs +1 -1
- package/dist/components/elements/tooltip/index.html.js +1 -1
- package/dist/components/elements/tooltip/index.js +1 -1
- package/dist/components/elements/tooltip/style.css.cjs +1 -1
- package/dist/components/elements/tooltip/style.css.js +1 -1
- package/dist/components/elements/tooltip/types.d.ts +1 -1
- package/dist/components/elements/tree/index.cjs +1 -1
- package/dist/components/elements/tree/index.d.ts +163 -13
- package/dist/components/elements/tree/index.html.cjs +1 -1
- package/dist/components/elements/tree/index.html.js +1 -1
- package/dist/components/elements/tree/index.js +1 -1
- package/dist/components/elements/tree/style.css.cjs +1 -1
- package/dist/components/elements/tree/style.css.js +1 -1
- package/dist/components/elements/tree/types.d.ts +18 -4
- package/dist/components/elements/upload/index.cjs +1 -1
- package/dist/components/elements/upload/index.d.ts +59 -8
- package/dist/components/elements/upload/index.html.cjs +1 -1
- package/dist/components/elements/upload/index.html.js +1 -1
- package/dist/components/elements/upload/index.js +1 -1
- package/dist/components/elements/upload/style.css.cjs +1 -1
- package/dist/components/elements/upload/style.css.js +1 -1
- package/dist/components/elements/upload/types.d.ts +89 -5
- package/dist/components/elements/utils/helpers.cjs +1 -1
- package/dist/components/elements/utils/helpers.d.ts +10 -0
- package/dist/components/elements/utils/helpers.js +1 -1
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +3 -21
- package/dist/components/index.js +1 -1
- package/dist/components/theme/auto-inject.cjs +1 -0
- package/dist/components/theme/auto-inject.d.ts +23 -0
- package/dist/components/theme/auto-inject.js +1 -0
- package/dist/components/theme/index.cjs +1 -1
- package/dist/components/theme/index.d.ts +7 -1
- package/dist/components/theme/index.js +1 -1
- package/dist/components/theme/variables.css +25 -0
- package/dist/components/theme/variables.css.cjs +1 -0
- package/dist/components/theme/variables.css.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1 -1
- package/dist/plugin.d.ts +2 -2
- package/dist/plugins/index.d.ts +2 -2
- package/dist/plugins/solely-vite-plugin.d.ts +1 -1
- package/dist/router/core.cjs +1 -1
- package/dist/router/core.d.ts +31 -1
- package/dist/router/core.js +1 -1
- package/dist/router/index.d.ts +4 -4
- package/dist/router/router-link.d.ts +1 -1
- package/dist/router/router-view.cjs +1 -1
- package/dist/router/router-view.d.ts +12 -2
- package/dist/router/router-view.js +1 -1
- package/dist/router/types.d.ts +3 -1
- package/dist/runtime/component/base-element.cjs +1 -1
- package/dist/runtime/component/base-element.d.ts +7 -0
- package/dist/runtime/component/base-element.js +1 -1
- package/dist/runtime/component/decorators.d.ts +7 -2
- package/dist/runtime/component/index.d.ts +2 -2
- package/dist/runtime/index.d.ts +3 -3
- package/dist/runtime/reactivity/computed.d.ts +1 -1
- package/dist/runtime/reactivity/index.d.ts +6 -6
- package/dist/runtime/reactivity/watch.d.ts +1 -1
- package/dist/runtime/renderer/index.d.ts +2 -2
- package/dist/runtime/renderer/renderIR.cjs +1 -1
- package/dist/runtime/renderer/renderIR.d.ts +1 -1
- package/dist/runtime/renderer/renderIR.js +1 -1
- package/dist/shared/aria.cjs +1 -0
- package/dist/shared/aria.d.ts +67 -0
- package/dist/shared/aria.js +1 -0
- package/dist/shared/boolean.cjs +1 -0
- package/dist/shared/boolean.d.ts +9 -0
- package/dist/shared/boolean.js +1 -0
- package/dist/shared/enum.cjs +1 -0
- package/dist/shared/enum.d.ts +10 -0
- package/dist/shared/enum.js +1 -0
- package/dist/shared/env.cjs +1 -1
- package/dist/shared/env.js +1 -1
- package/dist/shared/floating/overlay-stack.cjs +1 -0
- package/dist/shared/floating/overlay-stack.d.ts +56 -0
- package/dist/shared/floating/overlay-stack.js +1 -0
- package/dist/shared/floating/position.cjs +1 -0
- package/dist/shared/floating/position.d.ts +32 -0
- package/dist/shared/floating/position.js +1 -0
- package/dist/shared/floating/types.d.ts +112 -0
- package/dist/shared/form-associated.cjs +1 -0
- package/dist/shared/form-associated.d.ts +253 -0
- package/dist/shared/form-associated.js +1 -0
- package/dist/shared/gen-function.d.ts +1 -1
- package/dist/shared/icons.cjs +1 -0
- package/dist/shared/icons.d.ts +31 -0
- package/dist/shared/icons.js +1 -0
- package/dist/shared/index.cjs +1 -1
- package/dist/shared/index.d.ts +11 -9
- package/dist/shared/index.js +1 -1
- package/dist/shared/size.cjs +1 -0
- package/dist/shared/size.d.ts +17 -0
- package/dist/shared/size.js +1 -0
- package/dist/shared/templateError.d.ts +1 -1
- package/dist/types/index.d.ts +4 -4
- package/dist/types/ir.d.ts +1 -1
- package/package.json +27 -11
- package/dist/solely.svg +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./style.css.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./style.css.cjs"),e=require("./index.html.cjs"),a=require("../../../runtime/component/base-element.cjs"),r=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelyRate=class extends a.default{dragging=!1;dragValue;suppressClick=!1;clearSuppressTimer;getRateClasses(){return{"is-disabled":!!this.$data.disabled,"is-readonly":!!this.$data.readonly}}get value(){return this.$data.value||0}set value(t){(this.isSyncingProps||!this.$data.disabled&&!this.$data.readonly)&&this.setValue(t)}resolveCount(){const t=Number(this.$data.count??5);return Number.isFinite(t)?Math.max(0,Math.floor(t)):5}resolveValue(){const t=Number(this.$data.value??0),e=this.resolveCount();return Number.isFinite(t)?Math.max(0,Math.min(e,t)):0}clampValue(){const t=Number(this.$data.value??0);if(!Number.isFinite(t))return void(this.$data.value=0);const e=Math.max(0,Math.min(this.resolveCount(),t));e!==t&&(this.$data.value=e)}getStarTabindex(t){if(this.$data.disabled)return"-1";const e=this.resolveCount();if(0===e)return"-1";const a=this.resolveValue();return t===Math.min(e,Math.max(1,Math.ceil(a)))?"0":"-1"}getStarAriaChecked(t){const e=this.resolveValue();return e<=0?"false":t===Math.ceil(e)?"true":"false"}getTooltip(t){const e=this.$data.tooltips;if(!e)return`${t} 分`;let a=[];const r=e.trim();if(r.startsWith("["))try{const t=JSON.parse(r);a=Array.isArray(t)?t.map(t=>String(t)):[]}catch{a=[]}else a=r.split(",").map(t=>t.trim());return a[t-1]||`${t} 分`}getStarClasses(t){const e=this.$data.hoverValue,a=this.resolveValue(),r=void 0!==e?e:a;return{"rate__star--full":t<=r,"rate__star--half":!!this.$data.allowHalf&&t-.5===r,"rate__star--zero":t>r}}mounted(){this.dragging=!1,this.dragValue=void 0,this.clampValue(),this.refresh(),this.$data.hoverValue=void 0,this.generateStarCount()}unmounted(){this.dragging=!1,this.dragValue=void 0,this.clearSuppressTimer&&(clearTimeout(this.clearSuppressTimer),this.clearSuppressTimer=void 0),this.suppressClick=!1}updated(){this.updateAriaAttributes(),(this.$data.starCount||[]).length!==this.resolveCount()&&this.generateStarCount()}updateAriaAttributes(){const t=this.shadowRoot?.querySelector(".rate");t&&(t.removeAttribute("aria-valuenow"),t.removeAttribute("aria-valuemin"),t.removeAttribute("aria-valuemax"),t.setAttribute("aria-disabled",this.$data.disabled?"true":"false"),t.setAttribute("aria-readonly",this.$data.readonly?"true":"false"))}generateStarCount(){this.$data.starCount=Array.from({length:this.resolveCount()},(t,e)=>e+1),this.clampValue()}resolvePointerValue(t,e){if(!this.$data.allowHalf)return t;const a=e.currentTarget,r=a?.getBoundingClientRect(),s=r?.width||a?.offsetWidth||0;if(!r||s<=0)return t;const i=e.clientX-r.left;return Number.isFinite(i)&&i/s<.5?t-.5:t}resolveDragValue(t){const e=Array.from(this.shadowRoot?.querySelectorAll(".rate__star")||[]),a=e.length;if(0===a)return;const r=e.map(t=>t.getBoundingClientRect());if(r.every(t=>!t.width))return;const s=t.clientX;if(!Number.isFinite(s))return;if(s<=r[0].left)return 0;if(s>=r[a-1].right)return a;let i=a,l=r[a-1];for(let o=0;o<a;o++)if(s<=r[o].right){i=o+1,l=r[o];break}return l.width&&this.$data.allowHalf&&(s-l.left)/l.width<.5?Math.max(.5,i-.5):i}handlePointerDown(t){if(this.$data.disabled||this.$data.readonly||0!==t.button)return;const e=this.resolveDragValue(t);void 0!==e&&(this.capturePointer(t,!0),this.dragging=!0,this.dragValue=e,this.$data.hoverValue=e)}handlePointerMove(t){if(!this.dragging||this.$data.disabled||this.$data.readonly)return;const e=this.resolveDragValue(t);void 0!==e&&e!==this.dragValue&&(this.dragValue=e,this.$data.hoverValue=e)}handlePointerUp(t){this.dragging&&this.finishDrag(t,this.resolveDragValue(t)??this.dragValue,!0)}handlePointerCancel(t){this.dragging&&this.finishDrag(t,void 0,!1)}capturePointer(t,e){const a=t.currentTarget,r=t.pointerId;if(a&&"number"==typeof r)try{e?a.setPointerCapture?.(r):a.hasPointerCapture?.(r)&&a.releasePointerCapture?.(r)}catch{}}finishDrag(t,e,a){if(this.dragging=!1,this.dragValue=void 0,this.capturePointer(t,!1),this.suppressClick=!0,this.clearSuppressTimer&&clearTimeout(this.clearSuppressTimer),this.clearSuppressTimer=setTimeout(()=>{this.suppressClick=!1,this.clearSuppressTimer=void 0},0),a&&void 0!==e){const t=this.$data.allowHalf?.5:1;let a=e<=0?this.$data.allowClear?0:t:e;return a=Math.max(0,Math.min(this.resolveCount(),a)),this.$data.allowClear&&a===this.$data.value&&(a=0),this.$data.hoverValue=void 0,void(a!==this.$data.value&&(this.$data.value=a,this.dispatchChangeEvent()))}this.$data.hoverValue=void 0}handleClick(t,e){if(this.suppressClick)return void(this.suppressClick=!1);if(this.$data.disabled||this.$data.readonly)return;let a=e?this.resolvePointerValue(t,e):t;!e&&this.$data.allowHalf&&(a=this.$data.hoverValue??t),this.$data.allowClear&&a===this.$data.value&&(a=0),this.$data.hoverValue=void 0,a!==this.$data.value&&(this.$data.value=a,this.dispatchChangeEvent())}handleMouseEnter(t){this.dragging||this.$data.disabled||this.$data.readonly||(this.$data.hoverValue=t)}handleMouseMove(t,e){this.dragging||this.$data.disabled||this.$data.readonly||(this.$data.hoverValue=this.resolvePointerValue(t,e))}handleMouseLeave(){this.dragging||this.$data.disabled||this.$data.readonly||(this.$data.hoverValue=void 0)}handleKeyDown(t){if(this.$data.disabled||this.$data.readonly)return;const e=this.resolveCount();if(0===e)return;const a=this.resolveValue(),r=this.$data.allowHalf?.5:1;let s;switch(t.key){case"ArrowRight":case"ArrowUp":s=Math.min(e,a+r);break;case"ArrowLeft":case"ArrowDown":s=Math.max(0,a-r);break;case"Home":s=this.$data.allowClear?0:Math.min(1,e);break;case"End":s=e;break;case"Enter":case" ":case"Spacebar":{const a=Number(t.target?.dataset?.index);if(!a)return;s=Math.min(e,a);break}default:return}t.preventDefault(),s!==this.$data.value&&(this.$data.value=s,this.$data.hoverValue=void 0,this.dispatchChangeEvent(),this.focusStar(s))}focusStar(t){const e=this.resolveCount();if(0===e)return;const a=Math.min(e,Math.max(1,Math.ceil(t))),r=Array.from(this.shadowRoot?.querySelectorAll(".rate__star")||[]);r[a-1]?.focus()}dispatchChangeEvent(){this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}setValue(t){const e=Number(t);Number.isFinite(e)?this.$data.value=Math.max(0,Math.min(this.resolveCount(),e)):this.$data.value=0}getValue(){return this.$data.value}},exports.SolelyRate=((t,e)=>{for(var a,r=e,s=t.length-1;s>=0;s--)(a=t[s])&&(r=a(r)||r);return r})([r.CustomElement({tagName:"solely-rate",template:e.__SOLELY_IR__,styles:t.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"value",type:"number",default:0},{name:"count",type:"number",default:5},{name:"allowHalf",type:"boolean",default:!1},{name:"disabled",type:"boolean",default:!1},{name:"allowClear",type:"boolean",default:!1},{name:"character",type:"string",default:"★"},{name:"readonly",type:"boolean",default:!1},{name:"tooltips",type:"string"}]})],exports.SolelyRate);
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import { BaseElement } from '../../../runtime/component';
|
|
2
|
-
import { RateProps } from './types';
|
|
1
|
+
import { BaseElement } from '../../../runtime/component/index.js';
|
|
2
|
+
import { RateProps } from './types.js';
|
|
3
3
|
declare class SolelyRate extends BaseElement<RateProps & {
|
|
4
4
|
hoverValue: number | undefined;
|
|
5
5
|
starCount: number[];
|
|
6
6
|
}> {
|
|
7
|
+
/** 是否处于按住拖动中(纯内部交互状态,不参与响应式数据) */
|
|
8
|
+
private dragging;
|
|
9
|
+
/** 拖动过程中的最新预览值 */
|
|
10
|
+
private dragValue?;
|
|
11
|
+
/** 拖动结束后紧随其后的 click 需吞掉,避免重复提交或误触发 allowClear */
|
|
12
|
+
private suppressClick;
|
|
13
|
+
private clearSuppressTimer?;
|
|
7
14
|
/**
|
|
8
15
|
* 获取 rate class 对象
|
|
9
16
|
*/
|
|
@@ -13,30 +20,95 @@ declare class SolelyRate extends BaseElement<RateProps & {
|
|
|
13
20
|
*/
|
|
14
21
|
get value(): number;
|
|
15
22
|
set value(newValue: number);
|
|
23
|
+
/**
|
|
24
|
+
* 归一化星星总数:负数 / 非数字 / 小数都收敛为非负整数
|
|
25
|
+
*/
|
|
26
|
+
private resolveCount;
|
|
27
|
+
/**
|
|
28
|
+
* 归一化当前评分:裁剪到 [0, count],避免 value > count 时视觉与 ARIA 不一致
|
|
29
|
+
*/
|
|
30
|
+
private resolveValue;
|
|
31
|
+
/**
|
|
32
|
+
* 把实际存储的分值收敛到 [0, count]。
|
|
33
|
+
* 之前只在渲染时用 resolveValue 裁剪,`value` / `getValue()` 仍会返回越界值,
|
|
34
|
+
* 与视觉、ARIA 不一致;这里统一落库,保证 API 读取与展示同源。
|
|
35
|
+
*/
|
|
36
|
+
private clampValue;
|
|
37
|
+
/**
|
|
38
|
+
* roving tabindex:只有对应当前评分的星(向上取整)进入 Tab 序列
|
|
39
|
+
* 禁用时整组移出 Tab 序列(原生禁用 radio 不可聚焦)
|
|
40
|
+
*/
|
|
41
|
+
getStarTabindex(i: number): string;
|
|
42
|
+
/**
|
|
43
|
+
* 星星的 aria-checked(半星向上取整归到对应整星;0 分时无选中项)
|
|
44
|
+
*/
|
|
45
|
+
getStarAriaChecked(i: number): string;
|
|
46
|
+
/**
|
|
47
|
+
* 每颗星的提示文案
|
|
48
|
+
*/
|
|
49
|
+
getTooltip(i: number): string;
|
|
16
50
|
/**
|
|
17
51
|
* 获取 star class 对象
|
|
18
52
|
*/
|
|
19
53
|
getStarClasses(i: number): Record<string, boolean>;
|
|
20
54
|
mounted(): void;
|
|
55
|
+
unmounted(): void;
|
|
21
56
|
updated(): void;
|
|
22
57
|
private updateAriaAttributes;
|
|
23
58
|
/**
|
|
24
59
|
* 生成星星数量数组
|
|
25
60
|
*/
|
|
26
61
|
generateStarCount(): void;
|
|
62
|
+
/**
|
|
63
|
+
* 指针所在的评分值(allowHalf 时左半边为半星)
|
|
64
|
+
*/
|
|
65
|
+
private resolvePointerValue;
|
|
66
|
+
/**
|
|
67
|
+
* 容器级指针位置 → 评分值:跨星连续取值,口径与点击一致(allowHalf 下左半边为半星)
|
|
68
|
+
* 拿不到布局信息(如非布局环境)时返回 undefined,回退到点击逻辑。
|
|
69
|
+
*/
|
|
70
|
+
private resolveDragValue;
|
|
71
|
+
/**
|
|
72
|
+
* 按下开始拖动:预览当前位置分值,并捕获指针以支持拖出组件范围
|
|
73
|
+
*/
|
|
74
|
+
handlePointerDown(event: PointerEvent): void;
|
|
75
|
+
/**
|
|
76
|
+
* 拖动中:按指针位置连续预览
|
|
77
|
+
*/
|
|
78
|
+
handlePointerMove(event: PointerEvent): void;
|
|
79
|
+
/**
|
|
80
|
+
* 松开:提交最终分值(只派发一次 change)
|
|
81
|
+
*/
|
|
82
|
+
handlePointerUp(event: PointerEvent): void;
|
|
83
|
+
/**
|
|
84
|
+
* 指针取消:撤销预览,不提交
|
|
85
|
+
*/
|
|
86
|
+
handlePointerCancel(event: PointerEvent): void;
|
|
87
|
+
/** 捕获 / 释放指针,保证拖出组件后仍能收到 move / up */
|
|
88
|
+
private capturePointer;
|
|
89
|
+
/** 结束拖动:清状态、撤销预览、按需提交 */
|
|
90
|
+
private finishDrag;
|
|
27
91
|
/**
|
|
28
92
|
* 点击评分
|
|
29
93
|
*/
|
|
30
|
-
handleClick(index: number): void;
|
|
94
|
+
handleClick(index: number, event?: MouseEvent): void;
|
|
31
95
|
/**
|
|
32
96
|
* 鼠标进入
|
|
33
97
|
*/
|
|
34
98
|
handleMouseEnter(index: number): void;
|
|
99
|
+
/**
|
|
100
|
+
* 鼠标移动(allowHalf 时按指针在星内的左右半边高亮半星 / 整星)
|
|
101
|
+
*/
|
|
102
|
+
handleMouseMove(index: number, event: MouseEvent): void;
|
|
35
103
|
/**
|
|
36
104
|
* 鼠标离开
|
|
37
105
|
*/
|
|
38
106
|
handleMouseLeave(): void;
|
|
39
107
|
handleKeyDown(event: KeyboardEvent): void;
|
|
108
|
+
/**
|
|
109
|
+
* 把焦点移到当前评分对应的星
|
|
110
|
+
*/
|
|
111
|
+
private focusStar;
|
|
40
112
|
private dispatchChangeEvent;
|
|
41
113
|
/**
|
|
42
114
|
* 设置评分值
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t={t:"root",v:"1.2.0",fns:[function(t){const{$data:a}=this;return this.getRateClasses()},function(t){const{$data:a}=this;return"评分,当前 "+(a.value||0)+" 分"},function(t){const{$data:a}=this;return a.disabled?"true":"false"},function(t){const{$data:a}=this;return a.readonly?"true":"false"},function(t,a){const{$data:e}=this,{value:n,checked:i}=t?.target||{};this.handleKeyDown(t)},function(t,a){const{$data:e}=this,{value:n,checked:i}=t?.target||{};this.handlePointerDown(t)},function(t,a){const{$data:e}=this,{value:n,checked:i}=t?.target||{};this.handlePointerMove(t)},function(t,a){const{$data:e}=this,{value:n,checked:i}=t?.target||{};this.handlePointerUp(t)},function(t,a){const{$data:e}=this,{value:n,checked:i}=t?.target||{};this.handlePointerCancel(t)},function(t,a){const{$data:e}=this,{value:n,checked:i}=t?.target||{};this.handleMouseLeave()},function(t){const{$data:a}=this;return a.starCount},function(t){const{$data:a}=this;var[e]=t.map(t=>t.itmVal),[n]=t.map(t=>t.idxVal);return this.getStarClasses(e)},function(t){const{$data:a}=this;var[e]=t.map(t=>t.itmVal),[n]=t.map(t=>t.idxVal);return a.character||"★"},function(t){const{$data:a}=this;var[e]=t.map(t=>t.itmVal),[n]=t.map(t=>t.idxVal);return e},function(t){const{$data:a}=this;var[e]=t.map(t=>t.itmVal),[n]=t.map(t=>t.idxVal);return this.getTooltip(e)},function(t){const{$data:a}=this;var[e]=t.map(t=>t.itmVal),[n]=t.map(t=>t.idxVal);return this.getStarAriaChecked(e)},function(t){const{$data:a}=this;var[e]=t.map(t=>t.itmVal),[n]=t.map(t=>t.idxVal);return this.getStarTabindex(e)},function(t,a){const{$data:e}=this,{value:n,checked:i}=t?.target||{};var[d]=a.map(t=>t.itmVal),[s]=a.map(t=>t.idxVal);this.handleClick(d,t)},function(t,a){const{$data:e}=this,{value:n,checked:i}=t?.target||{};var[d]=a.map(t=>t.itmVal),[s]=a.map(t=>t.idxVal);this.handleMouseEnter(d)},function(t,a){const{$data:e}=this,{value:n,checked:i}=t?.target||{};var[d]=a.map(t=>t.itmVal),[s]=a.map(t=>t.idxVal);this.handleMouseMove(d,t)},function(t){const{$data:a}=this;var[e]=t.map(t=>t.itmVal),[n]=t.map(t=>t.idxVal);return`${a.character||"★"}`}],n:[{t:0,d:1,g:"div",a:[{k:"part",v:"base",d:0},{k:"class",v:"rate",d:0},{k:":class",f:1,d:1},{k:"role",v:"radiogroup",d:0},{k:":aria-label",f:2,d:1},{k:":aria-disabled",f:3,d:1},{k:":aria-readonly",f:4,d:1},{k:"@keydown",f:5,d:1},{k:"@pointerdown",f:6,d:1},{k:"@pointermove",f:7,d:1},{k:"@pointerup",f:8,d:1},{k:"@pointercancel",f:9,d:1},{k:"@mouseleave",f:10,d:1}],c:[{t:6,d:1,f:11,i:"i",n:"index",a:[],c:[{t:0,d:1,g:"span",a:[{k:"part",v:"star",d:0},{k:"class",v:"rate__star",d:0},{k:":class",f:12,d:1},{k:":data-char",f:13,d:1},{k:":data-index",f:14,d:1},{k:":title",f:15,d:1},{k:"role",v:"radio",d:0},{k:":aria-checked",f:16,d:1},{k:":aria-label",f:15,d:1},{k:":tabindex",f:17,d:1},{k:"@click",f:18,d:1},{k:"@mouseenter",f:19,d:1},{k:"@mousemove",f:20,d:1}],c:[{t:1,d:1,f:21}]}]}]}],s:{tf:21,cf:21,dn:1,tn:1,sn:0}};exports.__SOLELY_IR__=t,exports.default=t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const t={t:"root",v:"1.2.0",fns:[function(t){const{$data:a}=this;return this.getRateClasses()},function(t){const{$data:a}=this;return"评分,当前 "+(a.value||0)+" 分"},function(t){const{$data:a}=this;return a.disabled?"true":"false"},function(t){const{$data:a}=this;return a.readonly?"true":"false"},function(t,a){const{$data:e}=this,{value:n,checked:i}=t?.target||{};this.handleKeyDown(t)},function(t,a){const{$data:e}=this,{value:n,checked:i}=t?.target||{};this.handlePointerDown(t)},function(t,a){const{$data:e}=this,{value:n,checked:i}=t?.target||{};this.handlePointerMove(t)},function(t,a){const{$data:e}=this,{value:n,checked:i}=t?.target||{};this.handlePointerUp(t)},function(t,a){const{$data:e}=this,{value:n,checked:i}=t?.target||{};this.handlePointerCancel(t)},function(t,a){const{$data:e}=this,{value:n,checked:i}=t?.target||{};this.handleMouseLeave()},function(t){const{$data:a}=this;return a.starCount},function(t){const{$data:a}=this;var[e]=t.map(t=>t.itmVal),[n]=t.map(t=>t.idxVal);return this.getStarClasses(e)},function(t){const{$data:a}=this;var[e]=t.map(t=>t.itmVal),[n]=t.map(t=>t.idxVal);return a.character||"★"},function(t){const{$data:a}=this;var[e]=t.map(t=>t.itmVal),[n]=t.map(t=>t.idxVal);return e},function(t){const{$data:a}=this;var[e]=t.map(t=>t.itmVal),[n]=t.map(t=>t.idxVal);return this.getTooltip(e)},function(t){const{$data:a}=this;var[e]=t.map(t=>t.itmVal),[n]=t.map(t=>t.idxVal);return this.getStarAriaChecked(e)},function(t){const{$data:a}=this;var[e]=t.map(t=>t.itmVal),[n]=t.map(t=>t.idxVal);return this.getStarTabindex(e)},function(t,a){const{$data:e}=this,{value:n,checked:i}=t?.target||{};var[d]=a.map(t=>t.itmVal),[s]=a.map(t=>t.idxVal);this.handleClick(d,t)},function(t,a){const{$data:e}=this,{value:n,checked:i}=t?.target||{};var[d]=a.map(t=>t.itmVal),[s]=a.map(t=>t.idxVal);this.handleMouseEnter(d)},function(t,a){const{$data:e}=this,{value:n,checked:i}=t?.target||{};var[d]=a.map(t=>t.itmVal),[s]=a.map(t=>t.idxVal);this.handleMouseMove(d,t)},function(t){const{$data:a}=this;var[e]=t.map(t=>t.itmVal),[n]=t.map(t=>t.idxVal);return`${a.character||"★"}`}],n:[{t:0,d:1,g:"div",a:[{k:"part",v:"base",d:0},{k:"class",v:"rate",d:0},{k:":class",f:1,d:1},{k:"role",v:"radiogroup",d:0},{k:":aria-label",f:2,d:1},{k:":aria-disabled",f:3,d:1},{k:":aria-readonly",f:4,d:1},{k:"@keydown",f:5,d:1},{k:"@pointerdown",f:6,d:1},{k:"@pointermove",f:7,d:1},{k:"@pointerup",f:8,d:1},{k:"@pointercancel",f:9,d:1},{k:"@mouseleave",f:10,d:1}],c:[{t:6,d:1,f:11,i:"i",n:"index",a:[],c:[{t:0,d:1,g:"span",a:[{k:"part",v:"star",d:0},{k:"class",v:"rate__star",d:0},{k:":class",f:12,d:1},{k:":data-char",f:13,d:1},{k:":data-index",f:14,d:1},{k:":title",f:15,d:1},{k:"role",v:"radio",d:0},{k:":aria-checked",f:16,d:1},{k:":aria-label",f:15,d:1},{k:":tabindex",f:17,d:1},{k:"@click",f:18,d:1},{k:"@mouseenter",f:19,d:1},{k:"@mousemove",f:20,d:1}],c:[{t:1,d:1,f:21}]}]}]}],s:{tf:21,cf:21,dn:1,tn:1,sn:0}};export{t as __SOLELY_IR__,t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"./style.css.js";import{__SOLELY_IR__ as
|
|
1
|
+
import t from"./style.css.js";import{__SOLELY_IR__ as e}from"./index.html.js";import a from"../../../runtime/component/base-element.js";import{CustomElement as r}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let i=class extends a{dragging=!1;dragValue;suppressClick=!1;clearSuppressTimer;getRateClasses(){return{"is-disabled":!!this.$data.disabled,"is-readonly":!!this.$data.readonly}}get value(){return this.$data.value||0}set value(t){(this.isSyncingProps||!this.$data.disabled&&!this.$data.readonly)&&this.setValue(t)}resolveCount(){const t=Number(this.$data.count??5);return Number.isFinite(t)?Math.max(0,Math.floor(t)):5}resolveValue(){const t=Number(this.$data.value??0),e=this.resolveCount();return Number.isFinite(t)?Math.max(0,Math.min(e,t)):0}clampValue(){const t=Number(this.$data.value??0);if(!Number.isFinite(t))return void(this.$data.value=0);const e=Math.max(0,Math.min(this.resolveCount(),t));e!==t&&(this.$data.value=e)}getStarTabindex(t){if(this.$data.disabled)return"-1";const e=this.resolveCount();if(0===e)return"-1";const a=this.resolveValue();return t===Math.min(e,Math.max(1,Math.ceil(a)))?"0":"-1"}getStarAriaChecked(t){const e=this.resolveValue();return e<=0?"false":t===Math.ceil(e)?"true":"false"}getTooltip(t){const e=this.$data.tooltips;if(!e)return`${t} 分`;let a=[];const r=e.trim();if(r.startsWith("["))try{const t=JSON.parse(r);a=Array.isArray(t)?t.map(t=>String(t)):[]}catch{a=[]}else a=r.split(",").map(t=>t.trim());return a[t-1]||`${t} 分`}getStarClasses(t){const e=this.$data.hoverValue,a=this.resolveValue(),r=void 0!==e?e:a;return{"rate__star--full":t<=r,"rate__star--half":!!this.$data.allowHalf&&t-.5===r,"rate__star--zero":t>r}}mounted(){this.dragging=!1,this.dragValue=void 0,this.clampValue(),this.refresh(),this.$data.hoverValue=void 0,this.generateStarCount()}unmounted(){this.dragging=!1,this.dragValue=void 0,this.clearSuppressTimer&&(clearTimeout(this.clearSuppressTimer),this.clearSuppressTimer=void 0),this.suppressClick=!1}updated(){this.updateAriaAttributes(),(this.$data.starCount||[]).length!==this.resolveCount()&&this.generateStarCount()}updateAriaAttributes(){const t=this.shadowRoot?.querySelector(".rate");t&&(t.removeAttribute("aria-valuenow"),t.removeAttribute("aria-valuemin"),t.removeAttribute("aria-valuemax"),t.setAttribute("aria-disabled",this.$data.disabled?"true":"false"),t.setAttribute("aria-readonly",this.$data.readonly?"true":"false"))}generateStarCount(){this.$data.starCount=Array.from({length:this.resolveCount()},(t,e)=>e+1),this.clampValue()}resolvePointerValue(t,e){if(!this.$data.allowHalf)return t;const a=e.currentTarget,r=a?.getBoundingClientRect(),i=r?.width||a?.offsetWidth||0;if(!r||i<=0)return t;const s=e.clientX-r.left;return Number.isFinite(s)&&s/i<.5?t-.5:t}resolveDragValue(t){const e=Array.from(this.shadowRoot?.querySelectorAll(".rate__star")||[]),a=e.length;if(0===a)return;const r=e.map(t=>t.getBoundingClientRect());if(r.every(t=>!t.width))return;const i=t.clientX;if(!Number.isFinite(i))return;if(i<=r[0].left)return 0;if(i>=r[a-1].right)return a;let s=a,l=r[a-1];for(let o=0;o<a;o++)if(i<=r[o].right){s=o+1,l=r[o];break}return l.width&&this.$data.allowHalf&&(i-l.left)/l.width<.5?Math.max(.5,s-.5):s}handlePointerDown(t){if(this.$data.disabled||this.$data.readonly||0!==t.button)return;const e=this.resolveDragValue(t);void 0!==e&&(this.capturePointer(t,!0),this.dragging=!0,this.dragValue=e,this.$data.hoverValue=e)}handlePointerMove(t){if(!this.dragging||this.$data.disabled||this.$data.readonly)return;const e=this.resolveDragValue(t);void 0!==e&&e!==this.dragValue&&(this.dragValue=e,this.$data.hoverValue=e)}handlePointerUp(t){this.dragging&&this.finishDrag(t,this.resolveDragValue(t)??this.dragValue,!0)}handlePointerCancel(t){this.dragging&&this.finishDrag(t,void 0,!1)}capturePointer(t,e){const a=t.currentTarget,r=t.pointerId;if(a&&"number"==typeof r)try{e?a.setPointerCapture?.(r):a.hasPointerCapture?.(r)&&a.releasePointerCapture?.(r)}catch{}}finishDrag(t,e,a){if(this.dragging=!1,this.dragValue=void 0,this.capturePointer(t,!1),this.suppressClick=!0,this.clearSuppressTimer&&clearTimeout(this.clearSuppressTimer),this.clearSuppressTimer=setTimeout(()=>{this.suppressClick=!1,this.clearSuppressTimer=void 0},0),a&&void 0!==e){const t=this.$data.allowHalf?.5:1;let a=e<=0?this.$data.allowClear?0:t:e;return a=Math.max(0,Math.min(this.resolveCount(),a)),this.$data.allowClear&&a===this.$data.value&&(a=0),this.$data.hoverValue=void 0,void(a!==this.$data.value&&(this.$data.value=a,this.dispatchChangeEvent()))}this.$data.hoverValue=void 0}handleClick(t,e){if(this.suppressClick)return void(this.suppressClick=!1);if(this.$data.disabled||this.$data.readonly)return;let a=e?this.resolvePointerValue(t,e):t;!e&&this.$data.allowHalf&&(a=this.$data.hoverValue??t),this.$data.allowClear&&a===this.$data.value&&(a=0),this.$data.hoverValue=void 0,a!==this.$data.value&&(this.$data.value=a,this.dispatchChangeEvent())}handleMouseEnter(t){this.dragging||this.$data.disabled||this.$data.readonly||(this.$data.hoverValue=t)}handleMouseMove(t,e){this.dragging||this.$data.disabled||this.$data.readonly||(this.$data.hoverValue=this.resolvePointerValue(t,e))}handleMouseLeave(){this.dragging||this.$data.disabled||this.$data.readonly||(this.$data.hoverValue=void 0)}handleKeyDown(t){if(this.$data.disabled||this.$data.readonly)return;const e=this.resolveCount();if(0===e)return;const a=this.resolveValue(),r=this.$data.allowHalf?.5:1;let i;switch(t.key){case"ArrowRight":case"ArrowUp":i=Math.min(e,a+r);break;case"ArrowLeft":case"ArrowDown":i=Math.max(0,a-r);break;case"Home":i=this.$data.allowClear?0:Math.min(1,e);break;case"End":i=e;break;case"Enter":case" ":case"Spacebar":{const a=Number(t.target?.dataset?.index);if(!a)return;i=Math.min(e,a);break}default:return}t.preventDefault(),i!==this.$data.value&&(this.$data.value=i,this.$data.hoverValue=void 0,this.dispatchChangeEvent(),this.focusStar(i))}focusStar(t){const e=this.resolveCount();if(0===e)return;const a=Math.min(e,Math.max(1,Math.ceil(t))),r=Array.from(this.shadowRoot?.querySelectorAll(".rate__star")||[]);r[a-1]?.focus()}dispatchChangeEvent(){this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}setValue(t){const e=Number(t);Number.isFinite(e)?this.$data.value=Math.max(0,Math.min(this.resolveCount(),e)):this.$data.value=0}getValue(){return this.$data.value}};i=((t,e)=>{for(var a,r=e,i=t.length-1;i>=0;i--)(a=t[i])&&(r=a(r)||r);return r})([r({tagName:"solely-rate",template:e,styles:t,shadowDOM:{use:!0,mode:"open"},props:[{name:"value",type:"number",default:0},{name:"count",type:"number",default:5},{name:"allowHalf",type:"boolean",default:!1},{name:"disabled",type:"boolean",default:!1},{name:"allowClear",type:"boolean",default:!1},{name:"character",type:"string",default:"★"},{name:"readonly",type:"boolean",default:!1},{name:"tooltips",type:"string"}]})],i);export{i as SolelyRate};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),exports.default="*,*:before,*:after{box-sizing:border-box}:host{display:inline-block}.rate{display:inline-flex;align-items:center;gap:var(--solely-spacing-xs);font-family:var(--solely-font-family)}.rate__star{position:relative;display:inline-flex;align-items:center;justify-content:center;font-size:20px;color:var(--solely-gray-4);cursor:pointer;transition:all var(--solely-transition-duration);-webkit-user-select:none;user-select:none}.rate__star:hover{transform:scale(1.1)}.rate__star--full{color:var(--solely-warning)}.rate__star--half{position:relative}.rate__star--half:before{content:attr(data-char);position:absolute;left:0;width:50%;overflow:hidden;color:var(--solely-warning)}.rate__star--zero{color:var(--solely-gray-5)}.rate.is-disabled .rate__star{cursor:not-allowed;opacity:var(--solely-disabled-opacity)}.rate.is-disabled .rate__star:hover{transform:none}.rate.is-readonly .rate__star{cursor:default}.rate.is-readonly .rate__star:hover{transform:none}";
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),exports.default="*,*:before,*:after{box-sizing:border-box}:host{display:inline-block}.rate{display:inline-flex;align-items:center;gap:var(--solely-spacing-xs);font-family:var(--solely-font-family)}.rate__star{position:relative;display:inline-flex;align-items:center;justify-content:center;font-size:20px;color:var(--solely-gray-4);cursor:pointer;transition:all var(--solely-transition-duration);-webkit-user-select:none;user-select:none}.rate__star:hover{transform:scale(1.1)}.rate__star--full{color:var(--solely-warning)}.rate__star:focus-visible{outline:2px solid var(--solely-primary);outline-offset:2px;border-radius:2px}.rate__star--half{position:relative}.rate__star--half:before{content:attr(data-char);position:absolute;left:0;width:50%;overflow:hidden;color:var(--solely-warning)}.rate__star--zero{color:var(--solely-gray-5)}.rate.is-disabled .rate__star{cursor:not-allowed;opacity:var(--solely-disabled-opacity)}.rate.is-disabled .rate__star:hover{transform:none}.rate.is-readonly .rate__star{cursor:default}.rate.is-readonly .rate__star:hover{transform:none}";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const r="*,*:before,*:after{box-sizing:border-box}:host{display:inline-block}.rate{display:inline-flex;align-items:center;gap:var(--solely-spacing-xs);font-family:var(--solely-font-family)}.rate__star{position:relative;display:inline-flex;align-items:center;justify-content:center;font-size:20px;color:var(--solely-gray-4);cursor:pointer;transition:all var(--solely-transition-duration);-webkit-user-select:none;user-select:none}.rate__star:hover{transform:scale(1.1)}.rate__star--full{color:var(--solely-warning)}.rate__star:focus-visible{outline:2px solid var(--solely-primary);outline-offset:2px;border-radius:2px}.rate__star--half{position:relative}.rate__star--half:before{content:attr(data-char);position:absolute;left:0;width:50%;overflow:hidden;color:var(--solely-warning)}.rate__star--zero{color:var(--solely-gray-5)}.rate.is-disabled .rate__star{cursor:not-allowed;opacity:var(--solely-disabled-opacity)}.rate.is-disabled .rate__star:hover{transform:none}.rate.is-readonly .rate__star{cursor:default}.rate.is-readonly .rate__star:hover{transform:none}";export{r as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./style.css.cjs"),e=require("./index.html.cjs"),s=require("../../../runtime/component/base-element.cjs"),a=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelySelect=class extends s.default{clickOutsideHandler;slotObserver;closeTimer;get value(){return this.$data.value||""}set value(t){this.$data.disabled||this.setValue(t)}getSelectClasses(){const t={};return"small"===this.$data.size?t["select--sm"]=!0:"large"===this.$data.size?t["select--lg"]=!0:t["select--md"]=!0,t["is-disabled"]=!!this.$data.disabled,t["is-focused"]=!!this.$data.focused,t["is-open"]=!!this.$data.isOpen,t["use-slot"]=this.$data.useSlot,t}getDropdownClasses(){return{"select__dropdown--closing":!!this.$data.closing,"select__dropdown--top":"top"===this.$data.dropdownPlacement,"select__dropdown--bottom":"bottom"===this.$data.dropdownPlacement}}getOptionClasses(t){return{"select__option--selected":t.value===this.$data.value,"select__option--disabled":!!t.disabled}}calculateDropdownPlacement(){const t=this.getBoundingClientRect(),e=window.innerHeight-t.bottom,s=t.top;this.$data.dropdownPlacement=e<256&&s>e?"top":"bottom"}collectSlotOptions(){const t=Array.from(this.children);this.$data.hasHeaderSlot=t.some(t=>"header"===t.getAttribute("slot")),this.$data.hasFooterSlot=t.some(t=>"footer"===t.getAttribute("slot"));const e=t.filter(t=>!t.getAttribute("slot")&&t.hasAttribute("data-value"));0!==e.length?(this.$data.useSlot=!0,this.$data.slotOptions=e.map(t=>{const e=t;return{value:e.getAttribute("data-value")||"",label:e.getAttribute("data-label")||e.textContent?.trim()||"",disabled:e.hasAttribute("disabled"),element:t}}),this.syncSelectedLabel()):this.$data.useSlot=!1}mounted(){this.collectSlotOptions(),this.$data.useSlot||this.parseOptions(),this.setupSlotObserver(),this.clickOutsideHandler=t=>{t.composedPath().some(t=>t===this)||this.closeDropdown()},document.addEventListener("click",this.clickOutsideHandler)}setupSlotObserver(){this.slotObserver=new MutationObserver(()=>{this.collectSlotOptions()}),this.slotObserver.observe(this,{childList:!0,subtree:!1,attributes:!0,attributeFilter:["data-value","data-label","disabled"]})}unmounted(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.slotObserver&&this.slotObserver.disconnect(),this.closeTimer&&(clearTimeout(this.closeTimer),this.closeTimer=void 0)}updated(){const t=this.$data.selectedLabel,e=this.getCurrentLabel();t!==e&&(this.$data.selectedLabel=e),this.updateAriaAttributes()}updateAriaAttributes(){const t=this.shadowRoot?.querySelector(".select__trigger");t&&(t.setAttribute("aria-expanded",this.$data.isOpen?"true":"false"),t.setAttribute("aria-disabled",this.$data.disabled?"true":"false"))}getCurrentLabel(){if(this.$data.useSlot){const t=this.$data.slotOptions.find(t=>t.value===this.$data.value);return t?.label||""}{const t=this.$data.parsedOptions.find(t=>t.value===this.$data.value);return t?.label||""}}parseOptions(){this.$data.parsedOptions=Array.isArray(this.$data.options)?this.$data.options:[],this.syncSelectedLabel()}syncSelectedLabel(){if(this.$data.useSlot){const t=this.$data.slotOptions?.find(t=>t.value===this.$data.value);this.$data.selectedLabel=t?.label||""}else{const t=this.$data.parsedOptions?.find(t=>t.value===this.$data.value);this.$data.selectedLabel=t?.label||""}}handleClick(){if(this.$data.disabled)return;const t=!this.$data.isOpen;this.$data.isOpen=t,this.$data.focused=t,t&&this.calculateDropdownPlacement()}handleSelect(t,e){t.disabled||(this.$data.value=t.value,this.syncSelectedLabel(),this.closeDropdown(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleSlotClick(t){const e=t.target.closest("[data-value]");if(!e)return;if(e.hasAttribute("data-group"))return void t.stopPropagation();const s=e.getAttribute("data-value")||"",a=e.getAttribute("data-label")||e.textContent?.trim()||"";e.hasAttribute("disabled")||(this.$data.value=s,this.$data.selectedLabel=a,this.closeDropdown(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleHeaderFooterClick(t){t.stopPropagation()}handleClear(t){t.stopPropagation(),this.$data.value="",this.$data.selectedLabel="",this.dispatchEvent(new Event("clear",{bubbles:!0,composed:!0})),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}closeDropdown(){this.$data.isOpen&&(this.$data.closing=!0,this.closeTimer=setTimeout(()=>{this.$data.isOpen=!1,this.$data.closing=!1,this.$data.focused=!1,this.closeTimer=void 0},200))}setValue(t,e=!1){this.$data.value=t,this.syncSelectedLabel(),e||this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}getValue(){return this.$data.value||""}setOptions(t){this.$data.options=t,this.$data.useSlot=!1,this.parseOptions()}},exports.SolelySelect=((t,e)=>{for(var s,a=e,i=t.length-1;i>=0;i--)(s=t[i])&&(a=s(a)||a);return a})([a.CustomElement({tagName:"solely-select",template:e.__SOLELY_IR__,styles:t.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"value",type:"string",default:""},{name:"placeholder",type:"string",default:"请选择"},{name:"disabled",type:"boolean",default:!1},{name:"size",type:"string",default:"medium"},{name:"clearable",type:"boolean",default:!1},{name:"options",type:"array",default:[]},{name:"multiple",type:"boolean",default:!1},{name:"block",type:"boolean",default:!1}]})],exports.SolelySelect);
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../../shared/size.cjs"),e=require("../../../shared/boolean.cjs"),i=require("../../../shared/floating/position.cjs"),s=require("../../../shared/floating/overlay-stack.cjs"),a=require("../../../shared/form-associated.cjs"),o=require("./style.css.cjs"),n=require("./index.html.cjs");require("./option.cjs");const l=require("../../../runtime/component/base-element.cjs"),r=require("../../../runtime/reactivity/observe.cjs"),d=require("../../../runtime/component/decorators.cjs");var h=Object.defineProperty;Object.getOwnPropertyDescriptor;let c=0;var u,p,g;exports.SolelySelect=class extends l.default{get size(){return t.normalizeSize(this.$data.size)}set size(e){this.$data.size=t.normalizeSize(e)}clickOutsideHandler;slotObserver;closeTimer;instanceId=++c;optionsSource="auto";manualOptions;initialized=!1;lastParsedOptions;ignoreOutsideClick=!1;ignoreOutsideClickTimer;_dropdown;_overlay;_stopObserve;get value(){return this.$data.value??""}set value(t){this.setValue(t,!0)}get defaultValue(){return this.$data.defaultValue??""}set defaultValue(t){this.$data.defaultValue=t,!this.isSyncingProps&&this.initialized&&a.setFormDefault(this,this.normalizeValue(t))}get multiple(){return!!this.$data.multiple}set multiple(t){this.$data.multiple=!!t,this.$data.value=this.normalizeValue(this.$data.value),this.syncSelectedLabel(),this.syncSlotSelection()}created(){void 0===this.$data.focused&&(this.$data.focused=!1),void 0===this.$data.isOpen&&(this.$data.isOpen=!1),void 0===this.$data.closing&&(this.$data.closing=!1),void 0===this.$data.selectedLabel&&(this.$data.selectedLabel=""),void 0===this.$data.parsedOptions&&(this.$data.parsedOptions=[]),void 0===this.$data.slotOptions&&(this.$data.slotOptions=[]),void 0===this.$data.hasHeaderSlot&&(this.$data.hasHeaderSlot=!1),void 0===this.$data.hasFooterSlot&&(this.$data.hasFooterSlot=!1),void 0===this.$data.activeIndex&&(this.$data.activeIndex=-1),void 0===this.$data.dropdownPlacement&&(this.$data.dropdownPlacement="bottom");const t={family:"scalar",read:()=>this.getValue(),write:(t,e)=>this.setValue(t,!0),encode:t=>{const e=Array.isArray(t)?t:t?[String(t)]:[];return e.length>0?e.map(t=>String(t)):null},name:()=>this.formFieldName(),disabled:()=>!!this.$data.disabled,required:()=>!!this.$data.required,ariaTarget:()=>this.getTriggerElement(),tabTargets:()=>this.getTriggerElement(),anchors:()=>{const t=this.getTriggerElement();return t?[t]:null},validate:t=>this.validateValue(t),missingMessage:()=>a.FORM_VALIDATION_MESSAGES.valueMissingSelect,invalidMessage:()=>this.$data.invalidMessage||"",readDefault:()=>this.readExplicitDefaultValue(),changeDetail:(t,e,i)=>({name:this.formFieldName(),value:Array.isArray(t)?t.map(String):String(t??""),previousValue:Array.isArray(e)?e.map(String):String(e??""),source:i})};Object.defineProperty(t,"family",{configurable:!0,enumerable:!0,get:()=>this.multiple?"multiple":"scalar"}),a.initFormAssociation(this,t)}formAssociatedCallback(){a.handleFormAssociatedCallback(this)}formResetCallback(){a.handleFormResetCallback(this)}formDisabledCallback(t){a.handleFormDisabledCallback(this,t)}get validity(){return a.formValidity(this)}get validationMessage(){return a.formValidationMessage(this)}get willValidate(){return!a.effectiveDisabled(this)}checkValidity(){return a.checkFormValidity(this)}reportValidity(){return a.reportFormValidity(this)}setCustomValidity(t){a.setCustomValidity(this,t)}syncFormState(){a.syncFormValue(this),a.syncValidity(this),a.syncAria(this)}formFieldName(){return this.$data.name||this.getAttribute("name")||""}getTriggerElement(){return this.shadowRoot?.querySelector(".select")??null}getAriaDisabled(){return a.effectiveDisabled(this)?"true":"false"}getTabindex(){return a.effectiveDisabled(this)?"-1":"0"}validateValue(t){return this.$data.required&&(Array.isArray(t)?0===t.length:""===String(t??""))?{flags:{valueMissing:!0},anchor:this.getTriggerElement()??void 0}:null}readExplicitDefaultValue(){const t=this.getAttribute("default-value");if(null!==t)return this.normalizeValue(t);const e=this.$data.defaultValue;return"string"==typeof e&&""!==e?this.normalizeValue(e):void 0}getSelectClasses(){const t={};return"small"===this.$data.size?t["select--sm"]=!0:"large"===this.$data.size?t["select--lg"]=!0:t["select--md"]=!0,t["is-disabled"]=a.effectiveDisabled(this),t["is-focused"]=!!this.$data.focused,t["is-open"]=!!this.$data.isOpen,t["use-slot"]=this.$data.useSlot,t["select--multiple"]=!!this.$data.multiple,t}getDropdownClasses(){return{"select__dropdown--closing":!!this.$data.closing,"select__dropdown--top":"top"===this.$data.dropdownPlacement,"select__dropdown--bottom":"bottom"===this.$data.dropdownPlacement}}getOptionClasses(t,e=-1){const i=!!t.isGroup;return{"select__option--selected":!i&&this.isSelected(t.value),"select__option--highlighted":!i&&e>=0&&e===this.$data.activeIndex,"select__option--disabled":!i&&!!t.disabled,"select__option--group":i,"select__group-label":i}}isSelected(t){return this.getSelectedValues().includes(String(t))}getSelectedValues(){const t=this.$data.value;return this.$data.multiple?Array.isArray(t)?t.map(String):t?[String(t)]:[]:Array.isArray(t)?t.length?[String(t[0])]:[]:t?[String(t)]:[]}normalizeValue(t){if(this.$data.multiple){if(Array.isArray(t))return this.uniqueValues(t.map(String));if(null==t||""===t)return[];const e=String(t).trim();if(e.startsWith("["))try{const t=JSON.parse(e);if(Array.isArray(t))return this.uniqueValues(t.map(String))}catch{}const i=e.includes(",")?e.split(","):[e];return this.uniqueValues(i.map(t=>t.trim()).filter(Boolean))}return Array.isArray(t)?t.length?String(t[0]):"":null==t?"":String(t)}uniqueValues(t){return Array.from(new Set(t))}positionDropdown(){const t=this._dropdown;if(!t||!t.isConnected)return;const e=this.getBoundingClientRect(),s=t.getBoundingClientRect(),a=i.computePosition(e,{width:t.offsetWidth||s.width,height:t.offsetHeight||s.height},{placement:"bottom",viewport:{width:document.documentElement.clientWidth||window.innerWidth,height:document.documentElement.clientHeight||window.innerHeight},offset:4,boundaryPadding:8,flip:!0,shift:!0,strategy:"fixed"}),o=a.placement.startsWith("top")?"top":"bottom";t.classList.toggle("select__dropdown--top","top"===o),t.classList.toggle("select__dropdown--bottom","top"!==o),t.style.position="fixed",t.style.top=`${a.top}px`,t.style.left=`${a.left}px`,t.style.bottom="auto",t.style.right="auto",t.style.minWidth=`${e.width}px`}setupDropdown(){const t=this.shadowRoot?.querySelector(".select__dropdown");if(t){if(this._dropdown===t)return this._stopObserve||(this._stopObserve=i.observePosition({anchor:this,floating:t,update:()=>this.positionDropdown(),onAnchorLost:()=>this.close()})),void this.positionDropdown();this.teardownDropdown(),this._dropdown=t,this._overlay=s.registerOverlay({kind:"dropdown",container:t,trigger:this,escClosable:!0,trapFocus:!1,lockScroll:!1,inertBackground:!1,autoFocus:!1,returnFocus:!1,onEscape:()=>this.close()}),this._overlay.activate(),this.positionDropdown(),this._stopObserve=i.observePosition({anchor:this,floating:t,update:()=>this.positionDropdown(),onAnchorLost:()=>this.close()})}else this.teardownDropdown()}teardownDropdown(){this._stopObserve?.(),this._stopObserve=void 0,this._overlay?.deactivate(),this._overlay?.dispose(),this._overlay=void 0,this._dropdown=void 0}isDeclarativeOptionElement(t){return"solely-select-option"===t.tagName.toLowerCase()}getSlotOptionValue(t){const e=this.isDeclarativeOptionElement(t)?"value":"data-value";return t.getAttribute(e)??""}getSlotOptionLabel(t){const e=this.isDeclarativeOptionElement(t)?"label":"data-label";return t.getAttribute(e)||t.textContent?.trim()||""}collectSlotOptions(){const t=Array.from(this.children);if(this.$data.hasHeaderSlot=t.some(t=>"header"===t.getAttribute("slot")),this.$data.hasFooterSlot=t.some(t=>"footer"===t.getAttribute("slot")),"options"===this.optionsSource)return this.$data.useSlot=!1,void this.syncSlotSelection();const i=t.filter(t=>!t.getAttribute("slot")&&(t.hasAttribute("data-value")||this.isDeclarativeOptionElement(t)));if(0===i.length)return this.$data.useSlot=!1,this.parseOptions(),void this.syncSlotSelection();this.$data.useSlot=!0,this.$data.slotOptions=i.map(t=>({value:this.getSlotOptionValue(t),label:this.getSlotOptionLabel(t),disabled:e.parseBooleanAttribute(t.getAttribute("disabled")),isGroup:!!t.hasAttribute("data-group")||void 0,element:t})),this.syncSelectedLabel(),this.syncSlotSelection()}mounted(){this.$data.value=this.normalizeValue(this.$data.value),this.collectSlotOptions(),this.$data.useSlot||("options"===this.optionsSource&&this.manualOptions&&(this.$data.options=this.manualOptions),this.parseOptions()),this.setupSlotObserver(),this.clickOutsideHandler=t=>{this.ignoreOutsideClick||t.composedPath().some(t=>t===this)||this.closeDropdown()},document.addEventListener("click",this.clickOutsideHandler),this.syncValueContent(),this.syncOptionContents(),this.syncFormState(),this.initialized=!0}setupSlotObserver(){this.slotObserver=new MutationObserver(()=>{this.collectSlotOptions()}),this.slotObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-value","data-label","data-group","disabled","slot","value","label"]})}unmounted(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.slotObserver&&this.slotObserver.disconnect(),this.closeTimer&&(clearTimeout(this.closeTimer),this.closeTimer=void 0),this.ignoreOutsideClickTimer&&(clearTimeout(this.ignoreOutsideClickTimer),this.ignoreOutsideClickTimer=void 0),this.ignoreOutsideClick=!1,this.teardownDropdown()}updated(){this.$data.useSlot||this.$data.options===this.lastParsedOptions||this.parseOptions(),this.syncSelectedLabel(),this.syncSlotSelection(),this.syncValueContent(),this.syncOptionContents(),this.syncFormState(),this.$data.isOpen?this.setupDropdown():this.teardownDropdown()}renderOptionContent(t,e){const i=e.render;if("function"==typeof i){const s=i(e);if(s instanceof Element)return void t.appendChild(s.cloneNode(!0));if(null!=s&&String(s).length>0)return void(t.textContent=String(s))}const s="function"==typeof e.icon?e.icon(e):e.icon;if(s){const e=document.createElement("span");if(e.className="select__option-icon",e.setAttribute("part","option-icon"),e.setAttribute("aria-hidden","true"),"string"==typeof s){const t=s.split(/\s+/).filter(Boolean);if(t.length){e.classList.add(...t);const i=t.filter(t=>/^[a-zA-Z_][\w-]*$/.test(t));i.length&&e.setAttribute("part",`option-icon ${i.join(" ")}`)}}else s instanceof Element&&e.appendChild(s.cloneNode(!0));t.appendChild(e)}const a=document.createElement("span");a.className="select__option-label",a.setAttribute("part","option-label"),a.textContent=e.label||e.value,t.appendChild(a)}findOptionEntry(t){return this.$data.useSlot?this.$data.slotOptions.find(e=>!e.isGroup&&String(e.value)===t):this.$data.parsedOptions.find(e=>!e.isGroup&&String(e.value)===t)}cloneSlotContent(t,e,i){const s=r.toRaw(e),a=Array.from(s.childNodes);0!==a.length?a.forEach(e=>t.appendChild(e.cloneNode(!0))):t.textContent=i}syncOptionContents(){if(this.$data.useSlot)return;const t=this.$data.parsedOptions,e=this.shadowRoot?.querySelectorAll(".select__option");e&&e.forEach((e,i)=>{const s=t[i];if(!s)return;const a=e.querySelector(".select__option-content");if(!a)return;const o="string"==typeof s.icon?s.icon:"",n=[s.label??"",s.value??"",s.disabled?"1":"0",o].join("\0");a.__solelyOptionRef===s&&a.dataset.optionSignature===n||(a.__solelyOptionRef=s,a.dataset.optionSignature=n,a.textContent="",s.isGroup?a.textContent=s.label||s.value:this.renderOptionContent(a,s))})}syncValueContent(){const t=this.shadowRoot?.querySelector(".select__value-content");if(!t)return;t.textContent="";const e=this.getSelectedValues();0!==e.length&&e.forEach(e=>{const i=this.$data.multiple?document.createElement("span"):t;this.$data.multiple&&(i.className="select__tag");const s=this.findOptionEntry(e);s?s.element?this.cloneSlotContent(i,s.element,e):this.renderOptionContent(i,s):i.textContent=e,this.$data.multiple&&t.appendChild(i)})}attributeChanged(t){if("default-value"===t&&this.initialized)a.setFormDefault(this,this.normalizeValue(this.$data.defaultValue));else if("options"===t&&this.initialized){if(this.hasAttribute("options"))return this.manualOptions=void 0,this.optionsSource="options",this.$data.useSlot=!1,this.parseOptions(),void this.syncSlotSelection();if(this.manualOptions)return this.optionsSource="options",this.$data.options=this.manualOptions,this.$data.useSlot=!1,this.parseOptions(),void this.syncSlotSelection();this.optionsSource="auto",this.collectSlotOptions(),this.$data.useSlot||this.parseOptions()}}getLabelsForValues(t,e=!1){const i=((this.$data.useSlot?this.$data.slotOptions:this.$data.parsedOptions)??[]).filter(t=>!t.isGroup);return t.map(t=>{const s=i.find(e=>String(e.value)===t)?.label;return s||(e?t:void 0)}).filter(t=>!!t)}parseOptions(){const t=this.$data.options;this.lastParsedOptions=t,this.$data.parsedOptions=Array.isArray(t)?t:[],this.syncSelectedLabel()}syncSelectedLabel(){const t=this.getSelectedValues(),e=this.getLabelsForValues(t,!this.$data.useSlot);e.length>0?this.$data.selectedLabel=e.join("、"):0===t.length&&(this.$data.selectedLabel="")}cleanupSlotOptionState(t){t.removeAttribute("data-selected"),t.removeAttribute("data-highlighted"),t.removeAttribute("aria-selected"),"option"!==t.getAttribute("role")&&"presentation"!==t.getAttribute("role")||t.removeAttribute("role");const e=`${this.getListboxId()}-slot-option-`;t.id.startsWith(e)&&t.removeAttribute("id")}syncSlotSelection(){this.$data.useSlot?this.$data.slotOptions.forEach((t,e)=>{const i=r.toRaw(t.element);t.isGroup?this.cleanupSlotOptionState(i):(i.id||(i.id=`${this.getListboxId()}-slot-option-${e}`),i.setAttribute("role","option"),i.setAttribute("aria-selected",this.isSelected(t.value)?"true":"false"),this.isSelected(t.value)?i.setAttribute("data-selected",""):i.removeAttribute("data-selected"),e===this.$data.activeIndex?i.setAttribute("data-highlighted",""):i.removeAttribute("data-highlighted"))}):Array.from(this.children).filter(t=>t.hasAttribute("data-value")||this.isDeclarativeOptionElement(t)).forEach(t=>this.cleanupSlotOptionState(t))}getListboxId(){return`solely-select-${this.instanceId}-listbox`}getAriaControls(){return this.$data.isOpen?this.getListboxId():null}getOptionId(t,e){return`${this.getListboxId()}-option-${e}`}getActiveDescendantId(){if(!this.$data.isOpen)return null;const t=this.getAllOptions(),e=this.$data.activeIndex;if(e<0||e>=t.length)return null;if(!this.isSelectableOption(t[e]))return null;if(this.$data.useSlot){const t=this.$data.slotOptions[e];return t&&r.toRaw(t.element).id||null}return this.getOptionId(t[e],e)}getAllOptions(){return this.$data.useSlot?this.$data.slotOptions.map(({value:t,label:e,disabled:i,isGroup:s})=>({value:t,label:e,disabled:i,isGroup:s})):this.$data.parsedOptions}isSelectableOption(t){return!t.isGroup&&!t.disabled}getSelectableOptions(){return this.getAllOptions().filter(t=>!t.isGroup)}findBoundarySelectableIndex(t){const e=this.getAllOptions();if("first"===t)return e.findIndex(t=>this.isSelectableOption(t));for(let i=e.length-1;i>=0;i--)if(this.isSelectableOption(e[i]))return i;return-1}syncActiveIndexToSelection(){const t=this.getAllOptions(),e=this.getSelectedValues();let i=t.findIndex(t=>this.isSelectableOption(t)&&e.includes(String(t.value)));i<0&&(i=t.findIndex(t=>this.isSelectableOption(t))),this.$data.activeIndex=i}moveActive(t){const e=this.getAllOptions();if(0===e.length)return;let i=this.$data.activeIndex;i<0&&(i=t>0?-1:e.length);for(let s=0;s<e.length;s++)if(i=(i+t+e.length)%e.length,this.isSelectableOption(e[i]))return this.$data.activeIndex=i,void this.syncSlotSelection()}selectActive(){const t=this.getAllOptions()[this.$data.activeIndex];t&&this.isSelectableOption(t)&&this.applySelection(String(t.value),!!t.disabled)}searchByChar(t){const e=this.getAllOptions();if(0===e.length)return;const i=t.toLowerCase(),s=this.$data.activeIndex;for(let a=1;a<=e.length;a++){const t=(s+a+e.length)%e.length,o=e[t],n=String(o.label??o.value??"");if(this.isSelectableOption(o)&&n.trim().toLowerCase().startsWith(i))return this.$data.activeIndex=t,void this.syncSlotSelection()}}focusTrigger(){const t=this.shadowRoot?.querySelector(".select");t?.focus()}handleClick(t){if(a.effectiveDisabled(this))return;const e=t?.target;if(e){const t=this.shadowRoot?.querySelector(".select__dropdown");if(t?.contains(e))return;if(e!==this&&this.contains(e))return}this.$data.isOpen?this.close():this.open()}handleKeydown(t){if(a.effectiveDisabled(this))return;const e=t,i=e.key,s=e.target,o=this.shadowRoot?.querySelector(".select"),n=this.shadowRoot?.querySelector(".select__selector");if(s&&(s===o||s===n||n?.contains(s)))if("Tab"!==i){if("ArrowDown"===i||"ArrowUp"===i)return e.preventDefault(),void(this.$data.isOpen?this.moveActive("ArrowDown"===i?1:-1):(this.open(),"ArrowUp"===i?this.$data.activeIndex=this.findBoundarySelectableIndex("last"):this.moveActive(1),this.syncSlotSelection()));if("Enter"===i)return e.preventDefault(),void(this.$data.isOpen?this.selectActive():this.open());if(" "===i)return e.preventDefault(),void(this.$data.isOpen?this.close():this.open());if("Escape"!==i){if(this.$data.isOpen&&("Home"===i||"End"===i)){e.preventDefault();const t=this.findBoundarySelectableIndex("Home"===i?"first":"last");return void(t>=0&&(this.$data.activeIndex=t,this.syncSlotSelection()))}!this.$data.isOpen||1!==i.length||" "===i||e.ctrlKey||e.metaKey||e.altKey||(e.preventDefault(),this.searchByChar(i))}else this.$data.isOpen&&(e.preventDefault(),this.close())}else this.$data.isOpen&&this.close()}open(){if(!a.effectiveDisabled(this)){if(this.ignoreOutsideClick=!0,this.ignoreOutsideClickTimer&&clearTimeout(this.ignoreOutsideClickTimer),this.ignoreOutsideClickTimer=setTimeout(()=>{this.ignoreOutsideClick=!1,this.ignoreOutsideClickTimer=void 0},0),this.closeTimer&&(clearTimeout(this.closeTimer),this.closeTimer=void 0),this.$data.isOpen)return this.$data.closing=!1,this.$data.focused=!0,void(this._overlay?(this._overlay.activate(),this._dropdown&&!this._stopObserve&&this.setupDropdown()):this.setupDropdown());this.teardownDropdown(),this.$data.isOpen=!0,this.$data.closing=!1,this.$data.focused=!0,this.$data.activeIndex=-1,this.syncSlotSelection(),this.focusTrigger()}}close(){this.closeTimer&&(clearTimeout(this.closeTimer),this.closeTimer=void 0),this.ignoreOutsideClickTimer&&(clearTimeout(this.ignoreOutsideClickTimer),this.ignoreOutsideClickTimer=void 0),this.ignoreOutsideClick=!1,this.teardownDropdown(),this.$data.isOpen=!1,this.$data.closing=!1,this.$data.focused=!1,this.$data.activeIndex=-1}handleSelect(t,e){e.stopPropagation(),t.isGroup||this.applySelection(String(t.value),!!t.disabled)}handleSlotClick(t){const i=t.target.closest("[data-value], solely-select-option");if(!i)return;if(t.stopPropagation(),i.hasAttribute("data-group"))return;const s=this.getSlotOptionValue(i),a=e.parseBooleanAttribute(i.getAttribute("disabled"));this.applySelection(s,a)}applySelection(t,e){if(!e&&!a.effectiveDisabled(this)){if(this.$data.multiple){const e=this.getSelectedValues(),i=e.includes(t)?e.filter(e=>e!==t):[...e,t];return this.setValue(i,!1,"user"),this.$data.activeIndex=this.getAllOptions().findIndex(e=>String(e.value)===t),void this.syncSlotSelection()}this.setValue(t,!1,"user"),this.closeDropdown()}}handleHeaderFooterClick(t){t.stopPropagation()}clearValue(){if(0===this.getSelectedValues().length)return;const t=this.$data.value;this.setValue(this.$data.multiple?[]:"",!0),this.isSyncingProps||(this.dispatchEvent(new Event("clear",{bubbles:!0,composed:!0})),this.dispatchChange(t,"user"))}handleClear(t){a.effectiveDisabled(this)||(t.stopPropagation(),this.clearValue())}handleClearKeydown(t){"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.handleClear(t))}clear(){this.clearValue()}closeDropdown(){this.$data.isOpen&&!this.closeTimer&&(this._overlay?.deactivate(),this._stopObserve?.(),this._stopObserve=void 0,this.$data.closing=!0,this.closeTimer=setTimeout(()=>{this.$data.isOpen=!1,this.$data.closing=!1,this.$data.focused=!1,this.$data.activeIndex=-1,this.closeTimer=void 0,this.teardownDropdown()},200))}setValue(t,e=!1,i="api"){const s=this.$data.value,a=this.normalizeValue(t),o=!this.valuesEqual(s,a);this.$data.value=a,this.$data.isOpen&&this.syncActiveIndexToSelection(),this.syncSelectedLabel(),this.syncSlotSelection(),this.syncFormState(),e||!o||this.isSyncingProps||this.dispatchChange(s,i)}valuesEqual(t,e){return Array.isArray(t)||Array.isArray(e)?!(!Array.isArray(t)||!Array.isArray(e))&&t.length===e.length&&t.every((t,i)=>t===e[i]):(t??"")===(e??"")}getValue(){return this.$data.value??""}setOptions(t){this.optionsSource="options",this.manualOptions=t,this.$data.options=t,this.$data.useSlot=!1,this.parseOptions(),this.syncSlotSelection()}getOptions(){return this.getSelectableOptions().map(t=>{const e={label:t.label,value:t.value,disabled:t.disabled,isGroup:t.isGroup};return"icon"in t&&(e.icon=t.icon),"render"in t&&(e.render=t.render),e})}dispatchChange(t="",e="user"){const i=this.getValue(),s=this.formFieldName(),o=t=>Array.isArray(t)?t.map(String):t?[String(t)]:[];Array.isArray(i)||Array.isArray(t)?a.emitChange(this,{name:s,value:o(i),previousValue:o(t),source:e}):a.emitChange(this,{name:s,value:String(i??""),previousValue:String(t??""),source:e})}},u=exports.SolelySelect,g=!0,(p="formAssociated")in u?h(u,p,{enumerable:!0,configurable:!0,writable:!0,value:g}):u[p]=g,exports.SolelySelect=((t,e)=>{for(var i,s=e,a=t.length-1;a>=0;a--)(i=t[a])&&(s=i(s)||s);return s})([d.CustomElement({tagName:"solely-select",template:n.__SOLELY_IR__,styles:o.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"value",type:"string",default:""},{name:"placeholder",type:"string",default:"请选择"},{name:"disabled",type:"boolean",default:!1},{name:"size",type:"string",default:"medium"},{name:"clearable",type:"boolean",default:!1},{name:"options",type:"array",default:[]},{name:"multiple",type:"boolean",default:!1},{name:"block",type:"boolean",default:!1},{name:"name",type:"string",default:""},{name:"required",type:"boolean",default:!1,reflect:!0},{name:"defaultValue",type:"string",default:""},{name:"invalidMessage",type:"string",default:""}]})],exports.SolelySelect);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { BaseElement } from '../../../runtime/component';
|
|
2
|
-
import {
|
|
1
|
+
import { BaseElement } from '../../../runtime/component/index.js';
|
|
2
|
+
import { SizeInput } from '../../../shared/size.js';
|
|
3
|
+
import { ChangeSource } from '../../../shared/form-associated.js';
|
|
4
|
+
import { SelectProps, SelectOption as SelectOptionType, SelectMethods, SelectValue, SelectSize } from './types.js';
|
|
3
5
|
declare class SolelySelect extends BaseElement<SelectProps & {
|
|
4
6
|
focused: boolean;
|
|
5
7
|
isOpen: boolean;
|
|
@@ -12,19 +14,87 @@ declare class SolelySelect extends BaseElement<SelectProps & {
|
|
|
12
14
|
value: string;
|
|
13
15
|
label: string;
|
|
14
16
|
disabled: boolean;
|
|
17
|
+
isGroup?: boolean;
|
|
15
18
|
element: Element;
|
|
16
19
|
}>;
|
|
17
20
|
hasHeaderSlot: boolean;
|
|
18
21
|
hasFooterSlot: boolean;
|
|
19
|
-
|
|
22
|
+
activeIndex: number;
|
|
23
|
+
}> implements SelectMethods {
|
|
24
|
+
/** 统一尺寸语义:middle / default 归一为 medium */
|
|
25
|
+
get size(): SelectSize;
|
|
26
|
+
set size(value: SizeInput);
|
|
27
|
+
/** 表单关联自定义元素(C-FORM-01) */
|
|
28
|
+
static readonly formAssociated = true;
|
|
20
29
|
clickOutsideHandler?: (event: MouseEvent) => void;
|
|
21
30
|
slotObserver?: MutationObserver;
|
|
22
31
|
private closeTimer?;
|
|
32
|
+
private readonly instanceId;
|
|
33
|
+
/** 显式调用 setOptions() 后锁定为 options 数据源,重新挂载时不再被 slot 覆盖 */
|
|
34
|
+
private optionsSource;
|
|
35
|
+
/** setOptions() 设置的选项,重新挂载后优先于 options 属性 */
|
|
36
|
+
private manualOptions?;
|
|
37
|
+
/** 首次挂载完成后,属性变更才视为显式覆盖 */
|
|
38
|
+
private initialized;
|
|
39
|
+
/** 上次参与解析的 options 引用,用于发现 property 方式的异步赋值 */
|
|
40
|
+
private lastParsedOptions?;
|
|
41
|
+
/**
|
|
42
|
+
* 程序化 open() 所在的点击事件尚未结束时,忽略 document 的外部点击判定。
|
|
43
|
+
* 否则外部按钮在 click 里调用 open(),同一事件冒泡到 document 会立刻把下拉关掉。
|
|
44
|
+
*/
|
|
45
|
+
private ignoreOutsideClick;
|
|
46
|
+
/** 解除 ignoreOutsideClick 的定时器(等整次点击派发结束) */
|
|
47
|
+
private ignoreOutsideClickTimer?;
|
|
48
|
+
private _dropdown?;
|
|
49
|
+
private _overlay?;
|
|
50
|
+
private _stopObserve?;
|
|
23
51
|
/**
|
|
24
52
|
* 暴露 value 属性,使外部可通过 event.target.value 访问
|
|
53
|
+
* 多选时返回数组
|
|
54
|
+
*/
|
|
55
|
+
get value(): SelectValue;
|
|
56
|
+
/**
|
|
57
|
+
* 写入 value。disabled 只阻止用户交互,不阻止程序化同步,
|
|
58
|
+
* 避免外部值与内部值出现分叉。
|
|
59
|
+
*/
|
|
60
|
+
set value(newValue: SelectValue);
|
|
61
|
+
/**
|
|
62
|
+
* defaultValue:property 写入时同步 form reset 目标。
|
|
63
|
+
*
|
|
64
|
+
* property → attribute 的镜像不会触发 attributeChanged 钩子,
|
|
65
|
+
* 因此不能只依赖 attributeChanged 中的 setFormDefault。
|
|
25
66
|
*/
|
|
26
|
-
get
|
|
27
|
-
set
|
|
67
|
+
get defaultValue(): SelectValue;
|
|
68
|
+
set defaultValue(newValue: SelectValue);
|
|
69
|
+
/**
|
|
70
|
+
* 多选开关。切换为多选时把已有的单值归一化为数组。
|
|
71
|
+
*/
|
|
72
|
+
get multiple(): boolean;
|
|
73
|
+
set multiple(newValue: boolean);
|
|
74
|
+
created(): void;
|
|
75
|
+
formAssociatedCallback(): void;
|
|
76
|
+
formResetCallback(): void;
|
|
77
|
+
formDisabledCallback(disabled: boolean): void;
|
|
78
|
+
/** 公开有效性代理(C-FORM-16) */
|
|
79
|
+
get validity(): ValidityState;
|
|
80
|
+
get validationMessage(): string;
|
|
81
|
+
get willValidate(): boolean;
|
|
82
|
+
checkValidity(): boolean;
|
|
83
|
+
reportValidity(): boolean;
|
|
84
|
+
setCustomValidity(message: string): void;
|
|
85
|
+
/** 同步提交值 / 有效性 / ARIA(C-FORM-04) */
|
|
86
|
+
private syncFormState;
|
|
87
|
+
/** 字段名:property 优先,其次 attribute */
|
|
88
|
+
private formFieldName;
|
|
89
|
+
/** 承载 role="combobox" 的触发区 */
|
|
90
|
+
private getTriggerElement;
|
|
91
|
+
/** 触发区的 aria-disabled(包含 formDisabled) */
|
|
92
|
+
getAriaDisabled(): string;
|
|
93
|
+
getTabindex(): string;
|
|
94
|
+
/** required 且未选择任何值时判定 valueMissing */
|
|
95
|
+
private validateValue;
|
|
96
|
+
/** 读取显式 defaultValue;未显式设置时返回 undefined,由基座捕获初始值 */
|
|
97
|
+
private readExplicitDefaultValue;
|
|
28
98
|
/**
|
|
29
99
|
* 获取 select class 对象
|
|
30
100
|
*/
|
|
@@ -39,12 +109,36 @@ declare class SolelySelect extends BaseElement<SelectProps & {
|
|
|
39
109
|
getOptionClasses(option: SelectOptionType | {
|
|
40
110
|
value: string;
|
|
41
111
|
disabled?: boolean;
|
|
42
|
-
|
|
112
|
+
isGroup?: boolean;
|
|
113
|
+
}, index?: number): Record<string, boolean>;
|
|
114
|
+
/** 当前值是否命中给定选项值 */
|
|
115
|
+
isSelected(value: string): boolean;
|
|
116
|
+
/** 当前选中的所有值(单选取值数组长度为 1) */
|
|
117
|
+
getSelectedValues(): string[];
|
|
118
|
+
/** 将外部写入值归一化为内部存储结构 */
|
|
119
|
+
normalizeValue(value: SelectValue | null | undefined): SelectValue;
|
|
120
|
+
/** 多选值去重,保持首次出现顺序 */
|
|
121
|
+
private uniqueValues;
|
|
122
|
+
/**
|
|
123
|
+
* 用浮层基座的纯函数定位下拉层。
|
|
124
|
+
* 以实际测量高度参与 flip/shift,不再写死 256px;fixed 坐标系避免被祖先 overflow 裁剪。
|
|
125
|
+
*/
|
|
126
|
+
private positionDropdown;
|
|
127
|
+
/** 登记下拉浮层(z-index + Esc)并订阅重定位 */
|
|
128
|
+
private setupDropdown;
|
|
129
|
+
private teardownDropdown;
|
|
130
|
+
/** 是否为声明式选项子组件 */
|
|
131
|
+
private isDeclarativeOptionElement;
|
|
132
|
+
/**
|
|
133
|
+
* 读取插槽选项的值。
|
|
134
|
+
* 声明式组件读 `value`,兼容写法读 `data-value`。
|
|
135
|
+
*/
|
|
136
|
+
private getSlotOptionValue;
|
|
43
137
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
138
|
+
* 读取插槽选项的标签。
|
|
139
|
+
* 标签优先级:声明式 `label` / 兼容 `data-label` > 元素文本内容。
|
|
46
140
|
*/
|
|
47
|
-
|
|
141
|
+
private getSlotOptionLabel;
|
|
48
142
|
/**
|
|
49
143
|
* 从插槽收集选项
|
|
50
144
|
*/
|
|
@@ -56,59 +150,140 @@ declare class SolelySelect extends BaseElement<SelectProps & {
|
|
|
56
150
|
setupSlotObserver(): void;
|
|
57
151
|
unmounted(): void;
|
|
58
152
|
/**
|
|
59
|
-
*
|
|
60
|
-
* 当 s-model 等外部方式修改 value 时,需要更新 selectedLabel
|
|
153
|
+
* 数据更新后同步标签、插槽选中态与高亮
|
|
61
154
|
*/
|
|
62
155
|
updated(): void;
|
|
63
|
-
|
|
156
|
+
/** 渲染一份选项内容:图标 + 文本,或 render() 的自定义结果 */
|
|
157
|
+
private renderOptionContent;
|
|
158
|
+
/** 找到某个值对应的选项条目(插槽模式下附带原始元素) */
|
|
159
|
+
private findOptionEntry;
|
|
160
|
+
/** 把插槽选项的可视内容克隆到触发区,保证选中前后观感一致 */
|
|
161
|
+
private cloneSlotContent;
|
|
162
|
+
/** 同步下拉选项的可视内容(图标 / 自定义渲染) */
|
|
163
|
+
private syncOptionContents;
|
|
164
|
+
/** 同步触发区的已选内容:单选复用选项内容,多选渲染为标签 */
|
|
165
|
+
private syncValueContent;
|
|
166
|
+
/**
|
|
167
|
+
* options 属性在挂载后发生变化时重新解析
|
|
168
|
+
*
|
|
169
|
+
* 数据源优先级:options 属性(显式设置时)> setOptions() > 插槽。
|
|
170
|
+
* - 设置/修改 options 属性:以属性为准,丢弃 setOptions() 的锁定;
|
|
171
|
+
* - 移除 options 属性:若存在 setOptions() 锁定则恢复它,否则回到自动数据源(插槽优先)。
|
|
172
|
+
*/
|
|
173
|
+
attributeChanged(name: string): void;
|
|
64
174
|
/**
|
|
65
|
-
*
|
|
175
|
+
* 获取当前选中值对应的标签(支持多选)
|
|
176
|
+
* @param fallbackToValue 找不到选项时是否回退为原始值
|
|
66
177
|
*/
|
|
67
|
-
private
|
|
178
|
+
private getLabelsForValues;
|
|
68
179
|
/**
|
|
69
180
|
* 解析选项
|
|
70
181
|
*/
|
|
71
182
|
parseOptions(): void;
|
|
72
183
|
/**
|
|
73
184
|
* 更新选中的标签
|
|
185
|
+
* 多选时以顿号连接;值在另一数据源中不存在时保留原标签,避免混用时被静默清空
|
|
74
186
|
*/
|
|
75
187
|
syncSelectedLabel(): void;
|
|
188
|
+
/**
|
|
189
|
+
* 清理插槽元素上由组件写入的无障碍/选中状态
|
|
190
|
+
*/
|
|
191
|
+
private cleanupSlotOptionState;
|
|
192
|
+
/**
|
|
193
|
+
* 同步插槽选项的选中/高亮/ARIA 状态
|
|
194
|
+
*/
|
|
195
|
+
private syncSlotSelection;
|
|
196
|
+
/** listbox 的 id(shadow DOM 内唯一) */
|
|
197
|
+
getListboxId(): string;
|
|
198
|
+
/** 关闭态不下发 aria-controls */
|
|
199
|
+
getAriaControls(): string | null;
|
|
200
|
+
/** options 模式下某个选项的 id */
|
|
201
|
+
getOptionId(_option: SelectOptionType, index: number): string;
|
|
202
|
+
/** 当前高亮选项的 id,用于 aria-activedescendant;关闭或无可选项时为 null */
|
|
203
|
+
getActiveDescendantId(): string | null;
|
|
204
|
+
/** 数据源中的全部选项(含分组标题),索引与模板/插槽一一对应 */
|
|
205
|
+
private getAllOptions;
|
|
206
|
+
/** 分组标题与禁用项不可导航/不可选中 */
|
|
207
|
+
private isSelectableOption;
|
|
208
|
+
/** 对外可见的选项集合(分组标题不是合法选项) */
|
|
209
|
+
private getSelectableOptions;
|
|
210
|
+
/** 第一个/最后一个可导航项 */
|
|
211
|
+
private findBoundarySelectableIndex;
|
|
212
|
+
/** 把键盘高亮定位到已选项(没有则定位到第一个可选项) */
|
|
213
|
+
private syncActiveIndexToSelection;
|
|
214
|
+
/** 上下移动高亮(跳过禁用项/分组标题并循环) */
|
|
215
|
+
private moveActive;
|
|
216
|
+
/** 选中当前高亮项 */
|
|
217
|
+
private selectActive;
|
|
218
|
+
/** 首字母跳转(跳过禁用项/分组标题) */
|
|
219
|
+
private searchByChar;
|
|
220
|
+
/** 让组合框容器获得焦点 */
|
|
221
|
+
private focusTrigger;
|
|
76
222
|
/**
|
|
77
223
|
* 点击事件处理
|
|
224
|
+
* 下拉内容区(含空白处)的点击不应触发开合,避免多选时误关
|
|
225
|
+
*/
|
|
226
|
+
handleClick(event?: Event): void;
|
|
227
|
+
/**
|
|
228
|
+
* 键盘操作
|
|
229
|
+
* ArrowDown/ArrowUp 打开并移动高亮,Enter 选中,Escape 关闭,空格开合,字符首字母跳转
|
|
78
230
|
*/
|
|
79
|
-
|
|
231
|
+
handleKeydown(event: Event): void;
|
|
232
|
+
/** 打开下拉菜单(已打开时保留当前高亮,不重置) */
|
|
233
|
+
open(): void;
|
|
234
|
+
/** 关闭下拉菜单(立即关闭,不播放收起动画) */
|
|
235
|
+
close(): void;
|
|
80
236
|
/**
|
|
81
237
|
* 选择选项(来自 options 属性)
|
|
82
238
|
*/
|
|
83
|
-
handleSelect(option: SelectOptionType,
|
|
239
|
+
handleSelect(option: SelectOptionType, event: Event): void;
|
|
84
240
|
/**
|
|
85
241
|
* 处理插槽选项点击
|
|
86
242
|
*/
|
|
87
243
|
handleSlotClick(event: Event): void;
|
|
244
|
+
/**
|
|
245
|
+
* 统一的选择落地逻辑(options / slot / 键盘共用)
|
|
246
|
+
* 只有值真正变化时才派发 change
|
|
247
|
+
*/
|
|
248
|
+
private applySelection;
|
|
88
249
|
/**
|
|
89
250
|
* 处理 header/footer 点击,阻止事件冒泡避免关闭下拉框
|
|
90
251
|
*/
|
|
91
252
|
handleHeaderFooterClick(event: Event): void;
|
|
253
|
+
/** 清空选择(值确实存在时派发 clear + change) */
|
|
254
|
+
private clearValue;
|
|
92
255
|
/**
|
|
93
|
-
*
|
|
256
|
+
* 清除选择按钮
|
|
94
257
|
*/
|
|
95
|
-
handleClear(event:
|
|
258
|
+
handleClear(event: Event): void;
|
|
259
|
+
/** 清除按钮键盘激活:Enter / Space 等价点击 */
|
|
260
|
+
handleClearKeydown(event: KeyboardEvent): void;
|
|
261
|
+
/** 清空选择(公开方法) */
|
|
262
|
+
clear(): void;
|
|
96
263
|
/**
|
|
97
|
-
*
|
|
264
|
+
* 关闭下拉菜单(带收起动画,用于选择/点击外部)
|
|
98
265
|
*/
|
|
99
266
|
closeDropdown(): void;
|
|
100
267
|
/**
|
|
101
268
|
* 设置值
|
|
269
|
+
* 只有值真正变化时才派发 change;silent 或初始化/属性同步阶段不派发
|
|
102
270
|
*/
|
|
103
|
-
setValue(value:
|
|
271
|
+
setValue(value: SelectValue, silent?: boolean, source?: ChangeSource): void;
|
|
272
|
+
/** 判断两个值在语义上是否相同(数组按顺序比较) */
|
|
273
|
+
private valuesEqual;
|
|
104
274
|
/**
|
|
105
|
-
*
|
|
275
|
+
* 获取值(多选返回数组)
|
|
106
276
|
*/
|
|
107
|
-
getValue():
|
|
277
|
+
getValue(): SelectValue;
|
|
108
278
|
/**
|
|
109
279
|
* 设置选项
|
|
280
|
+
* 显式覆盖插槽数据源,重新挂载后也不会被 slot 覆盖
|
|
110
281
|
*/
|
|
111
282
|
setOptions(options: SelectOptionType[]): void;
|
|
283
|
+
/** 获取当前数据源的全部选项(保留 icon / render 等扩展字段) */
|
|
284
|
+
getOptions(): SelectOptionType[];
|
|
285
|
+
/** 派发 change(统一 CustomEvent 契约,带 name/value/previousValue/source) */
|
|
286
|
+
private dispatchChange;
|
|
112
287
|
}
|
|
113
288
|
export default SolelySelect;
|
|
114
289
|
export { SolelySelect };
|