@destyler/radio 0.0.1-beta.12 → 0.0.1-beta.14

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-PRESENT Elone Hoo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -154,7 +154,7 @@ const DestylerRadio = vue.defineComponent({
154
154
  passive: props.checked === void 0
155
155
  });
156
156
  const { value } = vue.toRefs(props);
157
- const { customElement, currentElement: triggerElement } = composition.useCustomElement();
157
+ const { forwardRef, currentElement: triggerElement } = composition.useForwardExpose();
158
158
  const isFormControl = composition.useFormControl(triggerElement);
159
159
  const ariaLabel = vue.computed(() => props.id && triggerElement.value ? document.querySelector(`[for="${props.id}"]`)?.textContent ?? props.value : void 0);
160
160
  function handleClick(event) {
@@ -163,7 +163,7 @@ const DestylerRadio = vue.defineComponent({
163
163
  event.stopPropagation();
164
164
  }
165
165
  return {
166
- customElement,
166
+ forwardRef,
167
167
  checkedRef,
168
168
  ariaLabel,
169
169
  value,
@@ -174,7 +174,7 @@ const DestylerRadio = vue.defineComponent({
174
174
  render() {
175
175
  return vue.withDirectives(vue.h(primitive.DestylerPrimitive, vue.mergeProps(this.$attrs, {
176
176
  "role": "radio",
177
- "ref": "customElement",
177
+ "ref": (el) => this.forwardRef(el),
178
178
  "type": this.$props.as === "button" ? "button" : void 0,
179
179
  "as": this.$props.as,
180
180
  "aria-checked": this.checkedRef,
@@ -250,7 +250,7 @@ const DestylerRadioGroupItem = vue.defineComponent({
250
250
  inheritAttrs: false,
251
251
  props: destylerRadioGroupItemProps,
252
252
  setup(props) {
253
- const { customElement, currentElement } = composition.useCustomElement();
253
+ const { forwardRef, currentElement } = composition.useForwardExpose();
254
254
  const rootContext = injectRadioGroupRootContext();
255
255
  const disabled = vue.computed(() => rootContext.disabled.value || props.disabled);
256
256
  const required = vue.computed(() => rootContext.required.value || props.required);
@@ -275,7 +275,7 @@ const DestylerRadioGroupItem = vue.defineComponent({
275
275
  checked,
276
276
  disabled,
277
277
  required,
278
- customElement,
278
+ forwardRef,
279
279
  rootContext,
280
280
  handleFocus
281
281
  };
@@ -288,7 +288,7 @@ const DestylerRadioGroupItem = vue.defineComponent({
288
288
  focusable: !this.disabled,
289
289
  active: this.checked
290
290
  }, vue.h(DestylerRadio, vue.mergeProps(this.$attrs, this.$props, {
291
- "ref": "customElement",
291
+ "ref": (el) => this.forwardRef(el),
292
292
  "checked": this.checked,
293
293
  "required": this.required,
294
294
  "onUpdate:checked": () => {
@@ -81,7 +81,7 @@ declare const DestylerRadio: vue.DefineComponent<{
81
81
  readonly required: false;
82
82
  };
83
83
  }, {
84
- customElement: vue.Ref<vue.ComponentPublicInstance | undefined>;
84
+ forwardRef: (ref: Element | vue.ComponentPublicInstance | null) => void;
85
85
  checkedRef: vue.WritableComputedRef<boolean | undefined>;
86
86
  ariaLabel: vue.ComputedRef<string | undefined>;
87
87
  value: vue.Ref<string | undefined>;
@@ -81,7 +81,7 @@ declare const DestylerRadio: vue.DefineComponent<{
81
81
  readonly required: false;
82
82
  };
83
83
  }, {
84
- customElement: vue.Ref<vue.ComponentPublicInstance | undefined>;
84
+ forwardRef: (ref: Element | vue.ComponentPublicInstance | null) => void;
85
85
  checkedRef: vue.WritableComputedRef<boolean | undefined>;
86
86
  ariaLabel: vue.ComputedRef<string | undefined>;
87
87
  value: vue.Ref<string | undefined>;
@@ -81,7 +81,7 @@ declare const DestylerRadio: vue.DefineComponent<{
81
81
  readonly required: false;
82
82
  };
83
83
  }, {
84
- customElement: vue.Ref<vue.ComponentPublicInstance | undefined>;
84
+ forwardRef: (ref: Element | vue.ComponentPublicInstance | null) => void;
85
85
  checkedRef: vue.WritableComputedRef<boolean | undefined>;
86
86
  ariaLabel: vue.ComputedRef<string | undefined>;
87
87
  value: vue.Ref<string | undefined>;
@@ -1,7 +1,7 @@
1
1
  import { defineComponent, toRefs, h, computed, withDirectives, mergeProps, withModifiers, ref } from 'vue';
2
2
  import { DestylerPrimitive } from '@destyler/primitive';
3
3
  import { createContext } from '@destyler/shared';
4
- import { useVModel, useDirection, useCustomElement, useFormControl } from '@destyler/composition';
4
+ import { useVModel, useDirection, useForwardExpose, useFormControl } from '@destyler/composition';
5
5
  import { DestylerRovingFocusGroup, DestylerRovingFocusItem } from '@destyler/roving-focus';
6
6
  import { useEventListener } from '@vueuse/core';
7
7
  import { BindOnceDirective } from '@destyler/directives';
@@ -152,7 +152,7 @@ const DestylerRadio = defineComponent({
152
152
  passive: props.checked === void 0
153
153
  });
154
154
  const { value } = toRefs(props);
155
- const { customElement, currentElement: triggerElement } = useCustomElement();
155
+ const { forwardRef, currentElement: triggerElement } = useForwardExpose();
156
156
  const isFormControl = useFormControl(triggerElement);
157
157
  const ariaLabel = computed(() => props.id && triggerElement.value ? document.querySelector(`[for="${props.id}"]`)?.textContent ?? props.value : void 0);
158
158
  function handleClick(event) {
@@ -161,7 +161,7 @@ const DestylerRadio = defineComponent({
161
161
  event.stopPropagation();
162
162
  }
163
163
  return {
164
- customElement,
164
+ forwardRef,
165
165
  checkedRef,
166
166
  ariaLabel,
167
167
  value,
@@ -172,7 +172,7 @@ const DestylerRadio = defineComponent({
172
172
  render() {
173
173
  return withDirectives(h(DestylerPrimitive, mergeProps(this.$attrs, {
174
174
  "role": "radio",
175
- "ref": "customElement",
175
+ "ref": (el) => this.forwardRef(el),
176
176
  "type": this.$props.as === "button" ? "button" : void 0,
177
177
  "as": this.$props.as,
178
178
  "aria-checked": this.checkedRef,
@@ -248,7 +248,7 @@ const DestylerRadioGroupItem = defineComponent({
248
248
  inheritAttrs: false,
249
249
  props: destylerRadioGroupItemProps,
250
250
  setup(props) {
251
- const { customElement, currentElement } = useCustomElement();
251
+ const { forwardRef, currentElement } = useForwardExpose();
252
252
  const rootContext = injectRadioGroupRootContext();
253
253
  const disabled = computed(() => rootContext.disabled.value || props.disabled);
254
254
  const required = computed(() => rootContext.required.value || props.required);
@@ -273,7 +273,7 @@ const DestylerRadioGroupItem = defineComponent({
273
273
  checked,
274
274
  disabled,
275
275
  required,
276
- customElement,
276
+ forwardRef,
277
277
  rootContext,
278
278
  handleFocus
279
279
  };
@@ -286,7 +286,7 @@ const DestylerRadioGroupItem = defineComponent({
286
286
  focusable: !this.disabled,
287
287
  active: this.checked
288
288
  }, h(DestylerRadio, mergeProps(this.$attrs, this.$props, {
289
- "ref": "customElement",
289
+ "ref": (el) => this.forwardRef(el),
290
290
  "checked": this.checked,
291
291
  "required": this.required,
292
292
  "onUpdate:checked": () => {
package/dist/index.d.cts CHANGED
@@ -247,7 +247,7 @@ declare const DestylerRadioGroupItem: vue.DefineComponent<{
247
247
  checked: ComputedRef<boolean>;
248
248
  disabled: ComputedRef<boolean>;
249
249
  required: ComputedRef<boolean | undefined>;
250
- customElement: vue.Ref<vue.ComponentPublicInstance | undefined>;
250
+ forwardRef: (ref: Element | vue.ComponentPublicInstance | null) => void;
251
251
  rootContext: RadioGroupRootContext;
252
252
  handleFocus: () => void;
253
253
  }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
package/dist/index.d.mts CHANGED
@@ -247,7 +247,7 @@ declare const DestylerRadioGroupItem: vue.DefineComponent<{
247
247
  checked: ComputedRef<boolean>;
248
248
  disabled: ComputedRef<boolean>;
249
249
  required: ComputedRef<boolean | undefined>;
250
- customElement: vue.Ref<vue.ComponentPublicInstance | undefined>;
250
+ forwardRef: (ref: Element | vue.ComponentPublicInstance | null) => void;
251
251
  rootContext: RadioGroupRootContext;
252
252
  handleFocus: () => void;
253
253
  }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
package/dist/index.d.ts CHANGED
@@ -247,7 +247,7 @@ declare const DestylerRadioGroupItem: vue.DefineComponent<{
247
247
  checked: ComputedRef<boolean>;
248
248
  disabled: ComputedRef<boolean>;
249
249
  required: ComputedRef<boolean | undefined>;
250
- customElement: vue.Ref<vue.ComponentPublicInstance | undefined>;
250
+ forwardRef: (ref: Element | vue.ComponentPublicInstance | null) => void;
251
251
  rootContext: RadioGroupRootContext;
252
252
  handleFocus: () => void;
253
253
  }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@destyler/radio",
3
- "version": "0.0.1-beta.12",
3
+ "version": "0.0.1-beta.14",
4
4
  "description": "unstyled radio component for vue",
5
5
  "author": "Elone Hoo <elonehoo@gmail.com>",
6
6
  "license": "MIT",
@@ -34,11 +34,11 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@vueuse/core": "^10.7.2",
37
- "@destyler/composition": "0.0.1-beta.12",
38
- "@destyler/directives": "0.0.1-beta.12",
39
- "@destyler/shared": "0.0.1-beta.12",
40
- "@destyler/primitive": "0.0.1-beta.12",
41
- "@destyler/roving-focus": "0.0.1-beta.12"
37
+ "@destyler/composition": "0.0.1-beta.14",
38
+ "@destyler/directives": "0.0.1-beta.14",
39
+ "@destyler/roving-focus": "0.0.1-beta.14",
40
+ "@destyler/primitive": "0.0.1-beta.14",
41
+ "@destyler/shared": "0.0.1-beta.14"
42
42
  },
43
43
  "scripts": {
44
44
  "clear": "rimraf ./dist",