vue-composable-ui 0.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +5 -1
  3. package/dist/combobox.vue_vue_type_script_setup_true_lang-BhVMcx67.js +140 -0
  4. package/dist/comboboxHiddenInput.vue_vue_type_script_setup_true_lang-Ba-UPd-M.js +29 -0
  5. package/dist/comboboxInput.vue_vue_type_script_setup_true_lang-DzRfJ5ke.js +33 -0
  6. package/dist/comboboxOption.vue_vue_type_script_setup_true_lang-OyJxB4Jk.js +42 -0
  7. package/dist/comboboxOptions.vue_vue_type_script_setup_true_lang-Doy6MfEQ.js +20 -0
  8. package/dist/composable-ui.js +49 -0
  9. package/dist/composable-ui10.js +4 -0
  10. package/dist/composable-ui11.js +4 -0
  11. package/dist/composable-ui12.js +4 -0
  12. package/dist/composable-ui13.js +4 -0
  13. package/dist/composable-ui14.js +4 -0
  14. package/dist/composable-ui15.js +4 -0
  15. package/dist/composable-ui16.js +4 -0
  16. package/dist/composable-ui17.js +31 -0
  17. package/dist/composable-ui18.js +4 -0
  18. package/dist/composable-ui19.js +4 -0
  19. package/dist/composable-ui2.js +55 -0
  20. package/dist/composable-ui20.js +4 -0
  21. package/dist/composable-ui21.js +100 -0
  22. package/dist/composable-ui22.js +144 -0
  23. package/dist/composable-ui23.js +7 -0
  24. package/dist/composable-ui24.js +7 -0
  25. package/dist/composable-ui3.js +4 -0
  26. package/dist/composable-ui4.js +4 -0
  27. package/dist/composable-ui5.js +4 -0
  28. package/dist/composable-ui6.js +4 -0
  29. package/dist/composable-ui7.js +4 -0
  30. package/dist/composable-ui8.js +4 -0
  31. package/dist/composable-ui9.js +4 -0
  32. package/dist/listbox.vue_vue_type_script_setup_true_lang-Bj1ZXiBX.js +69 -0
  33. package/dist/listboxOption.vue_vue_type_script_setup_true_lang-B_yRptJm.js +37 -0
  34. package/dist/menu.vue_vue_type_script_setup_true_lang-Ci7q2rOg.js +82 -0
  35. package/dist/menuItem.vue_vue_type_script_setup_true_lang-mXtMa4gO.js +63 -0
  36. package/dist/menuItems.vue_vue_type_script_setup_true_lang-p9vftREy.js +49 -0
  37. package/dist/popover.vue_vue_type_script_setup_true_lang-DhKF7_nY.js +50 -0
  38. package/dist/popoverDialog.vue_vue_type_script_setup_true_lang-CDXUO7wZ.js +33 -0
  39. package/dist/tab.vue_vue_type_script_setup_true_lang-Y5OFGqMB.js +29 -0
  40. package/dist/tabContainer.vue_vue_type_script_setup_true_lang-fPpLno2Z.js +40 -0
  41. package/dist/tabList.vue_vue_type_script_setup_true_lang-CZyqGCuj.js +48 -0
  42. package/dist/tabPanel.vue_vue_type_script_setup_true_lang-CGhP6SHR.js +31 -0
  43. package/dist/tooltip.vue_vue_type_script_setup_true_lang-DVKYJyfL.js +85 -0
  44. package/dist/types/components/combobox/combobox.vue.d.ts +45 -0
  45. package/dist/types/components/combobox/comboboxHiddenInput.vue.d.ts +6 -0
  46. package/dist/types/components/combobox/comboboxInput.vue.d.ts +9 -0
  47. package/dist/types/components/combobox/comboboxOption.vue.d.ts +20 -0
  48. package/dist/types/components/combobox/comboboxOptions.vue.d.ts +12 -0
  49. package/dist/types/components/injectionKeys.d.ts +43 -0
  50. package/dist/types/components/listbox/listbox.vue.d.ts +26 -0
  51. package/dist/types/components/listbox/listboxOption.vue.d.ts +20 -0
  52. package/dist/types/components/menu/menu.vue.d.ts +42 -0
  53. package/dist/types/components/menu/menuItem.vue.d.ts +24 -0
  54. package/dist/types/components/menu/menuItems.vue.d.ts +12 -0
  55. package/dist/types/components/popover/popover.vue.d.ts +40 -0
  56. package/dist/types/components/popover/popoverDialog.vue.d.ts +12 -0
  57. package/dist/types/components/tabs/tab.vue.d.ts +17 -0
  58. package/dist/types/components/tabs/tabContainer.vue.d.ts +19 -0
  59. package/dist/types/components/tabs/tabList.vue.d.ts +17 -0
  60. package/dist/types/components/tabs/tabPanel.vue.d.ts +15 -0
  61. package/dist/types/components/tooltip.vue.d.ts +34 -0
  62. package/dist/types/composables/formControl.d.ts +48 -0
  63. package/dist/types/composables/list.d.ts +107 -0
  64. package/dist/types/composables/listOption.d.ts +34 -0
  65. package/dist/types/composables/popover.d.ts +68 -0
  66. package/dist/types/main.d.ts +22 -0
  67. package/dist/types/utils/element.d.ts +3 -0
  68. package/package.json +28 -12
  69. package/.github/workflows/deploy.yml +0 -21
  70. package/.github/workflows/docs.yml +0 -62
  71. package/.vscode/extensions.json +0 -7
  72. package/docs/.vitepress/config.mts +0 -40
  73. package/docs/.vitepress/theme/index.js +0 -4
  74. package/docs/.vitepress/theme/style.scss +0 -155
  75. package/docs/components/combobox.md +0 -174
  76. package/docs/components/demos/combobox.vue +0 -142
  77. package/docs/components/demos/combobox_autocomplete.vue +0 -75
  78. package/docs/components/demos/combobox_tags.vue +0 -127
  79. package/docs/components/demos/input.vue +0 -35
  80. package/docs/components/demos/listbox.vue +0 -64
  81. package/docs/components/demos/menu.vue +0 -93
  82. package/docs/components/demos/popover.vue +0 -16
  83. package/docs/components/demos/tabs.vue +0 -59
  84. package/docs/components/demos/tooltip.vue +0 -27
  85. package/docs/components/listbox.md +0 -9
  86. package/docs/components/menu.md +0 -121
  87. package/docs/components/popover.md +0 -82
  88. package/docs/components/tabs.md +0 -9
  89. package/docs/components/tooltip.md +0 -78
  90. package/docs/composables/form-control.md +0 -130
  91. package/docs/composables/list-option.md +0 -47
  92. package/docs/composables/list.md +0 -192
  93. package/docs/composables/popover.md +0 -90
  94. package/docs/index.md +0 -24
  95. package/docs/intro.md +0 -0
  96. package/src/components/combobox/combobox.vue +0 -229
  97. package/src/components/combobox/comboboxFormInput.vue +0 -33
  98. package/src/components/combobox/comboboxOption.vue +0 -52
  99. package/src/components/combobox/comboboxOptions.vue +0 -17
  100. package/src/components/injectionKeys.ts +0 -50
  101. package/src/components/listbox/listbox.vue +0 -91
  102. package/src/components/listbox/listboxOption.vue +0 -37
  103. package/src/components/menu/menu.vue +0 -100
  104. package/src/components/menu/menuItem.vue +0 -86
  105. package/src/components/menu/menuItems.vue +0 -51
  106. package/src/components/popover/popover.vue +0 -68
  107. package/src/components/popover/popoverDialog.vue +0 -35
  108. package/src/components/tabs/tab.vue +0 -35
  109. package/src/components/tabs/tabContainer.vue +0 -50
  110. package/src/components/tabs/tabList.vue +0 -52
  111. package/src/components/tabs/tabPanel.vue +0 -36
  112. package/src/components/tooltip.vue +0 -115
  113. package/src/composables/formControl.ts +0 -144
  114. package/src/composables/list.ts +0 -326
  115. package/src/composables/listOption.ts +0 -80
  116. package/src/composables/popover.ts +0 -306
  117. package/src/main.ts +0 -65
  118. package/src/utils/element.ts +0 -19
  119. package/src/utils/id.ts +0 -5
  120. package/src/vite-env.d.ts +0 -1
  121. package/tsconfig.json +0 -27
  122. package/tsconfig.node.json +0 -10
  123. package/vite.config.ts +0 -28
