chore: rename utils package to shared
This commit is contained in:
@@ -9,7 +9,7 @@ const config = {
|
||||
reactStrictMode: true,
|
||||
|
||||
/** Enables hot reloading for local packages without a build step */
|
||||
transpilePackages: ["@kan/api", "@kan/db", "@kan/utils"],
|
||||
transpilePackages: ["@kan/api", "@kan/db", "@kan/shared"],
|
||||
|
||||
/** We already do linting and typechecking as separate tasks in CI */
|
||||
eslint: { ignoreDuringBuilds: true },
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
"@hookform/resolvers": "^3.3.4",
|
||||
"@kan/api": "workspace:*",
|
||||
"@kan/db": "workspace:^",
|
||||
"@kan/shared": "workspace:^",
|
||||
"@kan/supabase": "workspace:^",
|
||||
"@kan/utils": "workspace:^",
|
||||
"@t3-oss/env-nextjs": "^0.11.1",
|
||||
"@tanstack/react-query": "catalog:",
|
||||
"@trpc/client": "catalog:",
|
||||
|
||||
@@ -8,7 +8,7 @@ import type {
|
||||
ReorderCardInput,
|
||||
ReorderListInput,
|
||||
} from "@kan/api/types";
|
||||
import { generateUID } from "@kan/utils";
|
||||
import { generateUID } from "@kan/shared/utils";
|
||||
|
||||
import { usePopup } from "~/providers/popup";
|
||||
import { api } from "~/utils/api";
|
||||
|
||||
@@ -1,36 +1,26 @@
|
||||
import { Fragment } from "react";
|
||||
import { HiChevronUpDown, HiXMark } from "react-icons/hi2";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { Listbox, Transition } from "@headlessui/react";
|
||||
import { Fragment } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { HiChevronUpDown, HiXMark } from "react-icons/hi2";
|
||||
|
||||
import { api } from "~/utils/api";
|
||||
import { useModal } from "~/providers/modal";
|
||||
import { colours } from "@kan/shared/constants";
|
||||
|
||||
import Button from "~/components/Button";
|
||||
import Input from "~/components/Input";
|
||||
import Toggle from "~/components/Toggle";
|
||||
import { useModal } from "~/providers/modal";
|
||||
import { api } from "~/utils/api";
|
||||
|
||||
type LabelFormInput = {
|
||||
interface LabelFormInput {
|
||||
name: string;
|
||||
colour: Colour;
|
||||
isCreateAnotherEnabled?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
type Colour = {
|
||||
interface Colour {
|
||||
name: string;
|
||||
code: string;
|
||||
};
|
||||
|
||||
const colours = [
|
||||
{ name: "Teal", code: "#0d9488" },
|
||||
{ name: "Green", code: "#65a30d" },
|
||||
{ name: "Blue", code: "#0284c7" },
|
||||
{ name: "Purple", code: "#4f46e5" },
|
||||
{ name: "Yellow", code: "#ca8a04" },
|
||||
{ name: "Orange", code: "#ea580c" },
|
||||
{ name: "Red", code: "#dc2626" },
|
||||
{ name: "Pink", code: "#db2777" },
|
||||
];
|
||||
}
|
||||
|
||||
export function LabelForm({
|
||||
cardPublicId,
|
||||
@@ -54,9 +44,9 @@ export function LabelForm({
|
||||
const { control, register, reset, handleSubmit, setValue, watch } =
|
||||
useForm<LabelFormInput>({
|
||||
values: {
|
||||
name: isEdit && label?.data?.name ? label?.data?.name : "",
|
||||
colour: (isEdit && label?.data?.colourCode
|
||||
? colours.find((c) => c.code === label?.data?.colourCode)
|
||||
name: isEdit && label.data?.name ? label.data.name : "",
|
||||
colour: (isEdit && label.data?.colourCode
|
||||
? colours.find((c) => c.code === label.data?.colourCode)
|
||||
: colours[0]) as Colour,
|
||||
isCreateAnotherEnabled: false,
|
||||
},
|
||||
@@ -97,7 +87,7 @@ export function LabelForm({
|
||||
});
|
||||
|
||||
const onSubmit = (values: LabelFormInput) => {
|
||||
if (!values.colour?.code) return;
|
||||
if (!values.colour.code) return;
|
||||
|
||||
if (isEdit) {
|
||||
updateLabel.mutate({
|
||||
@@ -144,11 +134,11 @@ export function LabelForm({
|
||||
<Listbox.Button className="block w-full rounded-md border-0 bg-white/5 px-4 py-1.5 shadow-sm ring-1 ring-inset ring-light-600 focus:ring-2 focus:ring-inset focus:ring-light-600 dark:bg-dark-300 dark:text-dark-1000 dark:ring-dark-700 dark:focus:ring-dark-700 sm:text-sm sm:leading-6">
|
||||
<span className="flex items-center">
|
||||
<span
|
||||
style={{ backgroundColor: field.value?.code }}
|
||||
style={{ backgroundColor: field.value.code }}
|
||||
className={`inline-block h-2 w-2 flex-shrink-0 rounded-full`}
|
||||
/>
|
||||
<span className="ml-3 block truncate">
|
||||
{field.value?.name}
|
||||
{field.value.name}
|
||||
</span>
|
||||
</span>
|
||||
<span className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2">
|
||||
@@ -170,7 +160,7 @@ export function LabelForm({
|
||||
{colours.map((colour, index) => (
|
||||
<Listbox.Option
|
||||
key={`colours_${index}`}
|
||||
className="relative cursor-default select-none px-2 text-neutral-900 dark:text-dark-1000 "
|
||||
className="relative cursor-default select-none px-2 text-neutral-900 dark:text-dark-1000"
|
||||
value={colour}
|
||||
>
|
||||
{() => (
|
||||
|
||||
@@ -37,8 +37,8 @@
|
||||
"dependencies": {
|
||||
"@kan/db": "workspace:*",
|
||||
"@kan/email": "workspace:^",
|
||||
"@kan/shared": "workspace:^",
|
||||
"@kan/supabase": "workspace:^",
|
||||
"@kan/utils": "workspace:^",
|
||||
"@trpc/server": "catalog:",
|
||||
"superjson": "2.2.1",
|
||||
"trpc-to-openapi": "^2.1.0",
|
||||
|
||||
@@ -6,7 +6,7 @@ import * as cardRepo from "@kan/db/repository/card.repo";
|
||||
import * as activityRepo from "@kan/db/repository/cardActivity.repo";
|
||||
import * as listRepo from "@kan/db/repository/list.repo";
|
||||
import * as workspaceRepo from "@kan/db/repository/workspace.repo";
|
||||
import { generateSlug, generateUID } from "@kan/utils";
|
||||
import { generateSlug, generateUID } from "@kan/shared/utils";
|
||||
|
||||
import { createTRPCRouter, protectedProcedure, publicProcedure } from "../trpc";
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { z } from "zod";
|
||||
|
||||
import * as workspaceRepo from "@kan/db/repository/workspace.repo";
|
||||
import * as workspaceSlugRepo from "@kan/db/repository/workspaceSlug.repo";
|
||||
import { generateUID } from "@kan/utils";
|
||||
import { generateUID } from "@kan/shared/utils";
|
||||
|
||||
import { createTRPCRouter, protectedProcedure, publicProcedure } from "../trpc";
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
"with-env": "dotenv -e ../../.env --"
|
||||
},
|
||||
"dependencies": {
|
||||
"@kan/utils": "workspace:^",
|
||||
"@kan/shared": "workspace:^",
|
||||
"@vercel/postgres": "^0.10.0",
|
||||
"drizzle-orm": "^0.36.4",
|
||||
"drizzle-zod": "^0.5.1",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { SupabaseClient } from "@supabase/supabase-js";
|
||||
|
||||
import type { Database } from "@kan/db/types/database.types";
|
||||
import { generateUID } from "@kan/utils";
|
||||
import { generateUID } from "@kan/shared/utils";
|
||||
|
||||
export const getAllByWorkspaceId = async (
|
||||
db: SupabaseClient<Database>,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { SupabaseClient } from "@supabase/supabase-js";
|
||||
|
||||
import type { Database } from "@kan/db/types/database.types";
|
||||
import { generateUID } from "@kan/utils";
|
||||
import { generateUID } from "@kan/shared/utils";
|
||||
|
||||
export const create = async (
|
||||
db: SupabaseClient<Database>,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { SupabaseClient } from "@supabase/supabase-js";
|
||||
|
||||
import type { Database } from "@kan/db/types/database.types";
|
||||
import { generateUID } from "@kan/utils";
|
||||
import { generateUID } from "@kan/shared/utils";
|
||||
|
||||
export const create = async (
|
||||
db: SupabaseClient<Database>,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { SupabaseClient } from "@supabase/supabase-js";
|
||||
|
||||
import type { Database } from "@kan/db/types/database.types";
|
||||
import { generateUID } from "@kan/utils";
|
||||
import { generateUID } from "@kan/shared/utils";
|
||||
|
||||
export const create = async (
|
||||
db: SupabaseClient<Database>,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { SupabaseClient } from "@supabase/supabase-js";
|
||||
|
||||
import type { Database } from "@kan/db/types/database.types";
|
||||
import { generateUID } from "@kan/utils";
|
||||
import { generateUID } from "@kan/shared/utils";
|
||||
|
||||
export const create = async (
|
||||
db: SupabaseClient<Database>,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { SupabaseClient } from "@supabase/supabase-js";
|
||||
|
||||
import type { Database } from "@kan/db/types/database.types";
|
||||
import { generateUID } from "@kan/utils";
|
||||
import { generateUID } from "@kan/shared/utils";
|
||||
|
||||
export const create = async (
|
||||
db: SupabaseClient<Database>,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { SupabaseClient } from "@supabase/supabase-js";
|
||||
|
||||
import type { Database } from "@kan/db/types/database.types";
|
||||
import { generateUID } from "@kan/utils";
|
||||
import { generateUID } from "@kan/shared/utils";
|
||||
|
||||
export const create = async (
|
||||
db: SupabaseClient<Database>,
|
||||
|
||||
@@ -1,10 +1,21 @@
|
||||
{
|
||||
"name": "@kan/utils",
|
||||
"name": "@kan/shared",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": "./src/index.ts"
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"./utils": {
|
||||
"types": "./dist/utils/index.d.ts",
|
||||
"default": "./dist/utils/index.js"
|
||||
},
|
||||
"./constants": {
|
||||
"types": "./dist/constants/index.d.ts",
|
||||
"default": "./dist/constants/index.js"
|
||||
}
|
||||
},
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
12
packages/shared/src/constants/colours.ts
Normal file
12
packages/shared/src/constants/colours.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
export const colours: { name: string; code: string }[] = [
|
||||
{ name: "Teal", code: "#0d9488" },
|
||||
{ name: "Green", code: "#65a30d" },
|
||||
{ name: "Blue", code: "#0284c7" },
|
||||
{ name: "Purple", code: "#4f46e5" },
|
||||
{ name: "Yellow", code: "#ca8a04" },
|
||||
{ name: "Orange", code: "#ea580c" },
|
||||
{ name: "Red", code: "#dc2626" },
|
||||
{ name: "Pink", code: "#db2777" },
|
||||
] as const;
|
||||
|
||||
export type Colour = (typeof colours)[number];
|
||||
1
packages/shared/src/constants/index.ts
Normal file
1
packages/shared/src/constants/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./colours";
|
||||
4
packages/shared/src/index.ts
Normal file
4
packages/shared/src/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export const name = "shared";
|
||||
|
||||
export * from "./constants";
|
||||
export * from "./utils";
|
||||
2
packages/shared/src/utils/index.ts
Normal file
2
packages/shared/src/utils/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./generateUID";
|
||||
export * from "./generateSlug";
|
||||
@@ -1,4 +0,0 @@
|
||||
export const name = "utils";
|
||||
|
||||
export { generateUID } from "./generateUID";
|
||||
export { generateSlug } from "./generateSlug";
|
||||
66
pnpm-lock.yaml
generated
66
pnpm-lock.yaml
generated
@@ -87,12 +87,12 @@ importers:
|
||||
'@kan/db':
|
||||
specifier: workspace:^
|
||||
version: link:../../packages/db
|
||||
'@kan/shared':
|
||||
specifier: workspace:^
|
||||
version: link:../../packages/shared
|
||||
'@kan/supabase':
|
||||
specifier: workspace:^
|
||||
version: link:../../packages/supabase
|
||||
'@kan/utils':
|
||||
specifier: workspace:^
|
||||
version: link:../../packages/utils
|
||||
'@t3-oss/env-nextjs':
|
||||
specifier: ^0.11.1
|
||||
version: 0.11.1(typescript@5.7.2)(zod@3.24.0)
|
||||
@@ -214,12 +214,12 @@ importers:
|
||||
'@kan/email':
|
||||
specifier: workspace:^
|
||||
version: link:../email
|
||||
'@kan/shared':
|
||||
specifier: workspace:^
|
||||
version: link:../shared
|
||||
'@kan/supabase':
|
||||
specifier: workspace:^
|
||||
version: link:../supabase
|
||||
'@kan/utils':
|
||||
specifier: workspace:^
|
||||
version: link:../utils
|
||||
'@trpc/server':
|
||||
specifier: 'catalog:'
|
||||
version: 11.0.0-rc.660(typescript@5.7.2)
|
||||
@@ -254,9 +254,9 @@ importers:
|
||||
|
||||
packages/db:
|
||||
dependencies:
|
||||
'@kan/utils':
|
||||
'@kan/shared':
|
||||
specifier: workspace:^
|
||||
version: link:../utils
|
||||
version: link:../shared
|
||||
'@vercel/postgres':
|
||||
specifier: ^0.10.0
|
||||
version: 0.10.0(utf-8-validate@6.0.3)
|
||||
@@ -323,6 +323,31 @@ importers:
|
||||
specifier: 'catalog:'
|
||||
version: 5.7.2
|
||||
|
||||
packages/shared:
|
||||
dependencies:
|
||||
nanoid:
|
||||
specifier: ^5.0.9
|
||||
version: 5.0.9
|
||||
devDependencies:
|
||||
'@kan/eslint-config':
|
||||
specifier: workspace:*
|
||||
version: link:../../tooling/eslint
|
||||
'@kan/prettier-config':
|
||||
specifier: workspace:*
|
||||
version: link:../../tooling/prettier
|
||||
'@kan/tsconfig':
|
||||
specifier: workspace:*
|
||||
version: link:../../tooling/typescript
|
||||
eslint:
|
||||
specifier: 'catalog:'
|
||||
version: 9.16.0(jiti@1.21.6)
|
||||
prettier:
|
||||
specifier: 'catalog:'
|
||||
version: 3.4.2
|
||||
typescript:
|
||||
specifier: 'catalog:'
|
||||
version: 5.7.2
|
||||
|
||||
packages/supabase:
|
||||
dependencies:
|
||||
'@edge-runtime/cookies':
|
||||
@@ -360,31 +385,6 @@ importers:
|
||||
specifier: 'catalog:'
|
||||
version: 5.7.2
|
||||
|
||||
packages/utils:
|
||||
dependencies:
|
||||
nanoid:
|
||||
specifier: ^5.0.9
|
||||
version: 5.0.9
|
||||
devDependencies:
|
||||
'@kan/eslint-config':
|
||||
specifier: workspace:*
|
||||
version: link:../../tooling/eslint
|
||||
'@kan/prettier-config':
|
||||
specifier: workspace:*
|
||||
version: link:../../tooling/prettier
|
||||
'@kan/tsconfig':
|
||||
specifier: workspace:*
|
||||
version: link:../../tooling/typescript
|
||||
eslint:
|
||||
specifier: 'catalog:'
|
||||
version: 9.16.0(jiti@1.21.6)
|
||||
prettier:
|
||||
specifier: 'catalog:'
|
||||
version: 3.4.2
|
||||
typescript:
|
||||
specifier: 'catalog:'
|
||||
version: 5.7.2
|
||||
|
||||
tooling/eslint:
|
||||
dependencies:
|
||||
'@eslint/compat':
|
||||
|
||||
Reference in New Issue
Block a user