feat{input}: new input component

Added input component and merge the common size, padding etc. values to ui.config/standard.ts
This commit is contained in:
Timothy Yin 2024-11-24 05:15:38 +08:00
parent 07b317f23b
commit 565a4b5e4f
14 changed files with 856 additions and 6452 deletions

View File

@ -1,20 +1,9 @@
<script lang="ts" setup>
import { camelCase, kebabCase, upperFirst } from 'scule'
import FileTypeVue from '../icon/VscodeIconsFileTypeVue.vue'
import FileTypeTypescript from '../icon/VscodeIconsFileTypeTypescriptOfficial.vue'
import FileTypeJavascript from '../icon/VscodeIconsFileTypeJsOfficial.vue'
import TablerTerminal from '../icon/TablerTerminal.vue'
const route = useRoute()
const appConfig = useAppConfig()
const IconComponents = {
'vue': FileTypeVue,
'vue-html': FileTypeVue,
'sh': TablerTerminal,
'ts': FileTypeTypescript,
'js': FileTypeJavascript,
}
const { $prettier } = useNuxtApp()
const props = defineProps({
slug: {
@ -25,6 +14,14 @@ const props = defineProps({
type: Object,
default: () => ({}),
},
privateProps: {
type: Object,
default: () => ({}),
},
excludedProps: {
type: Array,
default: () => [],
},
slots: {
type: Object,
default: () => ({}),
@ -33,17 +30,22 @@ const props = defineProps({
type: Array as PropType<{ name: string, values: string[], restriction: 'expected' | 'included' | 'excluded' | 'only' }[]>,
default: () => [],
},
excludedProps: {
type: Array,
default: () => [],
},
})
const componentName = props.slug || `Ray${upperFirst(camelCase(route.params.slug[route.params.slug.length - 1]))}`
const componentMeta = await fetchComponentMeta(componentName)
const privateProps = reactive({ ...props.privateProps })
const componentProps = reactive({ ...props.props })
const componentFullProps = computed(() => ({ ...componentProps, ...privateProps }))
const componentVModel = computed({
get: () => privateProps.modelValue,
set: (value) => {
privateProps.modelValue = value
},
})
const customizableOptions = (key: string, schema: { kind: string, type: string, schema: [] }) => {
let options: string[] = []
const optionItem = props?.options?.find(item => item?.name === key) || null
@ -99,7 +101,7 @@ const customizableProps = computed(() => Object.keys(componentProps).map((k) =>
return {
name: k,
type: prop?.type || 'string',
label: camelCase(k),
label: k === 'modelValue' ? 'value' : camelCase(k),
options,
}
}).filter(prop => prop !== null))
@ -109,8 +111,12 @@ const code = computed(() => {
<template>
<${componentName}`
for (const [k, v] of Object.entries(componentProps)) {
code += ` ${typeof v === 'boolean' || typeof v === 'number' || typeof v === 'object' ? ':' : ''}${kebabCase(k)}="${typeof v === 'object' ? renderObject(v) : v}"`
for (const [k, v] of Object.entries(componentFullProps.value)) {
if (v === 'undefined' || v === null) {
continue
}
code += ` ${(typeof v === 'boolean' && (k === 'modelValue' || v !== true)) || typeof v === 'number' || typeof v === 'object' ? ':' : ''}${k === 'modelValue' ? 'model-value' : kebabCase(k)}${k !== 'modelValue' && typeof v === 'boolean' && !!v ? '' : `="${typeof v === 'object' ? renderObject(v) : v}"`}`
}
code += `/>\n</template>
@ -120,7 +126,17 @@ const code = computed(() => {
})
const { data: codeRender } = await useAsyncData(`${componentName}-code-renderer-${JSON.stringify({ props: componentProps, slots: props.slots, code: code.value })}`, async () => {
return parseMarkdown(code.value, {})
let fortmattedCode = ''
try {
fortmattedCode = await $prettier.format(code.value, {
semi: false,
singleQuote: true,
})
}
catch (e) {
fortmattedCode = code.value
}
return parseMarkdown(fortmattedCode)
}, {
watch: [code],
})
@ -128,9 +144,12 @@ const { data: codeRender } = await useAsyncData(`${componentName}-code-renderer-
<template>
<div class="border border-neutral-200 dark:border-neutral-700 rounded-lg not-prose my-2 overflow-hidden">
<div :class="['p-4 overflow-auto', !!codeRender ? 'border-b border-neutral-200 dark:border-neutral-700' : '']">
<component :is="componentName" v-bind="componentProps">
<slot />
<div :class="['p-4 overflow-auto flex', !!codeRender ? 'border-b border-neutral-200 dark:border-neutral-700' : '']">
<component :is="componentName" v-model="componentVModel" v-bind="componentFullProps">
<ContentSlot v-if="$slots.default" :use="$slots.default" />
<template v-for="slot in Object.keys(slots || {})" :key="slot" #[slot]>
<ContentSlot :name="slot" unwrap="p" />
</template>
</component>
</div>
@ -153,17 +172,20 @@ const { data: codeRender } = await useAsyncData(`${componentName}-code-renderer-
{{ option }}
</option>
</select>
<input
<RayInput
v-else
:id="`${prop.name}-prop`"
v-model="componentProps[prop.name]"
type="text"
:model-value="componentProps[prop.name]"
:type="prop.type === 'number' ? 'number' : 'text'"
variant="plain"
:padded="false"
placeholder="type something..."
>
@update:model-value="val => componentProps[prop.name] = prop.type === 'number' ? Number(val) : val"
/>
</div>
</div>
<ContentRenderer v-if="codeRender" :value="codeRender" class="overflow-auto [&_.pre]:rounded-none [&_.pre]:border-none" />
<ContentRenderer v-if="codeRender" :value="codeRender" class="[&_.pre]:rounded-none [&_.pre]:border-none" />
</div>
</template>

View File

@ -15,6 +15,7 @@
"nuxt": "^3.14.159",
"nuxt-component-meta": "^0.9.0",
"nuxt-shiki": "^0.3.0",
"prettier": "^3.3.3",
"rayine-ui": "workspace:rayine-ui",
"ufo": "^1.5.4",
"vue": "latest",

73
docs/plugins/prettier.ts Normal file
View File

@ -0,0 +1,73 @@
// ref: https://github.com/nuxt/ui/blob/f3632ddee511f0fccb24d4fc37403421e84ffdae/docs/plugins/prettier.ts
import type { Options } from 'prettier'
import { defu } from 'defu'
import PrettierWorker from '@/workers/prettier.js?worker&inline'
export interface SimplePrettier {
format: (source: string, options?: Options) => Promise<string>
}
function createPrettierWorkerApi(worker: Worker): SimplePrettier {
let counter = 0
const handlers: any = {}
worker.addEventListener('message', (event) => {
const { uid, message, error } = event.data
if (!handlers[uid]) {
return
}
const [resolve, reject] = handlers[uid]
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete handlers[uid]
if (error) {
reject(error)
}
else {
resolve(message)
}
})
function postMessage<T>(message: any) {
const uid = ++counter
return new Promise<T>((resolve, reject) => {
handlers[uid] = [resolve, reject]
worker.postMessage({ uid, message })
})
}
return {
format(source: string, options?: Options) {
return postMessage({ type: 'format', source, options })
},
}
}
export default defineNuxtPlugin(async () => {
let prettier: SimplePrettier
if (import.meta.server) {
const prettierModule = await import('prettier')
prettier = {
format(source, options = {}) {
return prettierModule.format(
source,
defu(options, {
parser: 'markdown',
}),
)
},
}
}
else {
const worker = new PrettierWorker()
prettier = createPrettierWorkerApi(worker)
}
return {
provide: {
prettier,
},
}
})

6378
docs/pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

34
docs/workers/prettier.js Normal file
View File

@ -0,0 +1,34 @@
// ref: https://github.com/nuxt/ui/blob/f3632ddee511f0fccb24d4fc37403421e84ffdae/docs/workers/prettier.js
/* eslint-disable no-undef */
self.onmessage = async function (event) {
self.postMessage({
uid: event.data.uid,
message: await handleMessage(event.data.message),
})
}
function handleMessage(message) {
switch (message.type) {
case 'format':
return handleFormatMessage(message)
}
}
async function handleFormatMessage(message) {
if (!globalThis.prettier) {
await Promise.all([
import('https://unpkg.com/prettier@3.3.3/standalone.js'),
import('https://unpkg.com/prettier@3.3.3/plugins/html.js'),
import('https://unpkg.com/prettier@3.3.3/plugins/markdown.js'),
])
}
const { options, source } = message
const formatted = await prettier.format(source, {
parser: 'markdown',
plugins: prettierPlugins,
...options,
})
return formatted
}

449
pnpm-lock.yaml generated
View File

@ -10,10 +10,10 @@ importers:
dependencies:
'@nuxt/kit':
specifier: ^3.14.159
version: 3.14.159(magicast@0.3.5)(rollup@4.27.2)
version: 3.14.159(magicast@0.3.5)(rollup@3.29.5)
'@nuxtjs/tailwindcss':
specifier: ^6.12.2
version: 6.12.2(magicast@0.3.5)(rollup@4.27.2)
version: 6.12.2(magicast@0.3.5)(rollup@3.29.5)
'@tailwindcss/aspect-ratio':
specifier: ^0.4.2
version: 0.4.2(tailwindcss@3.4.15)
@ -38,19 +38,19 @@ importers:
devDependencies:
'@nuxt/devtools':
specifier: ^1.6.0
version: 1.6.0(rollup@4.27.2)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))(vue@3.5.13(typescript@5.7.2))
version: 1.6.0(rollup@3.29.5)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))(vue@3.5.13(typescript@5.7.2))
'@nuxt/eslint-config':
specifier: ^0.7.0
version: 0.7.0(@vue/compiler-sfc@3.5.13)(eslint@9.15.0(jiti@2.4.0))(typescript@5.7.2)
'@nuxt/module-builder':
specifier: ^0.8.4
version: 0.8.4(@nuxt/kit@3.14.159(magicast@0.3.5)(rollup@4.27.2))(nuxi@3.15.0)(typescript@5.7.2)(vue-tsc@2.1.10(typescript@5.7.2))
version: 0.8.4(@nuxt/kit@3.14.159(magicast@0.3.5)(rollup@3.29.5))(nuxi@3.15.0)(typescript@5.7.2)(vue-tsc@2.1.10(typescript@5.7.2))
'@nuxt/schema':
specifier: ^3.14.159
version: 3.14.159(magicast@0.3.5)(rollup@4.27.2)
version: 3.14.159(magicast@0.3.5)(rollup@3.29.5)
'@nuxt/test-utils':
specifier: ^3.14.4
version: 3.14.4(h3@1.13.0)(magicast@0.3.5)(nitropack@2.10.4(typescript@5.7.2))(rollup@4.27.2)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))(vitest@2.1.5(@types/node@22.9.3)(terser@5.36.0))(vue-router@4.4.5(vue@3.5.13(typescript@5.7.2)))(vue@3.5.13(typescript@5.7.2))
version: 3.14.4(h3@1.13.0)(magicast@0.3.5)(nitropack@2.10.4(typescript@5.7.2))(rollup@3.29.5)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))(vitest@2.1.5(@types/node@22.9.3)(terser@5.36.0))(vue-router@4.4.5(vue@3.5.13(typescript@5.7.2)))(vue@3.5.13(typescript@5.7.2))
'@release-it/conventional-changelog':
specifier: ^9.0.3
version: 9.0.3(conventional-commits-filter@5.0.0)(conventional-commits-parser@6.0.0)(release-it@17.10.0(typescript@5.7.2))
@ -65,7 +65,7 @@ importers:
version: 9.15.0(jiti@2.4.0)
nuxt:
specifier: ^3.14.159
version: 3.14.159(@parcel/watcher@2.5.0)(@types/node@22.9.3)(eslint@9.15.0(jiti@2.4.0))(ioredis@5.4.1)(magicast@0.3.5)(optionator@0.9.4)(rollup@4.27.2)(terser@5.36.0)(typescript@5.7.2)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))(vue-tsc@2.1.10(typescript@5.7.2))
version: 3.14.159(@parcel/watcher@2.5.0)(@types/node@22.9.3)(eslint@9.15.0(jiti@2.4.0))(ioredis@5.4.1)(magicast@0.3.5)(optionator@0.9.4)(rollup@3.29.5)(terser@5.36.0)(typescript@5.7.2)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))(vue-tsc@2.1.10(typescript@5.7.2))
release-it:
specifier: ^17.10.0
version: 17.10.0(typescript@5.7.2)
@ -102,6 +102,9 @@ importers:
nuxt-shiki:
specifier: ^0.3.0
version: 0.3.0(magicast@0.3.5)(rollup@4.27.2)
prettier:
specifier: ^3.3.3
version: 3.3.3
rayine-ui:
specifier: workspace:rayine-ui
version: link:..
@ -4593,6 +4596,11 @@ packages:
resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==}
engines: {node: '>= 0.8.0'}
prettier@3.3.3:
resolution: {integrity: sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==}
engines: {node: '>=14'}
hasBin: true
pretty-bytes@6.1.1:
resolution: {integrity: sha512-mQUvGU6aUFQ+rNvTIAcZuWGRT9a6f6Yrg9bHs4ImKF+HZCEK+plBvnAZYSIQztknZF2qnzNtr6F8s0+IuptdlQ==}
engines: {node: ^14.13.1 || >=16.0.0}
@ -6609,6 +6617,17 @@ snapshots:
'@nuxt/devalue@2.0.2': {}
'@nuxt/devtools-kit@1.6.0(magicast@0.3.5)(rollup@3.29.5)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))':
dependencies:
'@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@3.29.5)
'@nuxt/schema': 3.14.159(magicast@0.3.5)(rollup@3.29.5)
execa: 7.2.0
vite: 5.4.11(@types/node@22.9.3)(terser@5.36.0)
transitivePeerDependencies:
- magicast
- rollup
- supports-color
'@nuxt/devtools-kit@1.6.0(magicast@0.3.5)(rollup@4.27.2)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))':
dependencies:
'@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@4.27.2)
@ -6633,6 +6652,53 @@ snapshots:
rc9: 2.1.2
semver: 7.6.3
'@nuxt/devtools@1.6.0(rollup@3.29.5)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))(vue@3.5.13(typescript@5.7.2))':
dependencies:
'@antfu/utils': 0.7.10
'@nuxt/devtools-kit': 1.6.0(magicast@0.3.5)(rollup@3.29.5)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))
'@nuxt/devtools-wizard': 1.6.0
'@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@3.29.5)
'@vue/devtools-core': 7.4.4(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))(vue@3.5.13(typescript@5.7.2))
'@vue/devtools-kit': 7.4.4
birpc: 0.2.19
consola: 3.2.3
cronstrue: 2.51.0
destr: 2.0.3
error-stack-parser-es: 0.1.5
execa: 7.2.0
fast-npm-meta: 0.2.2
flatted: 3.3.1
get-port-please: 3.1.2
hookable: 5.5.3
image-meta: 0.2.1
is-installed-globally: 1.0.0
launch-editor: 2.9.1
local-pkg: 0.5.0
magicast: 0.3.5
nypm: 0.3.12
ohash: 1.1.4
pathe: 1.1.2
perfect-debounce: 1.0.0
pkg-types: 1.2.1
rc9: 2.1.2
scule: 1.3.0
semver: 7.6.3
simple-git: 3.27.0
sirv: 2.0.4
tinyglobby: 0.2.10
unimport: 3.13.2(rollup@3.29.5)
vite: 5.4.11(@types/node@22.9.3)(terser@5.36.0)
vite-plugin-inspect: 0.8.7(@nuxt/kit@3.14.159(magicast@0.3.5)(rollup@3.29.5))(rollup@3.29.5)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))
vite-plugin-vue-inspector: 5.1.3(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))
which: 3.0.1
ws: 8.18.0
transitivePeerDependencies:
- bufferutil
- rollup
- supports-color
- utf-8-validate
- vue
'@nuxt/devtools@1.6.0(rollup@4.27.2)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))(vue@3.5.13(typescript@5.7.2))':
dependencies:
'@antfu/utils': 0.7.10
@ -6669,7 +6735,7 @@ snapshots:
tinyglobby: 0.2.10
unimport: 3.13.2(rollup@4.27.2)
vite: 5.4.11(@types/node@22.9.3)(terser@5.36.0)
vite-plugin-inspect: 0.8.7(@nuxt/kit@3.14.159(magicast@0.3.5)(rollup@4.27.2))(rollup@4.27.2)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))
vite-plugin-inspect: 0.8.7(@nuxt/kit@3.14.159(magicast@0.3.5)(rollup@3.29.5))(rollup@4.27.2)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))
vite-plugin-vue-inspector: 5.1.3(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))
which: 3.0.1
ws: 8.18.0
@ -6759,6 +6825,33 @@ snapshots:
- supports-color
- vite
'@nuxt/kit@3.14.159(magicast@0.3.5)(rollup@3.29.5)':
dependencies:
'@nuxt/schema': 3.14.159(magicast@0.3.5)(rollup@3.29.5)
c12: 2.0.1(magicast@0.3.5)
consola: 3.2.3
defu: 6.1.4
destr: 2.0.3
globby: 14.0.2
hash-sum: 2.0.0
ignore: 6.0.2
jiti: 2.4.0
klona: 2.0.6
knitwork: 1.1.0
mlly: 1.7.3
pathe: 1.1.2
pkg-types: 1.2.1
scule: 1.3.0
semver: 7.6.3
ufo: 1.5.4
unctx: 2.3.1
unimport: 3.13.2(rollup@3.29.5)
untyped: 1.5.1
transitivePeerDependencies:
- magicast
- rollup
- supports-color
'@nuxt/kit@3.14.159(magicast@0.3.5)(rollup@4.27.2)':
dependencies:
'@nuxt/schema': 3.14.159(magicast@0.3.5)(rollup@4.27.2)
@ -6786,9 +6879,9 @@ snapshots:
- rollup
- supports-color
'@nuxt/module-builder@0.8.4(@nuxt/kit@3.14.159(magicast@0.3.5)(rollup@4.27.2))(nuxi@3.15.0)(typescript@5.7.2)(vue-tsc@2.1.10(typescript@5.7.2))':
'@nuxt/module-builder@0.8.4(@nuxt/kit@3.14.159(magicast@0.3.5)(rollup@3.29.5))(nuxi@3.15.0)(typescript@5.7.2)(vue-tsc@2.1.10(typescript@5.7.2))':
dependencies:
'@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@4.27.2)
'@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@3.29.5)
citty: 0.1.6
consola: 3.2.3
defu: 6.1.4
@ -6805,6 +6898,26 @@ snapshots:
- typescript
- vue-tsc
'@nuxt/schema@3.14.159(magicast@0.3.5)(rollup@3.29.5)':
dependencies:
c12: 2.0.1(magicast@0.3.5)
compatx: 0.1.8
consola: 3.2.3
defu: 6.1.4
hookable: 5.5.3
pathe: 1.1.2
pkg-types: 1.2.1
scule: 1.3.0
std-env: 3.8.0
ufo: 1.5.4
uncrypto: 0.1.3
unimport: 3.13.2(rollup@3.29.5)
untyped: 1.5.1
transitivePeerDependencies:
- magicast
- rollup
- supports-color
'@nuxt/schema@3.14.159(magicast@0.3.5)(rollup@4.27.2)':
dependencies:
c12: 2.0.1(magicast@0.3.5)
@ -6825,6 +6938,31 @@ snapshots:
- rollup
- supports-color
'@nuxt/telemetry@2.6.0(magicast@0.3.5)(rollup@3.29.5)':
dependencies:
'@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@3.29.5)
ci-info: 4.1.0
consola: 3.2.3
create-require: 1.1.1
defu: 6.1.4
destr: 2.0.3
dotenv: 16.4.5
git-url-parse: 15.0.0
is-docker: 3.0.0
jiti: 1.21.6
mri: 1.2.0
nanoid: 5.0.8
ofetch: 1.4.1
package-manager-detector: 0.2.4
parse-git-config: 3.0.0
pathe: 1.1.2
rc9: 2.1.2
std-env: 3.8.0
transitivePeerDependencies:
- magicast
- rollup
- supports-color
'@nuxt/telemetry@2.6.0(magicast@0.3.5)(rollup@4.27.2)':
dependencies:
'@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@4.27.2)
@ -6850,10 +6988,10 @@ snapshots:
- rollup
- supports-color
'@nuxt/test-utils@3.14.4(h3@1.13.0)(magicast@0.3.5)(nitropack@2.10.4(typescript@5.7.2))(rollup@4.27.2)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))(vitest@2.1.5(@types/node@22.9.3)(terser@5.36.0))(vue-router@4.4.5(vue@3.5.13(typescript@5.7.2)))(vue@3.5.13(typescript@5.7.2))':
'@nuxt/test-utils@3.14.4(h3@1.13.0)(magicast@0.3.5)(nitropack@2.10.4(typescript@5.7.2))(rollup@3.29.5)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))(vitest@2.1.5(@types/node@22.9.3)(terser@5.36.0))(vue-router@4.4.5(vue@3.5.13(typescript@5.7.2)))(vue@3.5.13(typescript@5.7.2))':
dependencies:
'@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@4.27.2)
'@nuxt/schema': 3.14.159(magicast@0.3.5)(rollup@4.27.2)
'@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@3.29.5)
'@nuxt/schema': 3.14.159(magicast@0.3.5)(rollup@3.29.5)
c12: 2.0.1(magicast@0.3.5)
consola: 3.2.3
defu: 6.1.4
@ -6877,7 +7015,7 @@ snapshots:
unenv: 1.10.0
unplugin: 1.16.0
vite: 5.4.11(@types/node@22.9.3)(terser@5.36.0)
vitest-environment-nuxt: 1.0.1(h3@1.13.0)(magicast@0.3.5)(nitropack@2.10.4(typescript@5.7.2))(rollup@4.27.2)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))(vitest@2.1.5(@types/node@22.9.3)(terser@5.36.0))(vue-router@4.4.5(vue@3.5.13(typescript@5.7.2)))(vue@3.5.13(typescript@5.7.2))
vitest-environment-nuxt: 1.0.1(h3@1.13.0)(magicast@0.3.5)(nitropack@2.10.4(typescript@5.7.2))(rollup@3.29.5)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))(vitest@2.1.5(@types/node@22.9.3)(terser@5.36.0))(vue-router@4.4.5(vue@3.5.13(typescript@5.7.2)))(vue@3.5.13(typescript@5.7.2))
vue: 3.5.13(typescript@5.7.2)
vue-router: 4.4.5(vue@3.5.13(typescript@5.7.2))
optionalDependencies:
@ -6887,6 +7025,65 @@ snapshots:
- rollup
- supports-color
'@nuxt/vite-builder@3.14.159(@types/node@22.9.3)(eslint@9.15.0(jiti@2.4.0))(magicast@0.3.5)(optionator@0.9.4)(rollup@3.29.5)(terser@5.36.0)(typescript@5.7.2)(vue-tsc@2.1.10(typescript@5.7.2))(vue@3.5.13(typescript@5.7.2))':
dependencies:
'@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@3.29.5)
'@rollup/plugin-replace': 6.0.1(rollup@3.29.5)
'@vitejs/plugin-vue': 5.2.0(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))(vue@3.5.13(typescript@5.7.2))
'@vitejs/plugin-vue-jsx': 4.1.0(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))(vue@3.5.13(typescript@5.7.2))
autoprefixer: 10.4.20(postcss@8.4.49)
clear: 0.1.0
consola: 3.2.3
cssnano: 7.0.6(postcss@8.4.49)
defu: 6.1.4
esbuild: 0.24.0
escape-string-regexp: 5.0.0
estree-walker: 3.0.3
externality: 1.0.2
get-port-please: 3.1.2
h3: 1.13.0
jiti: 2.4.0
knitwork: 1.1.0
magic-string: 0.30.12
mlly: 1.7.3
ohash: 1.1.4
pathe: 1.1.2
perfect-debounce: 1.0.0
pkg-types: 1.2.1
postcss: 8.4.49
rollup-plugin-visualizer: 5.12.0(rollup@3.29.5)
std-env: 3.8.0
strip-literal: 2.1.0
ufo: 1.5.4
unenv: 1.10.0
unplugin: 1.16.0
vite: 5.4.11(@types/node@22.9.3)(terser@5.36.0)
vite-node: 2.1.5(@types/node@22.9.3)(terser@5.36.0)
vite-plugin-checker: 0.8.0(eslint@9.15.0(jiti@2.4.0))(optionator@0.9.4)(typescript@5.7.2)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))(vue-tsc@2.1.10(typescript@5.7.2))
vue: 3.5.13(typescript@5.7.2)
vue-bundle-renderer: 2.1.1
transitivePeerDependencies:
- '@biomejs/biome'
- '@types/node'
- eslint
- less
- lightningcss
- magicast
- meow
- optionator
- rollup
- sass
- sass-embedded
- stylelint
- stylus
- sugarss
- supports-color
- terser
- typescript
- vls
- vti
- vue-tsc
'@nuxt/vite-builder@3.14.159(@types/node@22.9.3)(eslint@9.15.0(jiti@2.4.0))(magicast@0.3.5)(optionator@0.9.4)(rollup@4.27.2)(terser@5.36.0)(typescript@5.7.2)(vue-tsc@2.1.10(typescript@5.7.2))(vue@3.5.13(typescript@5.7.2))':
dependencies:
'@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@4.27.2)
@ -6999,9 +7196,9 @@ snapshots:
- rollup
- supports-color
'@nuxtjs/tailwindcss@6.12.2(magicast@0.3.5)(rollup@4.27.2)':
'@nuxtjs/tailwindcss@6.12.2(magicast@0.3.5)(rollup@3.29.5)':
dependencies:
'@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@4.27.2)
'@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@3.29.5)
autoprefixer: 10.4.20(postcss@8.4.49)
consola: 3.2.3
defu: 6.1.4
@ -7283,6 +7480,13 @@ snapshots:
optionalDependencies:
rollup: 3.29.5
'@rollup/plugin-replace@6.0.1(rollup@3.29.5)':
dependencies:
'@rollup/pluginutils': 5.1.3(rollup@3.29.5)
magic-string: 0.30.12
optionalDependencies:
rollup: 3.29.5
'@rollup/plugin-replace@6.0.1(rollup@4.27.2)':
dependencies:
'@rollup/pluginutils': 5.1.3(rollup@4.27.2)
@ -7680,6 +7884,19 @@ snapshots:
path-browserify: 1.0.1
vscode-uri: 3.0.8
'@vue-macros/common@1.15.0(rollup@3.29.5)(vue@3.5.13(typescript@5.7.2))':
dependencies:
'@babel/types': 7.26.0
'@rollup/pluginutils': 5.1.3(rollup@3.29.5)
'@vue/compiler-sfc': 3.5.13
ast-kit: 1.3.1
local-pkg: 0.5.0
magic-string-ast: 0.6.2
optionalDependencies:
vue: 3.5.13(typescript@5.7.2)
transitivePeerDependencies:
- rollup
'@vue-macros/common@1.15.0(rollup@4.27.2)(vue@3.5.13(typescript@5.7.2))':
dependencies:
'@babel/types': 7.26.0
@ -9700,6 +9917,16 @@ snapshots:
parent-module: 1.0.1
resolve-from: 4.0.0
impound@0.2.0(rollup@3.29.5):
dependencies:
'@rollup/pluginutils': 5.1.3(rollup@3.29.5)
mlly: 1.7.3
pathe: 1.1.2
unenv: 1.10.0
unplugin: 1.16.0
transitivePeerDependencies:
- rollup
impound@0.2.0(rollup@4.27.2):
dependencies:
'@rollup/pluginutils': 5.1.3(rollup@4.27.2)
@ -10769,6 +10996,119 @@ snapshots:
- rollup
- supports-color
nuxt@3.14.159(@parcel/watcher@2.5.0)(@types/node@22.9.3)(eslint@9.15.0(jiti@2.4.0))(ioredis@5.4.1)(magicast@0.3.5)(optionator@0.9.4)(rollup@3.29.5)(terser@5.36.0)(typescript@5.7.2)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))(vue-tsc@2.1.10(typescript@5.7.2)):
dependencies:
'@nuxt/devalue': 2.0.2
'@nuxt/devtools': 1.6.0(rollup@3.29.5)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))(vue@3.5.13(typescript@5.7.2))
'@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@3.29.5)
'@nuxt/schema': 3.14.159(magicast@0.3.5)(rollup@3.29.5)
'@nuxt/telemetry': 2.6.0(magicast@0.3.5)(rollup@3.29.5)
'@nuxt/vite-builder': 3.14.159(@types/node@22.9.3)(eslint@9.15.0(jiti@2.4.0))(magicast@0.3.5)(optionator@0.9.4)(rollup@3.29.5)(terser@5.36.0)(typescript@5.7.2)(vue-tsc@2.1.10(typescript@5.7.2))(vue@3.5.13(typescript@5.7.2))
'@unhead/dom': 1.11.11
'@unhead/shared': 1.11.11
'@unhead/ssr': 1.11.11
'@unhead/vue': 1.11.11(vue@3.5.13(typescript@5.7.2))
'@vue/shared': 3.5.13
acorn: 8.14.0
c12: 2.0.1(magicast@0.3.5)
chokidar: 4.0.1
compatx: 0.1.8
consola: 3.2.3
cookie-es: 1.2.2
defu: 6.1.4
destr: 2.0.3
devalue: 5.1.1
errx: 0.1.0
esbuild: 0.24.0
escape-string-regexp: 5.0.0
estree-walker: 3.0.3
globby: 14.0.2
h3: 1.13.0
hookable: 5.5.3
ignore: 6.0.2
impound: 0.2.0(rollup@3.29.5)
jiti: 2.4.0
klona: 2.0.6
knitwork: 1.1.0
magic-string: 0.30.12
mlly: 1.7.3
nanotar: 0.1.1
nitropack: 2.10.4(typescript@5.7.2)
nuxi: 3.15.0
nypm: 0.3.12
ofetch: 1.4.1
ohash: 1.1.4
pathe: 1.1.2
perfect-debounce: 1.0.0
pkg-types: 1.2.1
radix3: 1.1.2
scule: 1.3.0
semver: 7.6.3
std-env: 3.8.0
strip-literal: 2.1.0
tinyglobby: 0.2.10
ufo: 1.5.4
ultrahtml: 1.5.3
uncrypto: 0.1.3
unctx: 2.3.1
unenv: 1.10.0
unhead: 1.11.11
unimport: 3.13.2(rollup@3.29.5)
unplugin: 1.16.0
unplugin-vue-router: 0.10.8(rollup@3.29.5)(vue-router@4.4.5(vue@3.5.13(typescript@5.7.2)))(vue@3.5.13(typescript@5.7.2))
unstorage: 1.13.1(ioredis@5.4.1)
untyped: 1.5.1
vue: 3.5.13(typescript@5.7.2)
vue-bundle-renderer: 2.1.1
vue-devtools-stub: 0.1.0
vue-router: 4.4.5(vue@3.5.13(typescript@5.7.2))
optionalDependencies:
'@parcel/watcher': 2.5.0
'@types/node': 22.9.3
transitivePeerDependencies:
- '@azure/app-configuration'
- '@azure/cosmos'
- '@azure/data-tables'
- '@azure/identity'
- '@azure/keyvault-secrets'
- '@azure/storage-blob'
- '@biomejs/biome'
- '@capacitor/preferences'
- '@electric-sql/pglite'
- '@libsql/client'
- '@netlify/blobs'
- '@planetscale/database'
- '@upstash/redis'
- '@vercel/kv'
- better-sqlite3
- bufferutil
- drizzle-orm
- encoding
- eslint
- idb-keyval
- ioredis
- less
- lightningcss
- magicast
- meow
- mysql2
- optionator
- rollup
- sass
- sass-embedded
- stylelint
- stylus
- sugarss
- supports-color
- terser
- typescript
- utf-8-validate
- vite
- vls
- vti
- vue-tsc
- xml2js
nuxt@3.14.159(@parcel/watcher@2.5.0)(@types/node@22.9.3)(eslint@9.15.0(jiti@2.4.0))(ioredis@5.4.1)(magicast@0.3.5)(optionator@0.9.4)(rollup@4.27.2)(terser@5.36.0)(typescript@5.7.2)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))(vue-tsc@2.1.10(typescript@5.7.2)):
dependencies:
'@nuxt/devalue': 2.0.2
@ -11371,6 +11711,8 @@ snapshots:
prelude-ls@1.2.1: {}
prettier@3.3.3: {}
pretty-bytes@6.1.1: {}
pretty-ms@9.2.0:
@ -11741,6 +12083,15 @@ snapshots:
optionalDependencies:
'@babel/code-frame': 7.26.2
rollup-plugin-visualizer@5.12.0(rollup@3.29.5):
dependencies:
open: 8.4.2
picomatch: 2.3.1
source-map: 0.7.4
yargs: 17.7.2
optionalDependencies:
rollup: 3.29.5
rollup-plugin-visualizer@5.12.0(rollup@4.27.2):
dependencies:
open: 8.4.2
@ -12375,6 +12726,24 @@ snapshots:
css-tree: 3.0.1
ohash: 1.1.4
unimport@3.13.2(rollup@3.29.5):
dependencies:
'@rollup/pluginutils': 5.1.3(rollup@3.29.5)
acorn: 8.14.0
escape-string-regexp: 5.0.0
estree-walker: 3.0.3
fast-glob: 3.3.2
local-pkg: 0.5.0
magic-string: 0.30.12
mlly: 1.7.3
pathe: 1.1.2
pkg-types: 1.2.1
scule: 1.3.0
strip-literal: 2.1.0
unplugin: 1.16.0
transitivePeerDependencies:
- rollup
unimport@3.13.2(rollup@4.27.2):
dependencies:
'@rollup/pluginutils': 5.1.3(rollup@4.27.2)
@ -12424,6 +12793,28 @@ snapshots:
universalify@2.0.1: {}
unplugin-vue-router@0.10.8(rollup@3.29.5)(vue-router@4.4.5(vue@3.5.13(typescript@5.7.2)))(vue@3.5.13(typescript@5.7.2)):
dependencies:
'@babel/types': 7.26.0
'@rollup/pluginutils': 5.1.3(rollup@3.29.5)
'@vue-macros/common': 1.15.0(rollup@3.29.5)(vue@3.5.13(typescript@5.7.2))
ast-walker-scope: 0.6.2
chokidar: 3.6.0
fast-glob: 3.3.2
json5: 2.2.3
local-pkg: 0.5.0
magic-string: 0.30.12
mlly: 1.7.3
pathe: 1.1.2
scule: 1.3.0
unplugin: 1.16.0
yaml: 2.6.0
optionalDependencies:
vue-router: 4.4.5(vue@3.5.13(typescript@5.7.2))
transitivePeerDependencies:
- rollup
- vue
unplugin-vue-router@0.10.8(rollup@4.27.2)(vue-router@4.4.5(vue@3.5.13(typescript@5.7.2)))(vue@3.5.13(typescript@5.7.2)):
dependencies:
'@babel/types': 7.26.0
@ -12595,7 +12986,25 @@ snapshots:
typescript: 5.7.2
vue-tsc: 2.1.10(typescript@5.7.2)
vite-plugin-inspect@0.8.7(@nuxt/kit@3.14.159(magicast@0.3.5)(rollup@4.27.2))(rollup@4.27.2)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0)):
vite-plugin-inspect@0.8.7(@nuxt/kit@3.14.159(magicast@0.3.5)(rollup@3.29.5))(rollup@3.29.5)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0)):
dependencies:
'@antfu/utils': 0.7.10
'@rollup/pluginutils': 5.1.3(rollup@3.29.5)
debug: 4.3.7(supports-color@9.4.0)
error-stack-parser-es: 0.1.5
fs-extra: 11.2.0
open: 10.1.0
perfect-debounce: 1.0.0
picocolors: 1.1.1
sirv: 2.0.4
vite: 5.4.11(@types/node@22.9.3)(terser@5.36.0)
optionalDependencies:
'@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@3.29.5)
transitivePeerDependencies:
- rollup
- supports-color
vite-plugin-inspect@0.8.7(@nuxt/kit@3.14.159(magicast@0.3.5)(rollup@3.29.5))(rollup@4.27.2)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0)):
dependencies:
'@antfu/utils': 0.7.10
'@rollup/pluginutils': 5.1.3(rollup@4.27.2)
@ -12608,7 +13017,7 @@ snapshots:
sirv: 2.0.4
vite: 5.4.11(@types/node@22.9.3)(terser@5.36.0)
optionalDependencies:
'@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@4.27.2)
'@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@3.29.5)
transitivePeerDependencies:
- rollup
- supports-color
@ -12638,9 +13047,9 @@ snapshots:
fsevents: 2.3.3
terser: 5.36.0
vitest-environment-nuxt@1.0.1(h3@1.13.0)(magicast@0.3.5)(nitropack@2.10.4(typescript@5.7.2))(rollup@4.27.2)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))(vitest@2.1.5(@types/node@22.9.3)(terser@5.36.0))(vue-router@4.4.5(vue@3.5.13(typescript@5.7.2)))(vue@3.5.13(typescript@5.7.2)):
vitest-environment-nuxt@1.0.1(h3@1.13.0)(magicast@0.3.5)(nitropack@2.10.4(typescript@5.7.2))(rollup@3.29.5)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))(vitest@2.1.5(@types/node@22.9.3)(terser@5.36.0))(vue-router@4.4.5(vue@3.5.13(typescript@5.7.2)))(vue@3.5.13(typescript@5.7.2)):
dependencies:
'@nuxt/test-utils': 3.14.4(h3@1.13.0)(magicast@0.3.5)(nitropack@2.10.4(typescript@5.7.2))(rollup@4.27.2)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))(vitest@2.1.5(@types/node@22.9.3)(terser@5.36.0))(vue-router@4.4.5(vue@3.5.13(typescript@5.7.2)))(vue@3.5.13(typescript@5.7.2))
'@nuxt/test-utils': 3.14.4(h3@1.13.0)(magicast@0.3.5)(nitropack@2.10.4(typescript@5.7.2))(rollup@3.29.5)(vite@5.4.11(@types/node@22.9.3)(terser@5.36.0))(vitest@2.1.5(@types/node@22.9.3)(terser@5.36.0))(vue-router@4.4.5(vue@3.5.13(typescript@5.7.2)))(vue@3.5.13(typescript@5.7.2))
transitivePeerDependencies:
- '@cucumber/cucumber'
- '@jest/globals'

