Skip to content

Commit 5ab96e8

Browse files
committed
refactor(useRegistry): rename to useRegistry
1 parent c8a2426 commit 5ab96e8

File tree

19 files changed

+132
-131
lines changed

19 files changed

+132
-131
lines changed

.github/.instructions-0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Components in this library should be:
5757
| `useHydration` | Manage SSR hydration process and optimization | `src/composables/useHydration/` |
5858
| `useKeydown` | Handle keyboard events with automatic cleanup | `src/composables/useKeydown/` |
5959
| `useLocale` | Internationalization with multiple languages and interpolation | `src/composables/useLocale/` |
60-
| `useRegistrar` | Foundation for registration-based systems | `src/composables/useRegistrar/` |
60+
| `useRegistry` | Foundation for registration-based systems | `src/composables/useRegistry/` |
6161
| `useStep` | Manage multi-step process state | `src/composables/useStep/` |
6262
| `useTheme` | Theme management with dynamic switching | `src/composables/useTheme/` |
6363
| `useTokens` | Design token system management | `src/composables/useTokens/` |

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Core foundational components and composables:
2828
- `useHydration` - SSR hydration helpers
2929
- `useKeydown` - Keyboard event handling
3030
- `useLocale` - Internationalization support
31-
- `useRegistrar` - Component registration system
31+
- `useRegistry` - Component registration system
3232
- `useStep` - Step navigation logic
3333
- `useTheme` - Theme switching and CSS variable management
3434
- `useTokens` - Design token system

apps/docs/src/components/app/AppNav.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
{
4646
name: 'Registration',
4747
children: [
48-
{ name: 'useRegistrar', to: '/composables/registration/use-registrar' },
48+
{ name: 'useRegistry', to: '/composables/registration/use-registry' },
4949
{ name: 'useTokens', to: '/composables/registration/use-tokens' },
5050
],
5151
},

apps/docs/src/pages/composables/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Reusable pieces of logic that can be shared across components, providing encapsu
1414
| [useKeydown](/composables/use-keydown) | Handle keyboard events with automatic cleanup |
1515
| [useLocale](/composables/use-locale) | Internationalization system for multiple languages |
1616
| [useMarkdown](/composables/use-markdown) | Render Markdown content in Vue applications |
17-
| [useRegistrar](/composables/use-registrar) | Foundation for registration-based systems |
17+
| [useRegistry](/composables/use-registry) | Foundation for registration-based systems |
1818
| [useSingle](/composables/use-single) | Simplified single-selection wrapper around useGroup |
1919
| [useStep](/composables/use-step) | Manage multi-step processes like forms or wizards |
2020
| [useStorage](/composables/use-storage) | Reactive interface to browser storage APIs |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# useRegistrar
1+
# useRegistry
22

33
A foundational composable for building registration-based systems, managing collections of registered items with automatic indexing and lifecycle management.

