@revojs/ui 0.3.9 → 0.3.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ import type { StackProps } from "./stack";
2
+ export interface SettingProps extends StackProps {
3
+ label: string;
4
+ description?: string;
5
+ error?: string;
6
+ for?: string;
7
+ disabled?: boolean;
8
+ }
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.d.ts CHANGED
@@ -32,6 +32,7 @@ export type * from "./components/rating";
32
32
  export type * from "./components/roving-focus";
33
33
  export type * from "./components/select";
34
34
  export type * from "./components/separator";
35
+ export type * from "./components/setting";
35
36
  export type * from "./components/sheet";
36
37
  export type * from "./components/shell";
37
38
  export type * from "./components/stack";
@@ -1,5 +1,6 @@
1
1
  <template>
2
2
  <Stack
3
+ v-bind="rootAttributes"
3
4
  is="label"
4
5
  direction="horizontal"
5
6
  align="start"
@@ -9,6 +10,7 @@
9
10
  >
10
11
  <input
11
12
  ref="input"
13
+ v-bind="controlAttributes"
12
14
  class="peer sr-only"
13
15
  type="checkbox"
14
16
  :checked="modelValue"
@@ -51,6 +53,7 @@
51
53
  import { computed, useTemplateRef, watchEffect } from "vue";
52
54
  import type { CheckboxProps } from "../../components/checkbox";
53
55
  import type { ControlInteraction } from "../../components/control.ts";
56
+ import { useControlAttributes } from "../utilities/use-control-attributes";
54
57
  import Stack from "./stack.vue";
55
58
 