@@ -1,93 +0,0 @@
1
- <template>
2
- <div class="d-demo">
3
- <Menu v-slot="{ attrs }">
4
- <button v-bind="attrs" class="d-btn">Basic Example</button>
5
-
6
- <MenuItems class="d-menu">
7
- <MenuItem @select="onSelect('Item 1')" class="d-menu-item"
8
- >Item 1</MenuItem
9
- >
10
- <MenuItem @select="onSelect('Item 2')" class="d-menu-item"
11
- >Item 2</MenuItem
12
- >
13
- <MenuItem @select="onSelect('Item 3')" class="d-menu-item"
14
- >Item 3</MenuItem
15
- >
16
- </MenuItems>
17
- </Menu>
18
-
19
- <Menu v-model="color" align="right" v-slot="{ attrs }">
20
- <button v-bind="attrs" :style="{ backgroundColor: color }" class="d-btn">
21
- Radio Items
22
- <span v-if="color">({{ color }})</span>
23
- </button>
24
-
25
- <MenuItems class="d-menu">
26
- <MenuItem
27
- v-for="(color, name) in colors"
28
- :value="color"
29
- class="d-menu-item"
30
- v-slot="{ isSelected }"
31
- >
32
- <span :style="{ fontWeight: isSelected ? 'bold' : 'normal' }">
33
- {{ name }}
34
- </span>
35
- </MenuItem>
36
- </MenuItems>
37
- </Menu>
38
-
39
- <Menu v-model="option" align="stretch" v-slot="{ attrs }">
40
- <button v-bind="attrs" class="d-btn">Checkbox Items</button>
41
-
42
- <MenuItems class="d-menu">
43
- <MenuItem
44
- v-for="(option, name) in options"
45
- :value="option"
46
- class="d-menu-item"
47
- v-slot="{ isSelected }"
48
- >
49
- {{ name }}
50
- <svg
51
- v-if="isSelected"
52
- xmlns="http://www.w3.org/2000/svg"
53
- width="1rem"
54
- height="1rem"
55
- viewBox="0 0 256 256"
56
- >
57
- <path
58
- fill="currentColor"
59
- d="m232.49 80.49l-128 128a12 12 0 0 1-17 0l-56-56a12 12 0 1 1 17-17L96 183L215.51 63.51a12 12 0 0 1 17 17Z"
60
- />
61
- </svg>
62
- </MenuItem>
63
- <hr />
64
- <MenuItem disabled class="d-menu-item">Disabled item</MenuItem>
65
- </MenuItems>
66
- </Menu>
67
- </div>
68
- </template>
69
-
70
- <script setup lang="ts">
71
- import { ref } from "vue";
72
- import { Menu, MenuItems, MenuItem } from "../../../src/main";
73
-
74
- const colors = {
75
- Blue: "#007bff",
76
- Purple: "#6f42c1",
77
- Pink: "#e83e8c",
78
- Red: "#dc3545",
79
- };
80
- const color = ref();
81
-
82
- const options = {
83
- "Option 1": 1,
84
- "Option 2": 2,
85
- "Option 3": 3,
86
- "Option 4": 4,
87
- };
88
- const option = ref([]);
89
-
90
- function onSelect(msg: string) {
91
- alert(msg);
92
- }
93
- </script>
@@ -1,16 +0,0 @@
1
- <template>
2
- <div class="d-demo">
3
- <Popover direction="right" align="center" v-slot="{ attrs, toggle, close }">
4
- <button @click="toggle" v-bind="attrs" class="d-btn">Toggle</button>
5
-
6
- <PopoverDialog class="d-popover d-popover--h">
7
- <div>Any HTML content &#x1F61C;</div>
8
- <button @click="close()" class="d-btn">Close</button>
9
- </PopoverDialog>
10
- </Popover>
11
- </div>
12
- </template>
13
-
14
- <script setup lang="ts">
15
- import { Popover, PopoverDialog } from "../../../src/main";
16
- </script>
@@ -1,59 +0,0 @@
1
- <template>
2
- <TabContainer v-model="currentTab">
3
- <TabList class="tab-list">
4
- <Tab v-for="(tab, i) in Object.keys(tabs)" :value="i" class="tab">
5
- {{ tab }}
6
- </Tab>
7
- </TabList>
8
-
9
- <TabPanel
10
- v-for="(tab, i) in Object.values(tabs)"
11
- :value="i"
12
- class="tab-panel"
13
- >
14
- {{ tab }}
15
- </TabPanel>
16
- </TabContainer>
17
- </template>
18
-
19
- <script setup lang="ts">
20
- import { ref } from "vue";
21
- import { TabContainer, TabList, Tab, TabPanel } from "../../../src/main";
22
-
23
- const tabs = {
24
- "Tab 1": "Tab Panel 1",
25
- "Tab 2": "Tab Panel 2",
26
- };
27
-
28
- const currentTab = ref(0);
29
- </script>
30
-
31
- <style>
32
- .tab-list {
33
- padding: 0.25rem;
34
- display: flex;
35
- gap: 0.25rem;
36
- }
37
- .tab {
38
- padding: 0.25rem 0.5rem;
39
- border-radius: 0.25rem 0.25rem 0 0;
40
- width: 100%;
41
- background-color: Lavender;
42
- }
43
- .tab:focus {
44
- z-index: 10;
45
- }
46
- .tab[aria-selected="false"]:hover {
47
- background-color: LightSkyBlue;
48
- }
49
- .tab[aria-selected="true"] {
50
- background-color: blue;
51
- color: white;
52
- }
53
- .tab-panel {
54
- padding: 1.5rem;
55
- border: 2px blue solid;
56
- border-radius: 0.5rem;
57
- text-align: center;
58
- }
59
- </style>
@@ -1,27 +0,0 @@
1
- <template>
2
- <div class="d-demo">
3
- <Tooltip text="Tooltip text" v-slot="{ attrs }" class="d-tooltip">
4
- <button v-bind="attrs" class="d-btn">Basic</button>
5
- </Tooltip>
6
-
7
- <Tooltip
8
- text="Tooltip text"
9
- delay="1000"
10
- v-slot="{ attrs }"
11
- class="d-tooltip"
12
- >
13
- <button v-bind="attrs" class="d-btn">Delayed</button>
14
- </Tooltip>
15
-
16
- <Tooltip id="tooltip-demo" class="d-tooltip">
17
- <template #content>Any HTML content &#x1F61C;</template>
18
- </Tooltip>
19
- <button aria-describedby="tooltip-demo" class="d-btn">
20
- Custom content
21
- </button>
22
- </div>
23
- </template>
24
-
25
- <script setup lang="ts">
26
- import { Tooltip } from "../../../src/main";
27
- </script>
@@ -1,9 +0,0 @@
1
- <script setup>
2
- import ListDemo from './demos/listbox.vue'
3
- </script>
4
-
5
- # List Components
6
-
7
- ## Demo
8
-
9
- <ListDemo />
@@ -1,121 +0,0 @@
1
- <script setup>
2
- import MenuDemo from './demos/menu.vue'
3
- </script>
4
-
5
- # Menu Components
6
-
7
- A composite widget that offers a list of choices to the user.
8
-
9
- Based on:
10
-
11
- - [usePopover](/composables/popover)
12
- - [useList](/composables/list)
13
- - [useListOption](/composables/list-option)
14
-
15
- ## Demo
16
-
17
- <MenuDemo />
18
-
19
- ::: details Code
20
- <<< ./demos/menu.vue
21
- :::
22
-
23
- ## Menu
24
-
25
- The root component.
26
-
27
- ### Properties
28
-
29
- | Property | Required | Description | Type | Default |
30
- | --------------- | -------- | ------------------------------------------------------------- | --------------------------------------------------------------------------- | -------------- |
31
- | **modelValue** | false | The selected value. Set to an array to enable multiselection. | `any` \| `any[]` | `undefined` |
32
- | **direction** | false | The direction of the menu. | `'up'` \| `'down'` \| `'left'` \| `'right'` | `'down'` |
33
- | **align** | false | The alignment of the menu. | `'top'` \| `'bottom'` \| `'left'` \| `'right'` \| `'center'` \| `'stretch'` | `'left'` |
34
- | **position** | false | CSS position of the menu panel. | `'fixed'` \| `'absolute'` | `'fixed'` |
35
- | **id** | false | The ID of the menu panel. | `string` | auto-generated |
36
- | **activatorId** | false | The ID of the activator element. | `string` | auto-generated |
37
-
38
- ### Slots
39
-
40
- #### default
41
-
42
- The `default` slot is used to provide an activator and a list of menu items in the [MenuItems](#menuitems) component. It provides the `attrs` property that must be binded to the activating element.
43
-
44
- ```vue-html
45
- <Menu v-slot="{ attrs }">
46
- <button v-bind="attrs">Toggle Menu</button>
47
-
48
- <MenuItems>
49
- <MenuItem @select="/* do smth. */">Item 1</MenuItem>
50
- </MenuItems>
51
- </Menu>
52
- ```
53
-
54
- ### Keyboard interactions
55
-
56
- Binding the props to the activating element adds the following keyboard interactions:
57
-
58
- - `Space` / `Enter` - Opens the menu and places focus on the first item. Or closes the menu and returns focus to the activating element.
59
- - `Down Arrow` - Opens the menu and moves focus to the first item.
60
- - `Up Arrow` - Opens the menu and moves focus to the last item.
61
-
62
- ### ARIA roles and attributes
63
-
64
- The following attributes are managed for the activator:
65
-
66
- - [aria-controls](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-controls)
67
- - [aria-haspopup](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-haspopup)
68
- - [aria-expanded](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-expanded)
69
-
70
- ## MenuItems
71
-
72
- A component to hold a collection of menu items.
73
-
74
- ### Keyboard interactions
75
-
76
- - `Escape` - Closes the menu and returns focus to the activating element.
77
- - `Tab` - Closes the menu.
78
- - `Down Arrow` - Moves focus to the next item.
79
- - `Up Arrow` - Moves focus to the previous item.
80
- - `Home` - Moves focus to the first item.
81
- - `End` - Moves focus to the last item.
82
-
83
- ### ARIA roles and attributes
84
-
85
- The menu container has the [menu](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/menu_role) role and automatically manages the following attributes:
86
-
87
- - [aria-activedescendant](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-activedescendant)
88
- - [aria-labelledby](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-labelledby)
89
-
90
- ## MenuItem
91
-
92
- ### Properties
93
-
94
- | Property | Required | Description | Type | Default |
95
- | ------------ | -------- | ----------------------------- | --------- | -------------- |
96
- | **value** | false | Value assigned to the item. | `any` | `undefined` |
97
- | **disabled** | false | Whether the item is disabled. | `boolean` | `false` |
98
- | **id** | false | The ID of the item. | `string` | auto-generated |
99
-
100
- ### Slots
101
-
102
- #### default
103
-
104
- | Attribute | Description | Type |
105
- | -------------- | ------------------------------------- | --------- |
106
- | **isSelected** | Whether the item is selected. | `boolean` |
107
- | **isActive** | Whether the item is active (focused). | `boolean` |
108
-
109
- ### Keyboard interactions
110
-
111
- - `Enter` - Selects the item and closes the menu.
112
- - `Space` - Selects the item if it has a value set, otherwise closes the menu.
113
-
114
- ### ARIA roles and attributes
115
-
116
- if an item has no value set, it will be given the [menuitem](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/menuitem_role) role. Otherwise, it will be given the [menuitemradio](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/menuitemradio_role) or [menuitemcheckbox](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/menuitemcheckbox_role) (if `modelValue` is an array) role.
117
-
118
- The following attributes are automatically managed:
119
-
120
- - [aria-checked](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-checked)
121
- - [aria-disabled](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-disabled)
@@ -1,82 +0,0 @@
1
- <script setup>
2
- import PopoverDemo from './demos/popover.vue'
3
- </script>
4
-
5
- # Popover Component
6
-
7
- Popover is a floating container that appears next to its activator element above the main document flow.
8
-
9
- No event listeners are attached to the activating element to give the user full control over the way the popover is triggered.
10
-
11
- Based on:
12
-
13
- - [usePopover](/composables/popover)
14
-
15
- ## Demo
16
-
17
- <PopoverDemo />
18
-
19
- ::: details Code
20
- <<< ./demos/popover.vue
21
- :::
22
-
23
- ## Popover
24
-
25
- The root component.
26
-
27
- ### Properties
28
-
29
- | Property | Required | Description | Type | Default |
30
- | ----------------------- | -------- | ---------------------------------------------------- | --------------------------------------------------------------------------- | -------------- |
31
- | **id** | false | The ID of the popover dialog. | `string` | Auto-generated |
32
- | **activatorId** | false | The ID of the activator element. | `string` | Auto-generated |
33
- | **direction** | false | The direction of the popover. | `'up'` \| `'down'` \| `'left'` \| `'right'` | `'down'` |
34
- | **align** | false | The alignment of the popover. | `'top'` \| `'bottom'` \| `'left'` \| `'right'` \| `'center'` \| `'stretch'` | `'left'` |
35
- | **position** | false | CSS position of the popover dialog. | `'fixed'` \| `'absolute'` | `'fixed'` |
36
- | **closeOnOutsideClick** | false | Close the popover on an click outside of the dialog. | `boolean` | `true` |
37
- | **closeOnInsideClick** | false | Close the popover on an click inside of the dialog. | `boolean` | `false` |
38
- | **role** | false | The ARIA role of the popover | `'dialog'` \| `'listbox'` \| `'menu'` \| `'tree'` \| `'grid'` | `'dialog'` |
39
-
40
- ### Slots
41
-
42
- #### default
43
-
44
- The `default` slot is used to provide an activating element and a [PopoverDialog](#popoverdialog). The slot passes the following properties:
45
-
46
- | Property | Description | Type |
47
- | -------- | ------------------------------------------------------------ | -------------- |
48
- | attrs | Required attributes that **must** be binded to the activator | `object` |
49
- | isOpen | The status of the popover | `Ref<boolean>` |
50
- | toggle | Toggle the popover | `() => void` |
51
- | open | Open the popover and place focus on it | `() => void` |
52
- | close | Close the popover and return focus to the activator | `() => void` |
53
-
54
- ```vue-html
55
- <Popover v-slot="{ attrs, toggle, close }">
56
- <button @click="toggle" v-bind="attrs">Toggle</button>
57
-
58
- <PopoverDialog>
59
- <button @click="close()" >Close</button>
60
- </PopoverDialog>
61
- </Popover>
62
- ```
63
-
64
- ### ARIA roles and attributes
65
-
66
- The following attributes are managed for the activator:
67
-
68
- - [aria-controls](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-controls)
69
- - [aria-haspopup](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-haspopup)
70
- - [aria-expanded](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-expanded)
71
-
72
- ## PopoverDialog
73
-
74
- ### Keyboard interactions
75
-
76
- - `Escape` - Closes the popover and returns focus to the activating element.
77
-
78
- ### ARIA roles and attributes
79
-
80
- The popover container has the role provided in the popover properties and automatically manages the following attributes:
81
-
82
- - [aria-labelledby](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-labelledby)
@@ -1,9 +0,0 @@
1
- <script setup>
2
- import TabsDemo from './demos/tabs.vue'
3
- </script>
4
-
5
- # Tabs Components
6
-
7
- ## Demo
8
-
9
- <TabsDemo />
@@ -1,78 +0,0 @@
1
- <script setup>
2
- import TooltipDemo from './demos/tooltip.vue'
3
- </script>
4
-
5
- # Tooltip Component
6
-
7
- A tooltip is a contextual text bubble that displays a description for an element that appears on pointer hover or keyboard focus.
8
-
9
- A tooltip activator can be provided in the default slot:
10
-
11
- ```vue
12
- <Tooltip text="Tooltip text" v-slot="{ attrs }">
13
- <button v-bind="attrs">Activator</button>
14
- </Tooltip>
15
- ```
16
-
17
- Or by setting a tooltip id and using it in the `aria-describedby` attribute on the activator:
18
-
19
- ```vue
20
- <Tooltip id="tooltip-example" text="Tooltip text" />
21
- <button aria-describedby="tooltip-example">Activator</button>
22
- ```
23
-
24
- Based on:
25
-
26
- - [usePopover](/composables/popover)
27
-
28
- ## Demo
29
-
30
- <TooltipDemo />
31
-
32
- ::: details Code
33
- <<< ./demos/tooltip.vue
34
- :::
35
-
36
- ## Tooltip
37
-
38
- ### Properties
39
-
40
- | Property | Required | Description | Type | Default |
41
- | ------------- | -------- | ----------------------------------------------------- | ------------------------------------------- | -------------- |
42
- | **text** | false | Tooltip text. | `string` | `undefined` |
43
- | **delay** | false | The delay before showing the tooltip in milliseconds. | `number` \| `string` | `undefined` |
44
- | **direction** | false | The direction of the tooltip. | `'up'` \| `'down'` \| `'left'` \| `'right'` | `'up'` |
45
- | **id** | false | The ID of the tooltip. | `string` | auto-generated |
46
-
47
- ### Slots
48
-
49
- #### default
50
-
51
- The `default` slot can be used to provide an activator. The slot provides the `attrs` attribute that must be binded to the activating element.
52
-
53
- ```vue
54
- <Tooltip text="Tooltip text" v-slot="{ attrs }">
55
- <button v-bind="attrs">Activator</button>
56
- </Tooltip>
57
- ```
58
-
59
- #### content
60
-
61
- The `content` slot can be used to provide any custom html content for the tooltip.
62
-
63
- ```vue
64
- <Tooltip>
65
- <template #content>
66
- Any custom html content
67
- <img src="..." />
68
- </template>
69
- </Tooltip>
70
- ```
71
-
72
- ### Keyboard interactions
73
-
74
- - `Escape` - Hides the tooltip without preventing the default action.
75
-
76
- ### ARIA roles and attributes
77
-
78
- Tooltips have the [tooltip](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/tooltip_role) role.
@@ -1,130 +0,0 @@
1
- # useFormControl
2
-
3
- `useFormControl` utilizes [Constraint Validation API](https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation) to enable custom validation constrains for a form control.
4
-
5
- ## Basic Usage
6
-
7
- ```vue
8
- <script setup>
9
- import { ref } from "vue";
10
- import { useFormControl } from "vue-composable-ui";
11
-
12
- const codeInput = ref();
13
-
14
- const code = ref("");
15
- const country = ref("");
16
-
17
- const validateCode = (value) => {
18
- const constraints = {
19
- ch: [
20
- "^(CH-)?\\d{4}$",
21
- "Swiss postal codes must have exactly 4 digits: e.g. CH-1950 or 1950",
22
- ],
23
- fr: [
24
- "^(F-)?\\d{5}$",
25
- "French postal codes must have exactly 5 digits: e.g. F-75012 or 75012",
26
- ],
27
- de: [
28
- "^(D-)?\\d{5}$",
29
- "German postal codes must have exactly 5 digits: e.g. D-12345 or 12345",
30
- ],
31
- nl: [
32
- "^(NL-)?\\d{4}\\s*([A-RT-Z][A-Z]|S[BCE-RT-Z])$",
33
- "Dutch postal codes must have exactly 4 digits, followed by 2 letters except SA, SD and SS",
34
- ],
35
- };
36
-
37
- const constraint = new RegExp(constraints[country.value][0], "");
38
-
39
- // Check it!
40
- if (constraint.test(code.value)) {
41
- // The postal code follows the constraint, we use the ConstraintAPI to tell it
42
- return true;
43
- } else {
44
- // The postal code doesn't follow the constraint, we use the ConstraintAPI to
45
- // give a message about the format required for this country
46
- return constraints[country.value][1];
47
- }
48
- };
49
-
50
- const { validate } = useFormControl(codeInput, [validateCode]);
51
- </script>
52
-
53
- <template>
54
- <form>
55
- <label for="postal-code">Postal Code: </label>
56
- <input ref="codeInput" v-model="code" id="postal-code" />
57
- <label for="country">Country: </label>
58
- <select v-model="country" id="country">
59
- <option value="ch">Switzerland</option>
60
- <option value="fr">France</option>
61
- <option value="de">Germany</option>
62
- <option value="nl">The Netherlands</option>
63
- </select>
64
- <button type="button" @click="validate">Validate</button>
65
- </form>
66
- </template>
67
- ```
68
-
69
- ## Type Declarations
70
-
71
- ### Composable
72
-
73
- ```ts
74
- type FormElement = HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement;
75
-
76
- /**
77
- * A validating function must return `true` or a string describing the error
78
- */
79
- export type FormValidator = (value: string) => boolean | string;
80
-
81
- /**
82
- * Utilizes Constraint Validation API to enable custom validation constrains for a form control
83
- *
84
- * @param el A template ref or a CSS selector
85
- * @param validators An array of validating functions
86
- * @param showValidationError Whether to show the default browser validation error (true by default)
87
- *
88
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation}
89
- */
90
- export declare function useFormControl(
91
- el: TemplateRefOrSelector<FormElement>,
92
- validators?: MaybeRef<FormValidator[]>,
93
- showValidationError?: MaybeRef<boolean>
94
- ): useFormControlReturn;
95
- ```
96
-
97
- ### Return Type
98
-
99
- ```ts
100
- export interface useFormControlReturn {
101
- /**
102
- * Focus the form control
103
- */
104
- focus: () => void;
105
- /**
106
- * Validate the form control
107
- *
108
- * @returns Validation result
109
- */
110
- validate: () => boolean;
111
- /**
112
- * Whether the form control is valid. A shorthand for `validity.valid`, but can be manually overriden.
113
- */
114
- isValid: Ref<boolean>;
115
- /**
116
- * The validity state of the form control
117
- *
118
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/ValidityState}
119
- */
120
- validity: Readonly<Ref<ValidityState | undefined>>;
121
- /**
122
- * A string representing a localized message that describes the validation constraints that the control does not satisfy (if any)
123
- */
124
- validationMessage: Readonly<Ref<string>>;
125
- /**
126
- * Whether the value has been changed since the form control was mounted
127
- */
128
- isChanged: Ref<boolean>;
129
- }
130
- ```
@@ -1,47 +0,0 @@
1
- # useListOption
2
-
3
- `useListOption` is meant to be used in a child component representing a list item inside a parent component that uses the [`useList`](/composables/list) composable.
4
-
5
- See the [Basic Usage](/composables/list#basic-usage) example.
6
-
7
- ## Type Declarations
8
-
9
- ### Composable
10
-
11
- ```ts
12
- /**
13
- * Registers an HTML element and an associated value in the list created in the parent component
14
- *
15
- * @param el A template ref or a CSS selector
16
- * @param value A value of any type to associate with the HTML element
17
- * @param disabled Whether the item is disabled (false by default)
18
- */
19
- export declare function useListOption(
20
- el: HTMLElementType,
21
- value: ItemValue,
22
- disabled?: MaybeRef<boolean>
23
- ): UseListOptionReturn;
24
- ```
25
-
26
- ### Return Type
27
-
28
- ```ts
29
- interface UseListOptionReturn {
30
- /**
31
- * Whether the item is selected
32
- */
33
- isSelected: ComputedRef<boolean>;
34
- /**
35
- * Whether the item is active
36
- */
37
- isActive: ComputedRef<boolean>;
38
- /**
39
- * Select the item
40
- */
41
- select: () => void;
42
- /**
43
- * Activate the item
44
- */
45
- activate: () => void;
46
- }
47
- ```