View File

@ -1,14 +1,164 @@
<script lang="ts" setup>
<script lang="ts">
import { computed, defineComponent, toRef, type PropType } from 'vue'
import { twJoin, twMerge } from 'tailwind-merge'
import defu from 'defu'
import { input } from '../../ui.config'
import type { DeepPartial, InputColor, InputModelModifiers, InputSize, InputType, InputVariant, Strategy } from '../../types'
import { onMounted, ref, useRayUI } from '#build/imports'
const config = input
export default defineComponent({
props: {
modelValue: {
type: [String, Number] as PropType<string | number | null>,
default: '',
},
type: {
type: String as PropType<InputType>,
default: 'text',
},
autofocus: {
type: Boolean,
default: false,
},
autofocusDelay: {
type: Number,
default: 100,
},
required: {
type: Boolean,
default: false,
},
disabled: {
type: Boolean,
default: false,
},
placeholder: {
type: String,
default: null,
},
padded: {
type: Boolean,
default: true,
},
size: {
type: String as PropType<InputSize>,
default: () => config.default.size,
},
color: {
type: String as PropType<InputColor>,
default: () => config.default.color,
},
variant: {
type: String as PropType<InputVariant>,
default: () => config.default.variant,
},
class: {
type: String,
default: '',
},
ui: {
type: Object as PropType<DeepPartial<typeof config> & { strategy?: Strategy }>,
default: () => ({}),
},
modelModifiers: {
type: Object as PropType<InputModelModifiers>,
default: () => ({}),
},
},
emits: ['update:modelValue', 'change', 'blur'],
setup(props, { emit }) {
const { ui, attrs } = useRayUI('input', toRef(props, 'ui'), config)
const modelModifiers = ref(defu({}, props.modelModifiers, { lazy: false, number: false, trim: false }))
const input = ref<HTMLInputElement | null>(null)
const baseClass = computed(() => {
return twMerge(twJoin(
ui.value.base,
ui.value.rounded,
ui.value.placeholder,
ui.value.size[props.size],
props.padded && ui.value.padding[props.size],
ui.value.variant[props.variant].replaceAll('{color}', props.color),
), props.class)
})
const updateValue = (value: string) => {
if (modelModifiers.value.trim) {
value = value.trim()
}
if (modelModifiers.value.number || props.type === 'number') {
const n = Number.parseFloat(value)
value = (Number.isNaN(n) ? value : n) as any
}
emit('update:modelValue', value)
}
const onInput = (e: Event) => {
if (modelModifiers.value.lazy) return
updateValue((e.target as HTMLInputElement).value)
}
const onChange = (e: Event) => {
if (props.type === 'file') {
emit('change', (e.target as HTMLInputElement).files)
return
}
const value = (e.target as HTMLInputElement).value
emit('change', value)
if (modelModifiers.value.lazy) {
updateValue(value)
}
if (modelModifiers.value.trim) {
(e.target as HTMLInputElement).value = value.trim()
}
}
const onBlur = (e: Event) => {
emit('blur', e)
}
onMounted(() => {
if (props.autofocus) {
setTimeout(() => {
input.value?.focus()
}, props.autofocusDelay)
}
})
return {
// eslint-disable-next-line vue/no-dupe-keys
ui,
attrs,
baseClass,
input,
onInput,
onChange,
onBlur,
}
},
})
</script>
<template>
<input
placeholder="test from rayine"
class="rounded-lg border border-neutral-200 px-2 py-1"
>
<div :class="type === 'hidden' ? 'hidden' : ui.wrapper">
<input
ref="input"
:type="type"
:class="baseClass"
:disabled="disabled"
:placeholder="placeholder"
:required="required"
v-bind="type === 'file' ? attrs : { ...attrs, value: modelValue }"
@input="onInput"
@change="onChange"
@blur="onBlur"
>
</div>
</template>
<style scoped>
</style>
<style scoped></style>

