Skip to content

Commit

Permalink
chore: update provideScope to createScope
Browse files Browse the repository at this point in the history
  • Loading branch information
productdevbook committed Jan 18, 2024
1 parent 23fbe11 commit 401288c
Show file tree
Hide file tree
Showing 22 changed files with 50 additions and 50 deletions.
4 changes: 2 additions & 2 deletions packages/vue/src/accordion/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { OkuElement, PrimitiveProps } from '@oku-ui/primitive'
import { ref } from 'vue'
import type { PropType, Ref } from 'vue'
import type { Scope } from '@oku-ui/provide'
import { ScopePropObject, createProvideScope } from '@oku-ui/provide'
import { ScopePropObject, createScope } from '@oku-ui/provide'
import { createCollection } from '@oku-ui/collection'
import type { RovingFocusGroupProps } from '@oku-ui/roving-focus'
import { collapsibleContentProps, collapsibleProps, collapsibleTriggerProps, createCollapsibleScope } from '@oku-ui/collapsible'
Expand Down Expand Up @@ -57,7 +57,7 @@ export const scopeAccordionProps = {
},
}

export const [createAccordionProvider, createAccordionScope] = createProvideScope(ACCORDION_NAME, [
export const [createAccordionProvider, createAccordionScope] = createScope(ACCORDION_NAME, [
createCollectionScope,
createCollapsibleScope,
])
Expand Down
4 changes: 2 additions & 2 deletions packages/vue/src/alert-dialog/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { OkuElement } from '@oku-ui/primitive'
import { propsOmit } from '@oku-ui/primitive'
import { createDialogScope, dialogCloseProps, dialogContentProps, dialogDescriptionProps, dialogOverlayProps, dialogProps, dialogTitleProps, dialogTriggerProps } from '@oku-ui/dialog'
import type { Scope } from '@oku-ui/provide'
import { ScopePropObject, createProvideScope } from '@oku-ui/provide'
import { ScopePropObject, createScope } from '@oku-ui/provide'
import type { PropType, Ref } from 'vue'

export const ROOT_NAME = 'OkuAlertDialog'
Expand All @@ -29,7 +29,7 @@ export const scopeAlertDialogProps = {
/* AlertDialog - alert-dialog.ts */
/* -------------------------------------------------------------------------- */

export const [createAlertDialogProvider, createAlertDialogScope] = createProvideScope(ROOT_NAME, [createDialogScope])
export const [createAlertDialogProvider, createAlertDialogScope] = createScope(ROOT_NAME, [createDialogScope])
export const useAlertDialogScope = createDialogScope()

type AlertDialogContentContextValue = {
Expand Down
4 changes: 2 additions & 2 deletions packages/vue/src/checkbox/Checkbox.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { createProvideScope } from '@oku-ui/provide'
import { createScope } from '@oku-ui/provide'
import type { PrimitiveProps } from '@oku-ui/primitive'
export interface ScopeCheckbox {
Expand Down Expand Up @@ -31,7 +31,7 @@ export type CheckboxEmits = {
'click': [event: MouseEvent]
}
export const { composeProviderScopes, createProvide } = createProvideScope<CheckboxProvide['_names']>('OkuCheckbox')
export const { composeProviderScopes, createProvide } = createScope<CheckboxProvide['_names']>('OkuCheckbox')
export const { useInject, useProvider }
= createProvide<Omit<CheckboxProvide, '_names'>>('OkuCheckbox')
Expand Down
4 changes: 2 additions & 2 deletions packages/vue/src/collapsible/collapsible.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { PropType, Ref } from 'vue'
import { computed, defineComponent, h, mergeProps, reactive, toRefs, useModel } from 'vue'
import type { OkuElement, PrimitiveProps } from '@oku-ui/primitive'
import { createProvideScope } from '@oku-ui/provide'
import { createScope } from '@oku-ui/provide'
import { Primitive, primitiveProps } from '@oku-ui/primitive'

import { reactiveOmit, useControllable, useForwardRef, useId } from '@oku-ui/use-composable'
Expand Down Expand Up @@ -59,7 +59,7 @@ export const collapsibleProps = {

const COLLAPSIBLE_NAME = 'OkuCollapsible'

export const [createCollapsibleProvide, createCollapsibleScope] = createProvideScope(COLLAPSIBLE_NAME)
export const [createCollapsibleProvide, createCollapsibleScope] = createScope(COLLAPSIBLE_NAME)

export const [collapsibleProvider, useCollapsibleInject]
= createCollapsibleProvide<CollapsibleProvideValue>(COLLAPSIBLE_NAME)
Expand Down
4 changes: 2 additions & 2 deletions packages/vue/src/dialog/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Scope } from '@oku-ui/provide'
import { ScopePropObject, createProvide, createProvideScope } from '@oku-ui/provide'
import { ScopePropObject, createProvide, createScope } from '@oku-ui/provide'
import { type Ref, ref } from 'vue'

export const CONTENT_NAME = 'OkuDialogContent'
Expand All @@ -16,7 +16,7 @@ export const scopeDialogProps = {
},
}

export const [createDialogProvider, createDialogScope] = createProvideScope(DIALOG_NAME)
export const [createDialogProvider, createDialogScope] = createScope(DIALOG_NAME)

type DialogProvideValue = {
triggerRef: Ref<HTMLButtonElement | null>
Expand Down
4 changes: 2 additions & 2 deletions packages/vue/src/hover-card/hoverCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import type { PropType, Ref } from 'vue'
import { computed, defineComponent, h, onBeforeUnmount, ref, toRefs, useModel } from 'vue'
import { primitiveProps } from '@oku-ui/primitive'
import { useControllable } from '@oku-ui/use-composable'
import { createProvideScope } from '@oku-ui/provide'
import { createScope } from '@oku-ui/provide'
import { OkuPopper, createPopperScope } from '@oku-ui/popper'
import { scopeHoverCardProps } from './utils'

export const HOVERCARD_NAME = 'OkuHoverCard'

const [createHoverCardProvider, createHoverCardScope] = createProvideScope(HOVERCARD_NAME, [
const [createHoverCardProvider, createHoverCardScope] = createScope(HOVERCARD_NAME, [
createPopperScope,
])

Expand Down
4 changes: 2 additions & 2 deletions packages/vue/src/hover-card/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createPopperScope } from '@oku-ui/popper'
import type { Scope } from '@oku-ui/provide'
import { ScopePropObject, createProvideScope } from '@oku-ui/provide'
import { ScopePropObject, createScope } from '@oku-ui/provide'

export type ScopeHoverCard<T> = T & { scopeOkuHoverCard?: Scope }

Expand All @@ -10,7 +10,7 @@ export const scopeHoverCardProps = {
},
}

export const [createHoverCardProvide, createHoverCardScope] = createProvideScope('HoverCard', [
export const [createHoverCardProvide, createHoverCardScope] = createScope('HoverCard', [
createPopperScope,
])

Expand Down
4 changes: 2 additions & 2 deletions packages/vue/src/menu/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ref } from 'vue'
import type { OkuElement, PrimitiveProps } from '@oku-ui/primitive'
import { primitiveProps, propsOmit } from '@oku-ui/primitive'
import type { Scope } from '@oku-ui/provide'
import { ScopePropObject, createProvideScope } from '@oku-ui/provide'
import { ScopePropObject, createScope } from '@oku-ui/provide'
import { createPopperScope, popperAnchorProps, popperArrowProps, popperContentProps } from '@oku-ui/popper'
import type { PopperAnchorElement, PopperAnchorNaviteElement, PopperAnchorProps, PopperArrowElement, PopperArrowNaviteElement, PopperArrowProps, PopperContentElement, PopperContentNaviteElement, PopperContentProps } from '@oku-ui/popper'
import type { Direction } from '@oku-ui/direction'
Expand Down Expand Up @@ -66,7 +66,7 @@ type ItemData = { disabled: boolean, textValue: string }

export const { CollectionProvider, CollectionSlot, CollectionItemSlot, useCollection, createCollectionScope } = createCollection<MenuItemElement, ItemData>(MENU_NAME)

export const [createMenuProvide, createMenuScope] = createProvideScope(MENU_NAME, [
export const [createMenuProvide, createMenuScope] = createScope(MENU_NAME, [
createCollectionScope,
createPopperScope,
createRovingFocusGroupScope,
Expand Down
4 changes: 2 additions & 2 deletions packages/vue/src/popover/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { PortalProps } from '@oku-ui/portal'
import type { OkuElement, PrimitiveProps } from '@oku-ui/primitive'
import { primitiveProps, propsOmit } from '@oku-ui/primitive'
import type { Scope } from '@oku-ui/provide'
import { ScopePropObject, createProvideScope } from '@oku-ui/provide'
import { ScopePropObject, createScope } from '@oku-ui/provide'
import { type PropType, type Ref, ref } from 'vue'

export type ScopePopover<T> = T & { scopeOkuPopover?: Scope }
Expand All @@ -33,7 +33,7 @@ export const PORTAL_NAME = 'OkuPopoverPortal'
/* OkuPopover - popover.ts */
/* -------------------------------------------------------------------------- */

export const [createPopoverProvide, createPopoverScope] = createProvideScope(POPOVER_NAME, [
export const [createPopoverProvide, createPopoverScope] = createScope(POPOVER_NAME, [
createPopperScope,
])

Expand Down
4 changes: 2 additions & 2 deletions packages/vue/src/popper/Popper.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<script lang="ts">
import { createProvideScope } from '@oku-ui/provide'
import { createScope } from '@oku-ui/provide'
import { defineOptions, ref } from 'vue'
export interface ScopePopper {
scopeOkuPopper?: any
}
export const { composeProviderScopes, createProvide }
= createProvideScope<PopperProvide['_names']>('OkuPopper')
= createScope<PopperProvide['_names']>('OkuPopper')
export type PopperProvide = {
_names: 'OkuPopper' | 'OkuPopperContent'
Expand Down
4 changes: 2 additions & 2 deletions packages/vue/src/progress/progress.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { OkuElement } from '@oku-ui/primitive'
import { Primitive, primitiveProps } from '@oku-ui/primitive'
import type { Scope } from '@oku-ui/provide'
import { createProvideScope } from '@oku-ui/provide'
import { createScope } from '@oku-ui/provide'
import type { PropType, Ref } from 'vue'
import { computed, defineComponent, h, mergeProps, reactive, toRefs, useModel } from 'vue'
import { reactiveOmit, useForwardRef } from '@oku-ui/use-composable'
Expand Down Expand Up @@ -58,7 +58,7 @@ export const progressProps = {
}

export const [createProgressContext, createProgressScope]
= createProvideScope(PROGRESS_NAME)
= createScope(PROGRESS_NAME)

export const [progressProvider, useProgressInject]
= createProgressContext<ProgressInjectValue>(PROGRESS_NAME)
Expand Down
14 changes: 7 additions & 7 deletions packages/vue/src/provide/tests/provide.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Component } from 'vue'
import { defineComponent, h } from 'vue'
import { describe, expect, it, vitest } from 'vitest'
import { mount } from '@vue/test-utils'
import { ScopePropObject, createProvide, createProvideScope } from '../'
import { ScopePropObject, createProvide, createScope } from '../'

describe('provide', () => {
it('createProvide consumerName emty test', async () => {
Expand Down Expand Up @@ -145,9 +145,9 @@ describe('provide', () => {
expect(component.html()).toContain('<div>Merhaba asdasda</div>')
})

it('createProvideScope', async () => {
it('createScope', async () => {
const AVATAR_NAME = 'OkuAvatar'
const [createAvatarProvide, _createAvatarScope] = createProvideScope(AVATAR_NAME)
const [createAvatarProvide, _createAvatarScope] = createScope(AVATAR_NAME)

type AvatarProvideValue = {
imageLoadingStatus: 'loading' | 'loaded' | 'error'
Expand Down Expand Up @@ -200,19 +200,19 @@ describe('provide', () => {
expect(component.html()).toContain('<div>loading</div>')
})

it('createProvideScope createScope empty', async () => {
const [_createCollectionProvide, createCollectionScope] = createProvideScope('TestCollectionProvider')
it('createScope createScope empty', async () => {
const [_createCollectionProvide, createCollectionScope] = createScope('TestCollectionProvider')

expect(createCollectionScope()({})).toEqual({
scopeTestCollectionProvider: { TestCollectionProvider: [] },
})
})

it('createProvideScope createScope component', async () => {
it('createScope createScope component', async () => {
// Collection
const PROVIDER_NAME = 'TestCollectionProvider'

const [createCollectionProvide, createCollectionScope] = createProvideScope(PROVIDER_NAME)
const [createCollectionProvide, createCollectionScope] = createScope(PROVIDER_NAME)

const [_collectionProvide, _useCollectionInject] = createCollectionProvide<{
collectionRef: 'test'
Expand Down
4 changes: 2 additions & 2 deletions packages/vue/src/radio-group/Radio.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Primitive, primitiveProps } from '@oku-ui/primitive'
import type { OkuElement } from '@oku-ui/primitive'
import { createProvideScope } from '@oku-ui/provide'
import { createScope } from '@oku-ui/provide'
import { reactiveOmit, useComposedRefs, useForwardRef } from '@oku-ui/use-composable'
import { computed, defineComponent, h, mergeProps, reactive, ref, toRefs } from 'vue'
import type { PropType, Ref } from 'vue'
Expand All @@ -10,7 +10,7 @@ import { OkuBubbleInput } from './BubbleInput'

const RADIO_NAME = 'OkuRadio'

export const [createRadioProvide, createRadioScope] = createProvideScope(RADIO_NAME)
export const [createRadioProvide, createRadioScope] = createScope(RADIO_NAME)

type RadioProvideValue = {
checked: Ref<boolean>
Expand Down
4 changes: 2 additions & 2 deletions packages/vue/src/radio-group/RadioGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { OkuElement, PrimitiveProps } from '@oku-ui/primitive'
import { Primitive, primitiveProps } from '@oku-ui/primitive'
import { computed, defineComponent, h, mergeProps, reactive, toRefs, useModel } from 'vue'
import type { PropType, Ref } from 'vue'
import { createProvideScope } from '@oku-ui/provide'
import { createScope } from '@oku-ui/provide'
import { OkuRovingFocusGroup, createRovingFocusGroupScope } from '@oku-ui/roving-focus'
import { reactiveOmit, useControllable, useForwardRef } from '@oku-ui/use-composable'
import { useDirection } from '@oku-ui/direction'
Expand All @@ -13,7 +13,7 @@ import { scopeRadioGroupProps } from './utils'

const RADIO_GROUP_NAME = 'OkuRadioGroup'

export const [createRadioGroupProvider, createRadioGroupScope] = createProvideScope(RADIO_GROUP_NAME, [
export const [createRadioGroupProvider, createRadioGroupScope] = createScope(RADIO_GROUP_NAME, [
createRovingFocusGroupScope,
createRadioScope,
])
Expand Down
4 changes: 2 additions & 2 deletions packages/vue/src/roving-focus/props.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ScopePropObject, createProvideScope } from '@oku-ui/provide'
import { ScopePropObject, createScope } from '@oku-ui/provide'
import type { CollectionPropsType } from '@oku-ui/collection'
import { createCollection } from '@oku-ui/collection'
import type { ComputedRef, PropType, Ref } from 'vue'
Expand Down Expand Up @@ -170,7 +170,7 @@ export const { CollectionItemSlot, CollectionProvider, CollectionSlot, useCollec
},
})

export const [createRovingFocusGroupProvide, createRovingFocusGroupScope] = createProvideScope(
export const [createRovingFocusGroupProvide, createRovingFocusGroupScope] = createScope(
GROUP_NAME,
[createCollectionScope],
)
Expand Down
6 changes: 3 additions & 3 deletions packages/vue/src/scroll-area/props.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { primitiveProps, propsOmit } from '@oku-ui/primitive'
import { ScopePropObject, createProvideScope } from '@oku-ui/provide'
import { ScopePropObject, createScope } from '@oku-ui/provide'
import type { PropType, Ref } from 'vue'
import type { Direction } from '@oku-ui/direction'
import type { OkuElement, PrimitiveProps } from '@oku-ui/primitive'
Expand Down Expand Up @@ -85,7 +85,7 @@ export const scrollAreaProps = {
},
emits: {},
}
export const [createScrollAreaProvide, createScrollAreaScope] = createProvideScope(SCROLL_AREA_NAME)
export const [createScrollAreaProvide, createScrollAreaScope] = createScope(SCROLL_AREA_NAME)

export const [scrollAreaProvider, useScrollAreaInject] = createScrollAreaProvide<ScrollAreaProvideValue>(SCROLL_AREA_NAME)

Expand Down Expand Up @@ -201,7 +201,7 @@ export type ScrollAreaScrollbarImplElement = HTMLDivElement
export interface ScrollAreaScrollbarImplProps extends Omit<PrimitiveProps, keyof ScrollAreaScrollbarImplPrivateProps>,
ScrollAreaScrollbarImplPrivateProps { }

export const [createScrollProvide, createScrollScope] = createProvideScope(SCROLL_AREA_SCROLLBAR_NAME)
export const [createScrollProvide, createScrollScope] = createScope(SCROLL_AREA_SCROLLBAR_NAME)

export type ScrollbarProvideValue = {
hasThumb: Ref<boolean>
Expand Down
4 changes: 2 additions & 2 deletions packages/vue/src/switch/Switch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
} from '@oku-ui/use-composable'
import type { OkuElement, PrimitiveProps } from '@oku-ui/primitive'
import { Primitive, primitiveProps } from '@oku-ui/primitive'
import { createProvideScope } from '@oku-ui/provide'
import { createScope } from '@oku-ui/provide'
import { composeEventHandlers } from '@oku-ui/utils'
import { getState, scopeSwitchProps } from './util'
import { BubbleInput } from './BubbleInput'
Expand Down Expand Up @@ -92,7 +92,7 @@ export const switchProps = {
}

const [createSwitchProvide, createSwitchScope]
= createProvideScope(SWITCH_NAME)
= createScope(SWITCH_NAME)

const [switchProvider, useSwitchInject]
= createSwitchProvide<SwitchProvideValue>(SWITCH_NAME)
Expand Down
4 changes: 2 additions & 2 deletions packages/vue/src/tabs/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { OkuElement, PrimitiveProps } from '@oku-ui/primitive'
import { Primitive, primitiveProps } from '@oku-ui/primitive'
import { computed, defineComponent, h, mergeProps, reactive, toRefs, useModel } from 'vue'
import type { PropType, Ref } from 'vue'
import { createProvideScope } from '@oku-ui/provide'
import { createScope } from '@oku-ui/provide'
import type { RovingFocusGroupProps } from '@oku-ui/roving-focus'
import { createRovingFocusGroupScope } from '@oku-ui/roving-focus'
import { reactiveOmit, useControllable, useForwardRef, useId } from '@oku-ui/use-composable'
Expand Down Expand Up @@ -98,7 +98,7 @@ interface TabsProvideValue {
activationMode?: Ref<TabsProps['activationMode']>
}

export const [createTabsProvider, _createTabsScope] = createProvideScope(TAB_NAME, [
export const [createTabsProvider, _createTabsScope] = createScope(TAB_NAME, [
createRovingFocusGroupScope,
])

Expand Down
4 changes: 2 additions & 2 deletions packages/vue/src/toast/share.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createProvideScope } from '@oku-ui/provide'
import { createScope } from '@oku-ui/provide'
import { createCollection } from '@oku-ui/collection'
import type { Ref } from 'vue'
import type { ToastImplElement, ToastImplNaviteElement } from './toast-impl'
Expand Down Expand Up @@ -26,7 +26,7 @@ type ToastProviderProvideValue = {
isClosePausedRef: Ref<boolean>
}

export const [createToastProvide, createToastScope] = createProvideScope('Toast', [createCollectionScope])
export const [createToastProvide, createToastScope] = createScope('Toast', [createCollectionScope])

export const [toastProviderProvider, useToastProviderInject] = createToastProvide<ToastProviderProvideValue>(PROVIDER_NAME)

Expand Down
4 changes: 2 additions & 2 deletions packages/vue/src/toggle-group/props.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { PropType, Ref } from 'vue'
import { ScopePropObject, createProvideScope } from '@oku-ui/provide'
import { ScopePropObject, createScope } from '@oku-ui/provide'
import type { Scope } from '@oku-ui/provide'
import { primitiveProps, propsOmit } from '@oku-ui/primitive'
import type { OkuElement, PrimitiveProps } from '@oku-ui/primitive'
Expand Down Expand Up @@ -30,7 +30,7 @@ export const TOGGLE_GROUP_ITEM_NAME = 'OkuToggleGroupItem'
export type ToggleGroupNativeElement = ToggleGroupImplSingleNativeElement | ToggleGroupImplMultipleNativeElement
export type ToggleGroupElement = ToggleGroupImplSingleElement | ToggleGroupImplMultipleElement

export const [createToggleGroupProvider, createToggleGroupScope] = createProvideScope(TOGGLE_GROUP_NAME, [
export const [createToggleGroupProvider, createToggleGroupScope] = createScope(TOGGLE_GROUP_NAME, [
createRovingFocusGroupScope,
])

Expand Down
4 changes: 2 additions & 2 deletions packages/vue/src/toolbar/toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineComponent, h, mergeProps, reactive, toRefs } from 'vue'
import type { OkuElement, PrimitiveProps } from '@oku-ui/primitive'
import { Primitive, primitiveProps } from '@oku-ui/primitive'
import { reactiveOmit, useForwardRef } from '@oku-ui/use-composable'
import { createProvideScope } from '@oku-ui/provide'
import { createScope } from '@oku-ui/provide'
import { OkuRovingFocusGroup, createRovingFocusGroupScope } from '@oku-ui/roving-focus'
import type { RovingFocusGroupProps } from '@oku-ui/roving-focus'
import { createToggleGroupScope } from '@oku-ui/toggle-group'
Expand All @@ -12,7 +12,7 @@ import { scopeToolbarProps } from './utils'

const TOOLBAR_NAME = 'OkuToolbar'

const [createToolbarProvider, createToolbarScope] = createProvideScope(TOOLBAR_NAME, [
const [createToolbarProvider, createToolbarScope] = createScope(TOOLBAR_NAME, [
createRovingFocusGroupScope,
createToggleGroupScope,
])
Expand Down
Loading

0 comments on commit 401288c

Please sign in to comment.