Skip to content

Commit

Permalink
refactor(types): Replace export namespace with export module
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianWendelborn and carsoli committed Jan 15, 2024
1 parent 0ffc372 commit fb1f367
Show file tree
Hide file tree
Showing 40 changed files with 91 additions and 91 deletions.
2 changes: 1 addition & 1 deletion packages/kotti-ui/source/kotti-accordion/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { yocoIconSchema } from '@3yourmind/yoco'
import { z } from 'zod'

export namespace KottiAccordion {
export module KottiAccordion {
export const propsSchema = z.object({
dataTest: z.string().optional(),
icon: yocoIconSchema.nullable().default(null),
Expand Down
2 changes: 1 addition & 1 deletion packages/kotti-ui/source/kotti-avatar-group/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { z } from 'zod'
import { KottiAvatar } from '../kotti-avatar/types'
import { refinementNonEmpty } from '../zod-refinements'

export namespace KottiAvatarGroup {
export module KottiAvatarGroup {
/**
* same type of name and src but they are required keys on the item object schema;
* removeDefault: removes the default value &
Expand Down
2 changes: 1 addition & 1 deletion packages/kotti-ui/source/kotti-avatar/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { z } from 'zod'

export namespace KottiAvatar {
export module KottiAvatar {
export enum Size {
LARGE = 'lg',
MEDIUM = 'md',
Expand Down
2 changes: 1 addition & 1 deletion packages/kotti-ui/source/kotti-banner/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Yoco, yocoIconSchema } from '@3yourmind/yoco'
import { z } from 'zod'

export namespace KottiBanner {
export module KottiBanner {
export const propsSchema = z.object({
actionText: z.string().nullable().default(null),
expandCloseLabel: z.string().nullable().default(null),
Expand Down
2 changes: 1 addition & 1 deletion packages/kotti-ui/source/kotti-breadcrumb/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Yoco, yocoIconSchema } from '@3yourmind/yoco'
import { z } from 'zod'

export namespace KottiBreadcrumb {
export module KottiBreadcrumb {
export enum SeparatorType {
ICON = 'icon',
TEXT = 'text',
Expand Down
2 changes: 1 addition & 1 deletion packages/kotti-ui/source/kotti-button-group/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SpecifyRequiredProps } from '../types/utilities'

export namespace KottiButtonGroup {
export module KottiButtonGroup {
export type PropsInternal = Record<string, never>

export type Props = SpecifyRequiredProps<PropsInternal, never>
Expand Down
2 changes: 1 addition & 1 deletion packages/kotti-ui/source/kotti-button/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { yocoIconSchema } from '@3yourmind/yoco'
import { z } from 'zod'

export namespace KottiButton {
export module KottiButton {
export enum Type {
DANGER = 'danger',
DEFAULT = 'default',
Expand Down
2 changes: 1 addition & 1 deletion packages/kotti-ui/source/kotti-card/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { z } from 'zod'

export namespace KottiCard {
export module KottiCard {
export enum ImagePosition {
BOTTOM = 'bottom',
MIDDLE = 'middle',
Expand Down
2 changes: 1 addition & 1 deletion packages/kotti-ui/source/kotti-col/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type MediaQueryProps = {
[KEY in 'lg' | 'md' | 'sm' | 'xl' | 'xs']: UpTo24 | null
}

export namespace KottiCol {
export module KottiCol {
export type PropsInternal = {
offset: UpTo24 | null
pull: UpTo24 | null
Expand Down
18 changes: 9 additions & 9 deletions packages/kotti-ui/source/kotti-comment/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { defaultParser, defaultPostEscapeParser } from './utilities'

const idSchema = z.union([z.number(), z.string()])

export namespace KottiComment {
export module KottiComment {
export const userSchema = z.object({
avatar: z.string().optional(),
id: idSchema,
Expand Down Expand Up @@ -34,7 +34,7 @@ export namespace KottiComment {
userAvatar: userSchema.shape.avatar,
})

export namespace Reply {
export module Reply {
export const schema = commentSchema
export type Props = z.input<typeof schema>
export type PropsInternal = z.output<typeof schema>
Expand All @@ -47,7 +47,7 @@ export namespace KottiComment {
export type Props = z.input<typeof propsSchema>
export type PropsInternal = z.output<typeof propsSchema>

export namespace Entry {
export module Entry {
export const schema = sharedSchema.omit({ userAvatar: true }).extend({
dataTest: z.string(),
isReply: z.boolean().default(false),
Expand All @@ -56,7 +56,7 @@ export namespace KottiComment {
export type PropsInternal = z.output<typeof schema>
}

export namespace Actions {
export module Actions {
export const schema = sharedSchema
.pick({
isDeletable: true,
Expand All @@ -72,7 +72,7 @@ export namespace KottiComment {
export type PropsInternal = z.output<typeof schema>
}

export namespace Header {
export module Header {
export const schema = commentSchema
.pick({
createdAt: true,
Expand All @@ -88,7 +88,7 @@ export namespace KottiComment {
export type PropsInternal = z.output<typeof schema>
}

export namespace InlineEdit {
export module InlineEdit {
export const schema = sharedSchema
.pick({
allowInternal: true,
Expand All @@ -112,7 +112,7 @@ export namespace KottiComment {
export type PropsInternal = z.output<typeof schema>
}

export namespace TextArea {
export module TextArea {
export const schema = InlineEdit.schema
.pick({
allowInternal: true,
Expand All @@ -129,7 +129,7 @@ export namespace KottiComment {
export type PropsInternal = z.output<typeof schema>
}

export namespace Events {
export module Events {
export type Add = {
isInternal?: PropsInternal['isInternal']
message: PropsInternal['message']
Expand Down Expand Up @@ -165,7 +165,7 @@ export namespace KottiComment {
}
}

export namespace KottiCommentInput {
export module KottiCommentInput {
export const propsSchema = KottiComment.propsSchema
.pick({
allowInternal: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/kotti-ui/source/kotti-drawer/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { z } from 'zod'

export namespace KottiDrawer {
export module KottiDrawer {
export const propsSchema = z.object({
defaultWidth: z.string().nullable().default(null),
disallowCloseOutside: z.boolean().default(false),
Expand Down
2 changes: 1 addition & 1 deletion packages/kotti-ui/source/kotti-field-currency/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { z } from 'zod'

import { KottiField } from '../kotti-field/types'

export namespace KottiFieldCurrency {
export module KottiFieldCurrency {
const VALUE_PROP_REGEX = /^-?(0?|([1-9][0-9]*))?(\.[0-9]+)?$/
export const valueSchema = z.string().regex(VALUE_PROP_REGEX).nullable()
export type Value = z.output<typeof valueSchema>
Expand Down
10 changes: 5 additions & 5 deletions packages/kotti-ui/source/kotti-field-date/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { KottiField } from '../kotti-field/types'

import { DATE_FORMAT_REGEX, DATE_TIME_FORMAT_REGEX } from './constants'

export namespace Shared {
export module Shared {
export const dateShortcutSchema = z.object({
keepOpen: z.boolean().optional(),
label: z.string(),
Expand Down Expand Up @@ -38,7 +38,7 @@ export namespace Shared {
export type PropsInternal = z.output<typeof propsSchema>
}

export namespace KottiFieldDate {
export module KottiFieldDate {
export const valueSchema = z.string().regex(DATE_FORMAT_REGEX).nullable()
export type Value = z.output<typeof valueSchema>

Expand All @@ -58,7 +58,7 @@ export namespace KottiFieldDate {
export type PropsInternal = z.output<typeof propsSchema>
}

export namespace KottiFieldDateRange {
export module KottiFieldDateRange {
export const valueSchema = z.tuple([
z.string().regex(DATE_FORMAT_REGEX).nullable(),
z.string().regex(DATE_FORMAT_REGEX).nullable(),
Expand Down Expand Up @@ -86,7 +86,7 @@ export namespace KottiFieldDateRange {
export type PropsInternal = z.output<typeof propsSchema>
}

export namespace KottiFieldDateTime {
export module KottiFieldDateTime {
export const valueSchema = z.string().regex(DATE_TIME_FORMAT_REGEX).nullable()
export type Value = z.output<typeof valueSchema>

Expand All @@ -106,7 +106,7 @@ export namespace KottiFieldDateTime {
export type PropsInternal = z.output<typeof propsSchema>
}

export namespace KottiFieldDateTimeRange {
export module KottiFieldDateTimeRange {
export const valueSchema = z.tuple([
z.string().regex(DATE_TIME_FORMAT_REGEX).nullable(),
z.string().regex(DATE_TIME_FORMAT_REGEX).nullable(),
Expand Down
28 changes: 14 additions & 14 deletions packages/kotti-ui/source/kotti-field-file-upload/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { z } from 'zod'

import { KottiField } from '../kotti-field/types'

export namespace Shared {
export module Shared {
export enum Validation {
INVALID_EXTENSION = 'INVALID_EXTENSION',
MAX_SIZE_EXCEEDED = 'MAX_SIZE_EXCEEDED',
Expand Down Expand Up @@ -65,13 +65,13 @@ export namespace Shared {
maxFileSize: z.number().int().min(0).default(Number.MAX_SAFE_INTEGER),
})

export namespace Events {
export module Events {
export type AddFiles = Array<File>

export type RemoveFile = z.infer<typeof idSchema>
}

export namespace ActionButton {
export module ActionButton {
export const schema = propsSchema
.pick({
isDisabled: true,
Expand All @@ -82,7 +82,7 @@ export namespace Shared {
export type Props = z.output<typeof schema>
}

export namespace DropArea {
export module DropArea {
export const schema = propsSchema
.pick({
allowMultiple: true,
Expand All @@ -103,7 +103,7 @@ export namespace Shared {
export type Props = z.output<typeof schema>
}

export namespace FileItem {
export module FileItem {
export const schema = propsSchema.pick({
dataTest: true,
extensions: true,
Expand All @@ -112,7 +112,7 @@ export namespace Shared {
})
}

export namespace TakePhoto {
export module TakePhoto {
export const schema = propsSchema.pick({
dataTest: true,
isDisabled: true,
Expand All @@ -135,7 +135,7 @@ export namespace Shared {
})
export type ErrorProps = z.output<typeof errorSchema>

export namespace Events {
export module Events {
export type Capture = {
file: File
photoUrl: string
Expand Down Expand Up @@ -191,7 +191,7 @@ export namespace Shared {
}
}

export namespace KottiFieldFileUpload {
export module KottiFieldFileUpload {
export enum Status {
INVALID = 'INVALID',
NOT_STARTED = 'NOT_STARTED',
Expand Down Expand Up @@ -228,22 +228,22 @@ export namespace KottiFieldFileUpload {
export type Props = z.input<typeof propsSchema>
export type PropsInternal = z.output<typeof propsSchema>

export namespace Events {
export module Events {
export type SetStatus = {
id: z.infer<typeof Shared.idSchema>
status: Status
}
}

export namespace FileItem {
export const schema = Shared.propsSchema.extend({
export module FileItem {
fileInfo: fileInfoSchema,
})
export type Props = z.output<typeof schema>
}
}

export namespace KottiFieldFileUploadRemote {
export module KottiFieldFileUploadRemote {
export enum Status {
CANCELED = 'CANCELED',
ERROR = 'ERROR',
Expand Down Expand Up @@ -310,22 +310,22 @@ export namespace KottiFieldFileUploadRemote {
export type Props = z.input<typeof propsSchema>
export type PropsInternal = z.output<typeof propsSchema>

export namespace Events {
export module Events {
export type SetStatus = {
id: z.infer<typeof Shared.idSchema>
status: Status
}
}

export namespace FileItem {
export module FileItem {
export const schema = Shared.propsSchema.extend({
actions: actionsSchema,
fileInfo: fileInfoSchema,
})
export type Props = z.output<typeof schema>
}

export namespace ProgressBar {
export module ProgressBar {
export const schema = payloadEntrySchema
.pick({
progress: true,
Expand Down
4 changes: 2 additions & 2 deletions packages/kotti-ui/source/kotti-field-inline-edit/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { z } from 'zod'

import { KottiField } from '../kotti-field/types'

export namespace KottiFieldInlineEdit {
export module KottiFieldInlineEdit {
export const valueSchema = z.string().nullable()
export type Value = z.output<typeof valueSchema>

Expand Down Expand Up @@ -33,7 +33,7 @@ export namespace KottiFieldInlineEdit {
export type Props = z.input<typeof propsSchema>
export type PropsInternal = z.output<typeof propsSchema>

export namespace Events {
export module Events {
export type Confirm = KottiFieldInlineEdit.Value
}

Expand Down
2 changes: 1 addition & 1 deletion packages/kotti-ui/source/kotti-field-number/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { z } from 'zod'

import { KottiField } from '../kotti-field/types'

export namespace KottiFieldNumber {
export module KottiFieldNumber {
export const valueSchema = z.number().nullable()
export type Value = z.output<typeof valueSchema>

Expand Down
2 changes: 1 addition & 1 deletion packages/kotti-ui/source/kotti-field-password/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { z } from 'zod'

import { KottiField } from '../kotti-field/types'

export namespace KottiFieldPassword {
export module KottiFieldPassword {
export const valueSchema = z.string().nullable()
export type Value = z.output<typeof valueSchema>

Expand Down
2 changes: 1 addition & 1 deletion packages/kotti-ui/source/kotti-field-radio-group/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { z } from 'zod'
import { KottiField } from '../kotti-field/types'
import { refinementNonEmpty } from '../zod-refinements'

export namespace KottiFieldRadioGroup {
export module KottiFieldRadioGroup {
export const valueSchema = z
.union([z.string(), z.number(), z.boolean()])
.nullable()
Expand Down
Loading

0 comments on commit fb1f367

Please sign in to comment.