View File

@ -1,4 +1,5 @@
export * from './button'
export * from './message'
export * from './input'
export * from './utils'

24
src/runtime/types/input.d.ts vendored Normal file
View File

@ -0,0 +1,24 @@
import type { AppConfig } from 'nuxt/schema'
import type { InputHTMLAttributes } from 'vue'
import type { input } from '../ui.config'
import type { ExtractDeepKey } from './utils'
import type colors from '#ray-colors'
export type InputSize =
| keyof typeof input.size
| ExtractDeepKey<AppConfig, ['rayui', 'input', 'size']>
export type InputColor =
| ExtractDeepKey<AppConfig, ['rayui', 'input', 'color']>
| (typeof colors)[number]
export type InputVariant =
| keyof typeof input.variant
| ExtractDeepKey<AppConfig, ['rayui', 'input', 'variant']>
export type InputType = Extract<
'text' | 'password' | 'number' | 'url' | 'email' | 'search' | 'file' | 'hidden',
InputHTMLAttributes['type']
>
export type InputModelModifiers = {
number?: boolean
trim?: boolean
lazy?: boolean
}

View File

@ -1,3 +1,5 @@
import { standard } from '..'
export default {
base: 'focus:outline-none focus-visible:outline-0 disabled:cursor-not-allowed disabled:opacity-70 aria-disabled:cursor-not-allowed aria-disabled:opacity-70 flex-shrink-0 transition',
rounded: 'rounded-lg',
@ -5,28 +7,13 @@ export default {
block: 'w-full flex justify-center items-center',
inline: 'inline-flex items-center',
size: {
'2xs': 'text-xs',
'xs': 'text-xs',
'sm': 'text-sm',
'md': 'text-sm',
'lg': 'text-sm',
'xl': 'text-base',
...standard.size,
},
padding: {
'2xs': 'px-2 py-1',
'xs': 'px-2.5 py-1.5',
'sm': 'px-2.5 py-1.5',
'md': 'px-3 py-2',
'lg': 'px-3.5 py-2.5',
'xl': 'px-3.5 py-2.5',
...standard.padding,
},
square: {
'2xs': 'p-1',
'xs': 'p-1.5',
'sm': 'p-1.5',
'md': 'p-2',
'lg': 'p-2.5',
'xl': 'p-2.5',
...standard.square,
},
icon: {
base: 'flex-shrink-0',

View File

@ -0,0 +1,23 @@
import { standard } from '..'
export default {
wrapper: 'relative',
base: 'relative w-full block focus:outline-none disabled:cursor-not-allowed disabled:opacity-70 transition',
placeholder: 'placeholder:text-gray-400 dark:placeholder:text-gray-500',
rounded: 'rounded-md',
size: {
...standard.size,
},
padding: {
...standard.padding,
},
variant: {
outline: 'shadow-sm bg-transparent text-gray-900 dark:text-white ring ring-1 ring-inset ring-gray-300 dark:ring-gray-700 focus:ring-2 focus:ring-{color}-500 dark:focus:ring-{color}-400',
plain: 'bg-transparent',
},
default: {
size: 'sm',
color: 'primary',
variant: 'outline',
},
}

View File

@ -1,6 +1,12 @@
// universal
export { default as standard } from './standard'
// elements
export { default as button } from './elements/button'
// forms
export { default as input } from './forms/input'
// overlays
export { default as message } from './overlays/message'
export { default as messages } from './overlays/messages'

View File

@ -0,0 +1,34 @@
export default {
size: {
'2xs': 'text-xs',
'xs': 'text-xs',
'sm': 'text-sm',
'md': 'text-sm',
'lg': 'text-sm',
'xl': 'text-base',
},
gap: {
'2xs': 'gap-x-1',
'xs': 'gap-x-1.5',
'sm': 'gap-x-1.5',
'md': 'gap-x-2',
'lg': 'gap-x-2.5',
'xl': 'gap-x-2.5',
},
padding: {
'2xs': 'px-2 py-1',
'xs': 'px-2.5 py-1.5',
'sm': 'px-2.5 py-1.5',
'md': 'px-3 py-2',
'lg': 'px-3.5 py-2.5',
'xl': 'px-3.5 py-2.5',
},
square: {
'2xs': 'p-1',
'xs': 'p-1.5',
'sm': 'p-1.5',
'md': 'p-2',
'lg': 'p-2.5',
'xl': 'p-2.5',
},
} as const

View File

@ -161,6 +161,24 @@ const safelistForComponent: Record<
variants: ['dark'],
},
],
input: colorsToRegex => [
{
pattern: RegExp(`^text-(${colorsToRegex})-400$`),
variants: ['placeholder'],
},
{
pattern: RegExp(`^text-(${colorsToRegex})-500$`),
variants: ['dark:placeholder'],
},
{
pattern: RegExp(`^ring-(${colorsToRegex})-400$`),
variants: ['dark:focus'],
},
{
pattern: RegExp(`^ring-(${colorsToRegex})-500$`),
variants: ['focus'],
},
],
}
export const generateSafelist = (colors: string[], globalColors: string[]) => {