-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): package direction (#263)
* core package direction (#243) * fix: lint issues * fix
- Loading branch information
Showing
8 changed files
with
147 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# `@oku-ui/direction` | ||
|
||
## Installation | ||
|
||
```sh | ||
$ pnpm add @oku-ui/direction | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { defineBuildConfig } from 'unbuild' | ||
|
||
export default defineBuildConfig({ | ||
entries: [ | ||
{ | ||
builder: 'mkdist', | ||
input: './src/', | ||
pattern: ['**/!(*.test|*.stories).ts'], | ||
}, | ||
], | ||
declaration: true, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"name": "@oku-ui/direction", | ||
"type": "module", | ||
"version": "0.2.3", | ||
"license": "MIT", | ||
"source": "src/index.ts", | ||
"funding": "https://github.com/sponsors/productdevbook", | ||
"homepage": "https://oku-ui.com/primitives", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/oku-ui/primitives.git", | ||
"directory": "packages/components/direction" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/oku-ui/primitives/issues" | ||
}, | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.mjs" | ||
} | ||
}, | ||
"module": "./dist/index.mjs", | ||
"types": "./dist/index.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"engines": { | ||
"node": ">=18" | ||
}, | ||
"scripts": { | ||
"build": "tsup", | ||
"dev": "tsup --watch" | ||
}, | ||
"peerDependencies": { | ||
"vue": "^3.3.0" | ||
}, | ||
"devDependencies": { | ||
"tsconfig": "workspace:^" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { type PropType, defineComponent, inject, provide } from 'vue' | ||
|
||
type Direction = 'ltr' | 'rtl' | ||
const DirectionContextSymbol = Symbol('DirectionContext') | ||
|
||
/* ------------------------------------------------------------------------------------------------- | ||
* Direction | ||
* ----------------------------------------------------------------------------------------------- */ | ||
|
||
const DirectionProvider = defineComponent({ | ||
name: 'DirectionProvider', | ||
props: { | ||
dir: { type: String as PropType<Direction>, required: true }, | ||
}, | ||
setup(props, { slots }) { | ||
// Direction context | ||
provide(DirectionContextSymbol, props.dir) | ||
return () => slots.default?.() | ||
}, | ||
}) | ||
|
||
/* ----------------------------------------------------------------------------------------------- */ | ||
|
||
function useDirection(localDir?: Direction) { | ||
const globalDir = inject(DirectionContextSymbol, null) | ||
return localDir || globalDir || 'ltr' | ||
} | ||
|
||
const Provider = DirectionProvider | ||
|
||
export { | ||
useDirection, | ||
Provider, | ||
DirectionProvider, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export { | ||
useDirection, | ||
// | ||
Provider, | ||
// | ||
DirectionProvider, | ||
} from './Direction' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "tsconfig/node16.json", | ||
"compilerOptions": { | ||
"rootDir": "src", | ||
"outDir": "dist" | ||
}, | ||
"include": [ | ||
"src" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { defineConfig } from 'tsup' | ||
import pkg from './package.json' | ||
|
||
const external = [ | ||
...Object.keys(pkg.peerDependencies || {}), | ||
] | ||
|
||
export default defineConfig((options) => { | ||
return [ | ||
{ | ||
...options, | ||
entryPoints: ['src/index.ts'], | ||
external, | ||
dts: true, | ||
clean: true, | ||
target: 'node16', | ||
format: ['esm'], | ||
outExtension: () => ({ js: '.mjs' }), | ||
}, | ||
] | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.