packages/0/src/components/Avatar/AvatarRoot.vue

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,36 @@
33
import { Atom } from '#v0/components/Atom'
44
55
// Composables
6-
import { useRegistrar } from '#v0/composables'
6+
import { useRegistry } from '#v0/composables'
77
88
// Utilities
99
import { computed, toRef } from 'vue'
1010
1111
// Types
1212
import type { AtomProps } from '#v0/components/Atom'
13-
import type { RegistrarContext, RegistrarItem, RegistrarTicket } from '#v0/composables'
13+
import type { RegistryContext, RegistryItem, RegistryTicket } from '#v0/composables'
1414
import type { ComputedGetter } from 'vue'
1515
1616
export interface AvatarRootProps extends AtomProps {}
1717
18-
export interface AvatarItem extends RegistrarItem {
18+
export interface AvatarItem extends RegistryItem {
1919
type: 'image' | 'fallback'
2020
priority: number
2121
status: 'idle' | 'loading' | 'loaded' | 'error'
2222
}
2323
24-
interface AvatarTicket extends RegistrarTicket {
24+
interface AvatarTicket extends RegistryTicket {
2525
type: AvatarItem['type']
2626
priority: AvatarItem['priority']
2727
status: AvatarItem['status']
2828
isVisible: Readonly<ComputedGetter<boolean>>
2929
}
3030
31-
export interface AvatarContext extends RegistrarContext<AvatarTicket, AvatarItem> {
31+
export interface AvatarContext extends RegistryContext<AvatarTicket, AvatarItem> {
3232
reset: () => void
3333
}
3434
35-
export const [useAvatarContext, provideAvatarContext, registrar] = useRegistrar<AvatarTicket, AvatarContext>('avatar')
35+
export const [useAvatarContext, provideAvatarContext, registry] = useRegistry<AvatarTicket, AvatarContext>('avatar')
3636
</script>
3737

3838
<script setup lang="ts">
@@ -41,13 +41,13 @@
4141
const { as = 'div', renderless } = defineProps<AvatarRootProps>()
4242
4343
const imageItems = computed(() => (
44-
Array.from(registrar.registeredItems.values())
44+
Array.from(registry.registeredItems.values())
4545
.filter(item => item.type === 'image')
4646
.toSorted((a, b) => a.priority - b.priority)
4747
))
4848
4949
const fallbackItems = computed(() => (
50-
Array.from(registrar.registeredItems.values())
50+
Array.from(registry.registeredItems.values())
5151
.filter(item => item.type === 'fallback')
5252
))
5353
@@ -64,14 +64,14 @@
6464
return undefined
6565
})
6666
67-
const register: typeof registrar.register = createAvatarItem => {
68-
const ticket = registrar.register(order => {
69-
const avatarItem = registrar.intake(order, createAvatarItem)
67+
const register: typeof registry.register = createAvatarItem => {
68+
const ticket = registry.register(order => {
69+
const avatarItem = registry.intake(order, createAvatarItem)
7070
7171
return {
7272
...avatarItem,
7373
type: avatarItem?.type ?? 'fallback',
74-
priority: avatarItem?.priority ?? registrar.registeredItems.size,
74+
priority: avatarItem?.priority ?? registry.registeredItems.size,
7575
status: avatarItem?.status ?? 'idle',
7676
isVisible: toRef(() => visibleItem.value?.id === order.id),
7777
}
@@ -81,15 +81,15 @@
8181
}
8282
8383
function reset () {
84-
for (const item of registrar.registeredItems.values()) {
84+
for (const item of registry.registeredItems.values()) {
8585
if (item.type === 'image') {
8686
item.status = 'idle'
8787
}
8888
}
8989
}
9090
9191
provideAvatarContext({
92-
...registrar,
92+
...registry,
9393
register,
9494
reset,
9595
})

packages/0/src/composables/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export * from './useHydration'
55
export * from './useKeydown'
66
export * from './useLocale'
77
export * from './useLogger'
8-
export * from './useRegistrar'
8+
export * from './useRegistry'
99
export * from './useSingle'
1010
export * from './useStep'
1111
export * from './useStorage'

packages/0/src/composables/useGroup/index.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
import { createTrinity } from '#v0/factories/createTrinity'
33

44
// Composables
5-
import { useRegistrar } from '#v0/composables/useRegistrar'
5+
import { useRegistry } from '#v0/composables/useRegistry'
66

77
// Utilities
88
import { computed, getCurrentInstance, nextTick, onMounted, reactive, toRef, toValue, watch } from 'vue'
99
import { genId } from '#v0/utilities/helpers'
1010

1111
// Types
1212
import type { App, ComputedGetter, ComputedRef, Reactive, Ref } from 'vue'
13-
import type { RegistrarContext, RegistrarTicket } from '#v0/composables/useRegistrar'
13+
import type { RegistryContext, RegistryTicket } from '#v0/composables/useRegistry'
1414
import type { ID } from '#v0/types'
1515

16-
export type GroupTicket = RegistrarTicket & {
16+
export type GroupTicket = RegistryTicket & {
1717
disabled: boolean
1818
value: unknown
1919
valueIsIndex: boolean
@@ -22,7 +22,7 @@ export type GroupTicket = RegistrarTicket & {
2222
toggle: () => void
2323
}
2424

25-
export type GroupContext = RegistrarContext & {
25+
export type GroupContext = RegistryContext & {
2626
selectedItems: ComputedRef<Set<GroupTicket | undefined>>
2727
selectedIndexes: ComputedRef<Set<number>>
2828
selectedIds: Reactive<Set<ID>>
@@ -46,13 +46,13 @@ export type GroupOptions = {
4646
}
4747

4848
/**
49-
* Creates a group registrar for managing group items within a specific namespace.
49+
* Creates a group registry for managing group items within a specific namespace.
5050
* This function provides a way to register, unregister, and manage group selections,
5151
* allowing for dynamic group management in applications.
5252
*
5353
* @param namespace The namespace for the group context.
5454
* @param options Optional configuration for the group behavior.
55-
* @template Z The type of the group items managed by the registrar.
55+
* @template Z The type of the group items managed by the registry.
5656
* @template E The type of the group context.
5757
* @returns A tuple containing the inject function, provide function, and the group context.
5858
*
@@ -65,15 +65,15 @@ export function useGroup<
6565
namespace: string,
6666
options?: GroupOptions,
6767
) {
68-
const [useRegistrarContext, provideRegistrarContext, registrar] = useRegistrar<Z, E>(namespace)
68+
const [useRegistryContext, provideRegistryContext, registry] = useRegistry<Z, E>(namespace)
6969

7070
const catalog = reactive(new Map<unknown, ID>())
7171
const selectedIds = reactive(new Set<ID>())
7272
let initialValue: unknown | unknown[] = null
7373

7474
const selectedItems = computed(() => {
7575
return new Set(
76-
Array.from(selectedIds).map(id => registrar.collection.get(id)),
76+
Array.from(selectedIds).map(id => registry.collection.get(id)),
7777
)
7878
})
7979

@@ -94,17 +94,17 @@ export function useGroup<
9494
}
9595

9696
function mandate () {
97-
if (!options?.mandatory || selectedIds.size > 0 || registrar.collection.size === 0) return
97+
if (!options?.mandatory || selectedIds.size > 0 || registry.collection.size === 0) return
9898

9999
if (options.mandatory === 'force') {
100-
const first = registrar.collection.values().next().value
100+
const first = registry.collection.values().next().value
101101

102102
if (first) selectedIds.add(first.id)
103103

104104
return
105105
}
106106

107-
for (const item of registrar.collection.values()) {
107+
for (const item of registry.collection.values()) {
108108
if (item.disabled) continue
109109
selectedIds.add(item.id)
110110

@@ -113,7 +113,7 @@ export function useGroup<
113113
}
114114

115115
function reindex () {
116-
registrar.reindex()
116+
registry.reindex()
117117
}
118118

119119
function reset () {
@@ -130,7 +130,7 @@ export function useGroup<
130130
for (const id of Array.isArray(ids) ? ids : [ids]) {
131131
if (!id) continue
132132

133-
const item = registrar.collection.get(id)
133+
const item = registry.collection.get(id)
134134

135135
if (!item || item.disabled) continue
136136

@@ -157,14 +157,14 @@ export function useGroup<
157157
function register (registrant: Partial<E>, id: ID = genId()): Reactive<E> {
158158
const item: Partial<E> = {
159159
disabled: false,
160-
value: registrant?.value ?? registrar.collection.size,
160+
value: registrant?.value ?? registry.collection.size,
161161
valueIsIndex: registrant?.value == null,
162162
isActive: toRef(() => selectedIds.has(ticket.id)),
163163
toggle: () => toggle(ticket.id),
164164
...registrant,
165165
}
166166

167-
const ticket = registrar.register(item, id)
167+
const ticket = registry.register(item, id)
168168

169169
catalog.set(ticket.value, ticket.id)
170170

@@ -183,7 +183,7 @@ export function useGroup<
183183

184184
function unregister (id: ID) {
185185
selectedIds.delete(id)
186-
registrar.unregister(id)
186+
registry.unregister(id)
187187
}
188188

189189
if (getCurrentInstance()) {
@@ -193,7 +193,7 @@ export function useGroup<
193193
}
194194

195195
const context = {
196-
...registrar,
196+
...registry,
197197
selectedItems,
198198
selectedIndexes,
199199
selectedIds,
@@ -255,8 +255,8 @@ export function useGroup<
255255
})
256256
}
257257

258-
return provideRegistrarContext(model, _context, app)
258+
return provideRegistryContext(model, _context, app)
259259
}
260260

261-
return createTrinity<Z>(useRegistrarContext, provideGroupContext, context)
261+
return createTrinity<Z>(useRegistryContext, provideGroupContext, context)
262262
}

packages/0/src/composables/useLocale/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ export interface LocalePlugin {
3636
}
3737

3838
/**
39-
* Creates a locale registrar for managing locale translations and number formatting.
39+
* Creates a locale registry for managing locale translations and number formatting.
4040
*
4141
* @param namespace The namespace for the locale context.
4242
* @param options Configuration including adapter and messages.
4343
* @template Z The type of the locale context.
44-
* @template E The type of the locale items managed by the registrar.
44+
* @template E The type of the locale items managed by the registry.
4545
* @returns An array containing the inject function, provide function, and the locale context.
4646
*/
4747
export function createLocale<
@@ -52,7 +52,7 @@ export function createLocale<
5252
options: LocalePluginOptions = {},
5353
) {
5454
const { adapter = new Vuetify0LocaleAdapter(), messages = {} } = options
55-
const [useLocaleContext, provideLocaleContext, registrar] = useSingle<Z, E>(namespace)
55+
const [useLocaleContext, provideLocaleContext, registry] = useSingle<Z, E>(namespace)
5656

5757
function resolve (locale: ID, str: string): string {
5858
return str.replace(/{([a-zA-Z0-9.-_]+)}/g, (match, linkedKey) => {
@@ -67,7 +67,7 @@ export function createLocale<
6767
}
6868

6969
function t (key: string, ...params: unknown[]): string {
70-
const locale = registrar.selectedId.value
70+
const locale = registry.selectedId.value
7171

7272
if (!locale) return key
7373

@@ -81,11 +81,11 @@ export function createLocale<
8181
}
8282

8383
function n (value: number, ...params: unknown[]): string {
84-
return adapter.n(value, registrar.selectedId.value, ...params)
84+
return adapter.n(value, registry.selectedId.value, ...params)
8585
}
8686

8787
return createTrinity<Z>(useLocaleContext, provideLocaleContext, {
88-
...registrar,
88+
...registry,
8989
t,
9090
n,
9191
} as Z)
@@ -106,9 +106,9 @@ export function useLocale (): LocaleContext {
106106
*
107107
* @param options Configuration for adapter, default locale, and messages.
108108
* @template Z The type of the locale context.
109-
* @template E The type of the locale items managed by the registrar.
109+
* @template E The type of the locale items managed by the registry.
110110
* @template R The type of the token context.
111-
* @template O The type of the token items managed by the registrar.
111+
* @template O The type of the token items managed by the registry.
112112
* @returns Vue install function for the plugin
113113
*/
114114
export function createLocalePlugin<

0 commit comments

Comments
 (0)