126 |
127 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 |
2 | # Contributor Covenant Code of Conduct
3 |
4 | ## Our Pledge
5 |
6 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, race, body size, disability, ethnicity, sex characteristics, and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, status, or sexual identity and orientation.
7 |
8 | ## Our Standards
9 |
10 | Examples of behavior that contributes to creating a positive environment include:
11 |
12 | - Using welcoming and inclusive language
13 | - Being respectful of differing viewpoints and experiences
14 | - Gracefully accepting constructive criticism
15 | - Focusing on what is best for the community
16 | - Showing empathy towards other community members
17 |
18 | Examples of unacceptable behavior by participants include:
19 |
20 | - The use of sexualized language or imagery and unwelcome sexual attention or advances
21 | - Trolling, insulting/derogatory comments, and personal or political attacks
22 | - Public or private harassment
23 | - Publishing others' private information, such as a physical or electronic address, without explicit permission
24 | - Other conduct which could reasonably be considered inappropriate in a professional setting
25 |
26 | ## Our Responsibilities
27 |
28 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
29 |
30 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
31 |
32 | ## Scope
33 |
34 | This Code of Conduct applies within all project spaces, and it also applies when an individual is representing the project or its community in public spaces. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
35 |
36 | ## Enforcement
37 |
38 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at selemondev19@gmail.com. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
39 |
40 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
41 |
42 | ## Attribution
43 |
44 | This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
45 |
46 | For answers to common questions about this code of conduct, see https://www.contributor-covenant.org/faq
--------------------------------------------------------------------------------
/packages/nuxt-ui-vue/src/components/forms/FormGroup/UFormGroup.vue:
--------------------------------------------------------------------------------
1 |
95 |
96 |
97 |
128 |
129 |
133 |
140 |
141 |
142 |
143 |
144 |
145 |
146 | {{ item.content }}
147 |
148 |
149 |
150 |
151 |
152 |
--------------------------------------------------------------------------------
/packages/nuxt-ui-vue/src/components/elements/Button/UButton.vue:
--------------------------------------------------------------------------------
1 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 | {{ label }}
175 |
176 |
177 |
178 |
179 |
183 |
184 |
185 |
186 |
--------------------------------------------------------------------------------
/packages/nuxt-ui-vue/src/composables/defineShortcuts.ts:
--------------------------------------------------------------------------------
1 | /* eslint-disable @typescript-eslint/ban-types */
2 | import { computed, ref } from 'vue'
3 | import type { ComputedRef, WatchSource } from 'vue'
4 | import { logicAnd, logicNot } from '@vueuse/math'
5 | import { useDebounceFn, useEventListener } from '@vueuse/core'
6 | import { useShortcuts } from './useShortcuts'
7 |
8 | export interface ShortcutConfig {
9 | handler: Function
10 | usingInput?: string | boolean
11 | whenever?: WatchSource[]
12 | }
13 |
14 | export interface ShortcutsConfig {
15 | [key: string]: ShortcutConfig | Function
16 | }
17 |
18 | export interface ShortcutsOptions {
19 | chainDelay?: number
20 | }
21 |
22 | interface Shortcut {
23 | handler: Function
24 | condition: ComputedRef
25 | chained: boolean
26 | // KeyboardEvent attributes
27 | key: string
28 | ctrlKey: boolean
29 | metaKey: boolean
30 | shiftKey: boolean
31 | altKey: boolean
32 | // code?: string
33 | // keyCode?: number
34 | }
35 |
36 | export function defineShortcuts(config: ShortcutsConfig, options: ShortcutsOptions = {}) {
37 | const { macOS, usingInput } = useShortcuts()
38 |
39 | let shortcuts: Shortcut[] = []
40 |
41 | const chainedInputs = ref([])
42 | const clearChainedInput = () => {
43 | chainedInputs.value.splice(0, chainedInputs.value.length)
44 | }
45 | const debouncedClearChainedInput = useDebounceFn(clearChainedInput, options.chainDelay ?? 800)
46 |
47 | const onKeyDown = (e: KeyboardEvent) => {
48 | // Input autocomplete triggers a keydown event
49 | if (!e.key)
50 | return
51 |
52 | const alphabeticalKey = /^[a-z]{1}$/i.test(e.key)
53 |
54 | let chainedKey
55 | // eslint-disable-next-line @typescript-eslint/ban-ts-comment
56 | // @ts-expect-error
57 | chainedInputs.value.push(e.key)
58 | // try matching a chained shortcut
59 | if (chainedInputs.value.length >= 2) {
60 | chainedKey = chainedInputs.value.slice(-2).join('-')
61 |
62 | for (const shortcut of shortcuts.filter(s => s.chained)) {
63 | if (shortcut.key !== chainedKey)
64 | continue
65 |
66 | if (shortcut.condition.value) {
67 | e.preventDefault()
68 | shortcut.handler()
69 | }
70 | clearChainedInput()
71 | return
72 | }
73 | }
74 |
75 | // try matching a standard shortcut
76 | for (const shortcut of shortcuts.filter(s => !s.chained)) {
77 | if (e.key.toLowerCase() !== shortcut.key)
78 | continue
79 | if (e.metaKey !== shortcut.metaKey)
80 | continue
81 | if (e.ctrlKey !== shortcut.ctrlKey)
82 | continue
83 | // shift modifier is only checked in combination with alphabetical keys
84 | // (shift with non-alphabetical keys would change the key)
85 | if (alphabeticalKey && e.shiftKey !== shortcut.shiftKey)
86 | continue
87 | // alt modifier changes the combined key anyways
88 | // if (e.altKey !== shortcut.altKey) { continue }
89 |
90 | if (shortcut.condition.value) {
91 | e.preventDefault()
92 | shortcut.handler()
93 | }
94 | clearChainedInput()
95 | return
96 | }
97 |
98 | debouncedClearChainedInput()
99 | }
100 |
101 | // Map config to full detailled shortcuts
102 | shortcuts = Object.entries(config).map(([key, shortcutConfig]) => {
103 | if (!shortcutConfig)
104 | return null
105 |
106 | // Parse key and modifiers
107 | let shortcut: Partial
108 |
109 | if (key.includes('-') && key.includes('_'))
110 | return null
111 |
112 | const chained = key.includes('-')
113 | if (chained) {
114 | shortcut = {
115 | key: key.toLowerCase(),
116 | metaKey: false,
117 | ctrlKey: false,
118 | shiftKey: false,
119 | altKey: false,
120 | }
121 | }
122 | else {
123 | const keySplit = key.toLowerCase().split('_').map(k => k)
124 | shortcut = {
125 | key: keySplit.filter(k => !['meta', 'ctrl', 'shift', 'alt'].includes(k)).join('_'),
126 | metaKey: keySplit.includes('meta'),
127 | ctrlKey: keySplit.includes('ctrl'),
128 | shiftKey: keySplit.includes('shift'),
129 | altKey: keySplit.includes('alt'),
130 | }
131 | }
132 | shortcut.chained = chained
133 |
134 | // Convert Meta to Ctrl for non-MacOS
135 | if (!macOS.value && shortcut.metaKey && !shortcut.ctrlKey) {
136 | shortcut.metaKey = false
137 | shortcut.ctrlKey = true
138 | }
139 |
140 | // Retrieve handler function
141 | if (typeof shortcutConfig === 'function')
142 | shortcut.handler = shortcutConfig
143 | else if (typeof shortcutConfig === 'object')
144 | shortcut = { ...shortcut, handler: shortcutConfig.handler }
145 |
146 | if (!shortcut.handler)
147 | return null
148 |
149 | // Create shortcut computed
150 | const conditions: ComputedRef[] = []
151 | if (!(shortcutConfig as ShortcutConfig).usingInput)
152 | conditions.push(logicNot(usingInput))
153 | else if (typeof (shortcutConfig as ShortcutConfig).usingInput === 'string')
154 | conditions.push(computed(() => usingInput.value === (shortcutConfig as ShortcutConfig).usingInput))
155 |
156 | shortcut.condition = logicAnd(...conditions, ...((shortcutConfig as ShortcutConfig).whenever || []))
157 |
158 | return shortcut as Shortcut
159 | }).filter(Boolean) as Shortcut[]
160 |
161 | useEventListener('keydown', onKeyDown)
162 | }
163 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | Thank you for your valuable contribution and dedication to improving this project! We greatly appreciate your involvement. To ensure a smooth and cohesive collaboration, we have provided some guidelines to help you get started. Kindly take a moment to review them before submitting your contributions. Your efforts will undoubtedly make this project even better, and we look forward to working together on its success!.
4 |
5 | ## Code of Conduct
6 |
7 | This project is governed by the [Contributor Covenant Code of Conduct](./CODE_OF_CONDUCT.md). By participating, you are expected to adhere to it.
8 |
9 | ## Open Development
10 |
11 | All work happens directly on `GitHub`. Both core team members and external contributors send pull requests which go through the same `code review` process.
12 |
13 | ## Semantic Versioning
14 |
15 | This project follows semantic versioning. We release patch versions for bug fixes or other changes that do not change the behavior of the API, minor versions for new features that are backward-compatible, and major versions for any breaking changes.
16 |
17 | Every significant change is documented in the changelog file.
18 |
19 | ## Reporting Issues
20 |
21 | Welcome to Windi UI! We value your feedback and contributions to make this project better. If you encounter any bugs or have feature requests, please use [Github issues](https://github.com/nuxt-ui-vue/nuxt-ui-vue/issues) issues to submit them.
22 |
23 | Before reporting an issue, we ask you to:
24 |
25 | 1. `Search for Similar Issues` : Ensure you have searched through our existing issues to see if the problem or feature request has already been addressed or is under discussion.
26 |
27 | 2. `Reproduce the Bug` : If reporting a bug, please provide the minimum code required to reproduce the issue. This will help us understand and resolve the problem more efficiently.
28 |
29 | 3. `Describe Feature Requests` : For feature requests, please describe the desired functionality and any additional context that might be helpful.
30 |
31 | Your participation and attention to these guidelines will help us maintain a more organized and effective development process.
32 |
33 | ## Sending a pull request
34 |
35 | 1. Fork [the repository](https://github.com/nuxt-ui-vue/nuxt-ui-vue),and create your branch from `main`. For new feature, please submit your changes directly to the `feature` branch. Other changes should go against `main` branch.
36 | 2. Use `pnpm install` install the dependencies
37 | 3. Use `pnpm run dev` start project, RUN `pnpm run play` start the `playground`, RUN `pnpm run docs` to write docs, usually a dev server and document server can be debugged.
38 | 4. Make changes to the codebase. Please add `tests` if applicable.
39 | 5. Make sure the test suite passes with `pnpm run test`.
40 | 6. Use `pnpm run test:ci` to RUN `CI` tests before you commit your code.
41 | 8. Commit your changes, adhering to the [Commit Guidelines](#commit-guidelines).
42 | 9. Open a new pull request, [referencing corresponding issues](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword) if available.
43 |
44 | ## Commit Guidelines
45 |
46 | Commit messages are required to follow the [conventional-changelog standard](https://www.conventionalcommits.org/en/v1.0.0/):
47 |
48 | ```bash
49 | [optional scope]:
50 |
51 | [optional body]
52 |
53 | [optional footer(s)]
54 | ```
55 |
56 | 👉 [Commit example](https://github.com/unocss/unocss/releases/tag/v0.39.0)
57 |
58 | ### Commit types
59 |
60 | The following is a list of commit types:
61 |
62 | ### Commit Types:
63 |
64 | - `feat`: Adding a new UI component or significant functionality to the library. Examples:
65 | - Added a new dropdown menu component.
66 | - Implemented a dark mode feature for all components.
67 |
68 | - `fix`: Addressing bugs or issues in existing UI components. Examples:
69 | - Fixed misalignment in the button component.
70 | - Resolved an issue with the modal not closing correctly.
71 |
72 | - `docs`: Commits related to documentation changes for Windi UI components. Examples:
73 | - Updated usage examples in the README for the carousel component.
74 | - Added API documentation for the accordion component.
75 |
76 | - `style`: Commits related to code formatting, styling, or theming of UI components. Examples:
77 | - Improved button styles for better consistency across browsers.
78 | - Updated color palette for a more cohesive design.
79 |
80 | - `refactor`: Code changes that enhance the library's structure without introducing new features or fixing bugs. Examples:
81 | - Reorganized folder structure for better modularity.
82 | - Simplified the logic in a component to improve maintainability.
83 |
84 | - `perf`: Commits aimed at improving performance for UI components. Examples:
85 | - Optimized rendering logic in the data table component.
86 | - Reduced the size of assets for faster loading times.
87 |
88 | - `test`: Commits related to testing Windi UI components. Examples:
89 | - Added unit tests for the accordion component to ensure functionality.
90 | - Fixed failing test cases for the dropdown menu.
91 |
92 | - `chore`: Other commits not affecting source or test files directly. Examples:
93 | - Updated third-party dependencies in package.json.
94 | - Ignored build output in .gitignore.
95 |
96 |
97 | ## NuxtLabs UI Vue Repository Structure
98 |
99 | This repository is managed by `pnpm` and includes the following packages:
100 |
101 | 1. `nuxt-ui-vue`: Main UI component library for Vue
102 |
103 | ## License
104 |
105 | By contributing your code to the repository, you agree to license your contribution under the [MIT license](./LICENSE).
--------------------------------------------------------------------------------
/packages/nuxt-ui-vue/src/components/navigation/Command-Palette/CommandPaletteGroup.vue:
--------------------------------------------------------------------------------
1 |
80 |
81 |
82 |