56
59
  const {
@@ -63,6 +66,10 @@ const {
63
66
  disabled = false,
64
67
  } = defineProps<CheckboxProps>();
65
68
 
69
+ defineOptions({ inheritAttrs: false });
70
+
71
+ const { rootAttributes, controlAttributes } = useControlAttributes();
72
+
66
73
  defineEmits<{
67
74
  "update:modelValue": [value: boolean];
68
75
  }>();
@@ -0,0 +1,55 @@
1
+ <template>
2
+ <Stack
3
+ :padding="padding"
4
+ :gap="gap"
5
+ :direction="direction"
6
+ :align="align"
7
+ :justify="justify"
8
+ :wrap="wrap"
9
+ class="min-w-0 text-sm"
10
+ :class="disabled ? 'opacity-50' : ''"
11
+ >
12
+ <Stack gap="0" class="min-w-48 flex-1">
13
+ <component :is="controlId ? 'label' : 'span'" :id="`${id}-label`" :for="controlId" class="font-normal">
14
+ {{ label }}
15
+ </component>
16
+
17
+ <p v-if="error" :id="`${id}-error`" role="alert" class="text-destructive">{{ error }}</p>
18
+ <p v-else-if="description" :id="`${id}-description`" class="opacity-60">{{ description }}</p>
19
+ </Stack>
20
+
21
+ <Stack v-if="$slots.default" direction="horizontal" align="center" gap="1" class="shrink-0">
22
+ <slot :control="controlAttributes" />
23
+ </Stack>
24
+ </Stack>
25
+ </template>
26
+
27
+ <script setup lang="ts">
28
+ import { computed, useId } from "vue";
29
+ import type { SettingProps } from "../../components/setting";
30
+ import Stack from "./stack.vue";
31
+
32
+ const {
33
+ label,
34
+ description,
35
+ error,
36
+ for: controlId,
37
+ disabled = false,
38
+ padding = "0",
39
+ gap = "5",
40
+ direction = "horizontal",
41
+ align = "center",
42
+ justify = "between",
43
+ wrap = true,
44
+ } = defineProps<SettingProps>();
45
+
46
+ const id = `setting-${useId()}`;
47
+
48
+ const controlAttributes = computed(() => ({
49
+ id: controlId,
50
+ disabled,
51
+ "aria-labelledby": controlId ? undefined : `${id}-label`,
52
+ "aria-describedby": error ? `${id}-error` : description ? `${id}-description` : undefined,
53
+ "aria-invalid": error ? true : undefined,
54
+ }));
55
+ </script>
@@ -1,5 +1,6 @@
1
1
  <template>
2
2
  <Stack
3
+ v-bind="rootAttributes"
3
4
  is="label"
4
5
  direction="horizontal"
5
6
  align="start"
@@ -10,6 +11,7 @@
10
11
  <input v-if="name" type="hidden" :name="name" :value="modelValue ? 'on' : 'off'" />
11
12
 
12
13
  <button
14
+ v-bind="controlAttributes"
13
15
  class="relative flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-ui p-0.5 outline-ring focus-visible:outline-2 focus-visible:outline-offset-2 disabled:cursor-not-allowed"
14
16
  :class="[
15
17
  variants[state],
@@ -42,10 +44,15 @@
42
44
  import { computed } from "vue";
43
45
  import type { ControlInteraction } from "../../components/control.ts";
44
46
  import type { SwitchProps, SwitchState } from "../../components/switch";
47
+ import { useControlAttributes } from "../utilities/use-control-attributes";
45
48
  import Stack from "./stack.vue";
46
49
 
47
50
  const { modelValue = false, label, description, name, disabled = false } = defineProps<SwitchProps>();
48
51
 
52
+ defineOptions({ inheritAttrs: false });
53
+
54
+ const { rootAttributes, controlAttributes } = useControlAttributes();
55
+
49
56
  defineEmits<{
50
57
  "update:modelValue": [value: boolean];
51
58
  }>();
@@ -36,6 +36,7 @@ export { default as Range } from "./components/range.vue";
36
36
  export { default as Rating } from "./components/rating.vue";
37
37
  export { default as Select } from "./components/select.vue";
38
38
  export { default as Separator } from "./components/separator.vue";
39
+ export { default as Setting } from "./components/setting.vue";
39
40
  export { default as Sheet } from "./components/sheet.vue";
40
41
  export { default as Shell } from "./components/shell.vue";
41
42
  export { default as Stack } from "./components/stack.vue";
package/dist/vue/index.js CHANGED
@@ -48,6 +48,7 @@ import Range from "./components/range.vue";
48
48
  import Rating from "./components/rating.vue";
49
49
  import Select from "./components/select.vue";
50
50
  import Separator from "./components/separator.vue";
51
+ import Setting from "./components/setting.vue";
51
52
  import Sheet from "./components/sheet.vue";
52
53
  import Shell from "./components/shell.vue";
53
54
  import Stack from "./components/stack.vue";
@@ -61,4 +62,4 @@ import ToggleGroup from "./components/toggle-group.vue";
61
62
  import Toolbar from "./components/toolbar.vue";
62
63
  import Tooltip from "./components/tooltip.vue";
63
64
  import Upload from "./components/upload.vue";
64
- export { Accordion, Badge, Breadcrumb, Button, Card, Checkbox, Collapsible, Collection, ConfirmDialog, Container, ContextMenu, Counter, Dialog, Entry, Field, Heading, Icon, Input, Link, Markdown, Menu, MenuCheckboxItem, MenuGroup, MenuItem, MenuLayer, MenuRadioGroup, MenuRadioItem, Navigate, Notification, Pagination, Popover, Progress, Radio, RadioGroup, Range, Rating, Select, Separator, Sheet, Shell, Stack, Stepper, Switch, Tabs, TagsInput, Textarea, ToastRegion, ToggleGroup, Toolbar, Tooltip, Upload, defaultUiLabels, germanUiLabels, isTypeaheadKey, menuCloseKey, menuItemSelector, menuRadioKey, menuSizeKey, provideUiLabels, tooltipState, uiLabelsKey, useAnchor, useConfirm, useControlAttributes, useMenuNavigation, useModalDialog, useRovingFocus, useScrollLock, useToast, useTypeahead, useUiLabels };
65
+ export { Accordion, Badge, Breadcrumb, Button, Card, Checkbox, Collapsible, Collection, ConfirmDialog, Container, ContextMenu, Counter, Dialog, Entry, Field, Heading, Icon, Input, Link, Markdown, Menu, MenuCheckboxItem, MenuGroup, MenuItem, MenuLayer, MenuRadioGroup, MenuRadioItem, Navigate, Notification, Pagination, Popover, Progress, Radio, RadioGroup, Range, Rating, Select, Separator, Setting, Sheet, Shell, Stack, Stepper, Switch, Tabs, TagsInput, Textarea, ToastRegion, ToggleGroup, Toolbar, Tooltip, Upload, defaultUiLabels, germanUiLabels, isTypeaheadKey, menuCloseKey, menuItemSelector, menuRadioKey, menuSizeKey, provideUiLabels, tooltipState, uiLabelsKey, useAnchor, useConfirm, useControlAttributes, useMenuNavigation, useModalDialog, useRovingFocus, useScrollLock, useToast, useTypeahead, useUiLabels };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revojs/ui",
3
- "version": "0.3.9",
3
+ "version": "0.3.10",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -35,14 +35,14 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@iconify-json/hugeicons": "^1.2.35",
38
- "@revojs/client": "0.3.9",
38
+ "@revojs/client": "0.3.10",
39
39
  "@tailwindcss/vite": "^4.3.3",
40
- "revojs": "0.3.9",
40
+ "revojs": "0.3.10",
41
41
  "tailwindcss": "^4.3.3",
42
42
  "unplugin-icons": "^24.0.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@revojs/tsconfig": "0.3.9",
45
+ "@revojs/tsconfig": "0.3.10",
46
46
  "@vitejs/plugin-vue": "^6.0.9"
47
47
  },
48
48
  "optionalDependencies": {