Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(core): one package use-composable #109

Merged
merged 4 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/components/avatar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"dependencies": {
"@oku-ui/primitive": "workspace:^",
"@oku-ui/provide": "workspace:^",
"@oku-ui/use-callback-ref": "workspace:^",
"@oku-ui/use-composable": "workspace:^",
"@oku-ui/utils": "workspace:^"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/avatar/src/avatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { ElementType, MergeProps, PrimitiveProps, RefElement } from '@oku-u
import { Primitive } from '@oku-ui/primitive'
import type { Scope } from '@oku-ui/provide'
import { createProvideScope } from '@oku-ui/provide'
import { useCallbackRef } from '@oku-ui/use-callback-ref'
import { useCallbackRef } from '@oku-ui/use-composable'

function useImageLoadingStatus(src?: string) {
const loadingStatus = ref<ImageLoadingStatus>('idle')
Expand Down
5 changes: 1 addition & 4 deletions packages/components/checkbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,9 @@
"vue": "^3.3.1"
},
"dependencies": {
"@oku-ui/compose-refs": "workspace:^",
"@oku-ui/primitive": "workspace:^",
"@oku-ui/provide": "workspace:^",
"@oku-ui/use-controllable-ref": "workspace:^",
"@oku-ui/use-previous": "workspace:^",
"@oku-ui/use-size": "workspace:^",
"@oku-ui/use-composable": "workspace:^",
"@oku-ui/utils": "workspace:^"
},
"devDependencies": {
Expand Down
14 changes: 8 additions & 6 deletions packages/components/checkbox/src/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import { createProvideScope } from '@oku-ui/provide'
import type { PropType, Ref } from 'vue'
import { Transition, computed, defineComponent, h, onMounted, ref, watchEffect } from 'vue'

import { useControllableRef } from '@oku-ui/use-controllable-ref'
import { composeEventHandlers } from '@oku-ui/utils'
import { usePrevious } from '@oku-ui/use-previous'
import { useSize } from '@oku-ui/use-size'
import { useControllableRef, usePrevious, useSize } from '@oku-ui/use-composable'
import { Primitive } from '@oku-ui/primitive'

// import { useComposedRefs } from '@oku-ui/compose-refs'
Expand Down Expand Up @@ -216,8 +214,10 @@ const Checkbox = defineComponent({
}
}),
},
slots.default?.(),
), isFormControl && h(
{
default: () => slots.default?.(),
}),
isFormControl && h(
BubbleInput,
{
control: _button.value,
Expand Down Expand Up @@ -277,7 +277,9 @@ const CheckboxIndicator = defineComponent({
...indicatorProps,
'style': { pointerEvents: 'none', ...attrs.style as any },
},
slots.default?.(),
{
default: () => slots.default?.(),
},
)
: null,
])
Expand Down
3 changes: 2 additions & 1 deletion packages/components/checkbox/src/stories/CheckboxDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<script setup lang="ts">
import type { CheckboxProps } from '@oku-ui/checkbox'
import { OkuCheckbox, OkuCheckboxIndicator } from '@oku-ui/checkbox'
import { OkuLabel } from '@oku-ui/label'

export interface ICheckBoxProps extends CheckboxProps {
template?: '#1' | '#2' | '#3'
Expand Down Expand Up @@ -66,7 +67,7 @@ withDefaults(defineProps<ICheckBoxProps>(), {
<OkuLabel>
Label
<OkuCheckbox
id="checkbox"
id="checkboxx"
class="w-6 h-6 flex bg-gray-300 rounded-md text-red-500 checked:text-red-600"
>
<OkuCheckboxIndicator class="w-6 h-6 flex items-center justify-center text-blue-500">
Expand Down
10 changes: 0 additions & 10 deletions packages/core/compose-refs/README.md

This file was deleted.

40 changes: 0 additions & 40 deletions packages/core/compose-refs/package.json

This file was deleted.

1 change: 0 additions & 1 deletion packages/core/compose-refs/src/index.ts

This file was deleted.

11 changes: 0 additions & 11 deletions packages/core/use-callback-ref/README.md

This file was deleted.

40 changes: 0 additions & 40 deletions packages/core/use-callback-ref/package.json

This file was deleted.

1 change: 0 additions & 1 deletion packages/core/use-callback-ref/src/index.ts

This file was deleted.

9 changes: 0 additions & 9 deletions packages/core/use-callback-ref/tsconfig.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@oku-ui/use-size",
"name": "@oku-ui/use-composable",
"type": "module",
"version": "1.0.0",
"license": "MIT",
Expand All @@ -9,7 +9,7 @@
"repository": {
"type": "git",
"url": "git+https://github.com/oku-ui/primitives.git",
"directory": "packages/core/use-size"
"directory": "packages/core/use-composable"
},
"bugs": {
"url": "https://github.com/oku-ui/primitives/issues"
Expand All @@ -18,18 +18,18 @@
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.cjs",
"import": "./dist/index.mjs"
"import": "./dist/index.js"
}
},
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "unbuild",
"dev": "unbuild --stub"
"build": "tsup",
"dev": "tsup --watch"
},
"peerDependencies": {
"vue": "^3.3.1"
Expand Down
5 changes: 5 additions & 0 deletions packages/core/use-composable/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export { useControllableRef } from './useControllableRef'
export { useCallbackRef } from './useCallbackRef'
export { useSize } from './useSize'
export { usePrevious } from './usePrevious'
export { useComposedRefs, composeRefs } from './useComposedRefs'
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
// @ts-nocheck
import type { Ref } from 'vue'
import { computed, ref, watch, watchEffect } from 'vue'
import { useCallbackRef } from '@oku-ui/use-callback-ref'
import { useCallbackRef } from './useCallbackRef'

type UseControllableRefParams<T> = {
prop?: T | undefined
Expand Down
18 changes: 18 additions & 0 deletions packages/core/use-composable/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { Options } from 'tsup'

import pkg from './package.json'

const external = [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
]

export default <Options>{
entryPoints: ['src/index.ts'],
outDir: 'dist',
target: 'node16',
format: ['esm', 'cjs'],
clean: true,
dts: true,
external,
}
43 changes: 0 additions & 43 deletions packages/core/use-controllable-ref/package.json

This file was deleted.

1 change: 0 additions & 1 deletion packages/core/use-controllable-ref/src/index.ts

This file was deleted.

9 changes: 0 additions & 9 deletions packages/core/use-controllable-ref/tsconfig.json

This file was deleted.

10 changes: 0 additions & 10 deletions packages/core/use-previous/README.md

This file was deleted.

40 changes: 0 additions & 40 deletions packages/core/use-previous/package.json

This file was deleted.

1 change: 0 additions & 1 deletion packages/core/use-previous/src/index.ts

This file was deleted.

9 changes: 0 additions & 9 deletions packages/core/use-previous/tsconfig.json

This file was deleted.

Loading