@driveflux/ui 1.0.0-next.0 → 1.0.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@driveflux/ui",
3
- "version": "1.0.0-next.0",
3
+ "version": "1.0.0-next.2",
4
4
  "type": "module",
5
- "main": "./dist/cjs/index.js",
5
+ "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
8
8
  "exports": {
@@ -30,34 +30,39 @@
30
30
  "import": "./dist/utils/index.js",
31
31
  "require": "./dist/cjs/utils/index.js",
32
32
  "types": "./dist/utils/index.d.ts"
33
+ },
34
+ "./translations": {
35
+ "import": "./dist/translations.js",
36
+ "require": "./dist/cjs/translations.js",
37
+ "types": "./dist/translations.d.ts"
33
38
  }
34
39
  },
35
40
  "dependencies": {
36
41
  "@chakra-ui/react": "^2.8.2",
37
- "lodash": "^4.17.21",
38
- "@driveflux/icons": "1.0.0-next.0"
42
+ "@driveflux/icons": "1.0.0-next.2",
43
+ "lodash": "^4.17.21"
39
44
  },
40
45
  "peerDependencies": {
41
- "next": "^14.0.3",
46
+ "next": "14.1.0",
42
47
  "react": "18.2.0",
43
48
  "swr": "^2.2.4"
44
49
  },
45
50
  "devDependencies": {
46
- "@lingui/macro": "^4.5.0",
51
+ "@driveflux/eslint-config": "1.0.0-next.2",
52
+ "@driveflux/fab": "1.0.0-next.2",
53
+ "@driveflux/problem": "4.0.0-next.2",
54
+ "@driveflux/result": "4.0.0-next.2",
55
+ "@driveflux/tsconfig": "1.0.0-next.2",
56
+ "@lingui/macro": "^4.7.0",
57
+ "@swc/cli": "^0.3.9",
58
+ "@swc/core": "^1.4.0",
47
59
  "@types/lodash": "^4.14.202",
48
- "@types/node": "^20.9.1",
49
- "@types/react": "^18.2.0",
50
- "@swc/cli": "^0.1.63",
51
- "@swc/core": "^1.3.99",
60
+ "@types/node": "^20.11.16",
61
+ "@types/react": "^18.2.55",
52
62
  "del-cli": "^5.1.0",
53
- "eslint": "8.54.0",
54
- "type-fest": "^4.8.2",
55
- "typescript": "^5.2.2",
56
- "@driveflux/eslint-config": "1.0.0-next.0",
57
- "@driveflux/tsconfig": "1.0.0-next.0",
58
- "@driveflux/problem": "4.0.0-next.0",
59
- "@driveflux/result": "4.0.0-next.0",
60
- "@driveflux/fab": "1.0.0-next.0"
63
+ "eslint": "8.56.0",
64
+ "type-fest": "^4.10.2",
65
+ "typescript": "^5.3.3"
61
66
  },
62
67
  "scripts": {
63
68
  "build": "fab",
package/src/index.ts CHANGED
@@ -1 +1,3 @@
1
+ // Turbopack has a bug that's not allowing export * from './chakra.js' to work
1
2
  export * from './chakra.js'
3
+
@@ -1,7 +1,7 @@
1
- import { Trans } from '@lingui/macro'
2
1
  import { FC, ReactNode } from 'react'
3
2
  import { Button, ButtonProps, Stack, StackProps } from '../../chakra.js'
4
3
  import { colors } from '../../theme/colors.js'
4
+ import { translations } from '../../translations.js'
5
5
  import { useEnhancedModal } from '../use-enhanced-modal.js'
6
6
 
7
7
  type Props = {
@@ -36,10 +36,10 @@ const EnhancedModalFooter: FC<Props> = ({ sticky, cancelProps, okProps, children
36
36
  ) : (
37
37
  <Stack direction={{ base: 'column-reverse', md: 'row' }} spacing={'24px'}>
38
38
  <Button w={'full'} variant={'outline'} onClick={() => close()} {...cancelProps} fontSize={'10px'} fontWeight={'bold'} letterSpacing={'3px'}>
39
- {cancelProps?.children ? cancelProps.children : <Trans>Cancel</Trans>}
39
+ {cancelProps?.children ? cancelProps.children : translations.cancel}
40
40
  </Button>
41
41
  <Button w={'full'} {...okProps} fontSize={'10px'} fontWeight={'bold'} letterSpacing={'3px'}>
42
- {okProps?.children ? okProps.children : <Trans>Confirm</Trans>}
42
+ {okProps?.children ? okProps.children : translations.confirm}
43
43
  </Button>
44
44
  </Stack>
45
45
  )}
@@ -1,4 +1,3 @@
1
- import { t } from '@lingui/macro'
2
1
  import { useCallback, useState, type FC } from 'react'
3
2
  import {
4
3
  Button,
@@ -8,6 +7,7 @@ import {
8
7
  ModalFooter,
9
8
  ModalHeader
10
9
  } from '../../chakra.js'
10
+ import { translations } from '../../translations.js'
11
11
  import { isReactNode } from '../../utils/react.js'
12
12
  import type { ModalContentConfig, ModalControlProps } from '../context.js'
13
13
  import { useEnhancedModal } from '../use-enhanced-modal.js'
@@ -51,9 +51,9 @@ const StandardModalContent: FC<Props> = ({ controls: { open, close }, modalConte
51
51
  </ModalBody>
52
52
  <ModalFooter>
53
53
  <HStack w={'full'} spacing={'6'}>
54
- <Button isDisabled={isSaving} w={'full'} variant={'outline'} onClick={handleCancel}>{modalContentConfig.cancelText || t`Close`}</Button>
54
+ <Button isDisabled={isSaving} w={'full'} variant={'outline'} onClick={handleCancel}>{modalContentConfig.cancelText || translations.close}</Button>
55
55
  <Button isDisabled={modalContentConfig.isOkDisabled} isLoading={isSaving || modalContentConfig.isOkLoading} w={'full'} variant={'solid'} onClick={handleOK} colorScheme={modalContentConfig.okColorScheme}>
56
- {modalContentConfig.okText || t`Ok`}
56
+ {modalContentConfig.okText || translations.ok}
57
57
  </Button>
58
58
  </HStack>
59
59
  </ModalFooter>
@@ -1,6 +1,5 @@
1
1
  import type { Problem, ValidationIssues } from '@driveflux/problem'
2
2
  import type { StandardResult } from '@driveflux/result'
3
- import { t } from '@lingui/macro'
4
3
  import merge from 'lodash/merge.js'
5
4
  import { useCallback } from 'react'
6
5
  import {
@@ -13,6 +12,7 @@ import {
13
12
  type ToastId,
14
13
  type UseToastOptions
15
14
  } from '../chakra.js'
15
+ import { translations } from '../translations.js'
16
16
  import { accessReactNode, type ReactNodeAccessor } from '../utils/accessors.js'
17
17
 
18
18
  export type StatusFn<T> = (data?: T) => UseToastOptions['status']
@@ -52,14 +52,14 @@ type UseToastResult = {
52
52
  const defaultUseToastResultOptions = {
53
53
  success: {
54
54
  status: 'success',
55
- title: t`Success`,
56
- description: t`The operation was done successfully`,
55
+ title: translations.success,
56
+ description: translations.successDescription,
57
57
  isClosable: true
58
58
  },
59
59
  error: {
60
60
  status: 'error',
61
- title: t`Operation Failed`,
62
- defaultDescription: t`There was a problem while performing this operation`,
61
+ title: translations.failed,
62
+ defaultDescription: translations.failedDescription,
63
63
  showValidationErrors: true,
64
64
  isClosable: true
65
65
  }
@@ -0,0 +1,23 @@
1
+ type Translations = typeof translations
2
+
3
+ export const translations = {
4
+ success: 'Success',
5
+ successDescription: 'Operation completed successfully.',
6
+ failed: 'Operation Failed',
7
+ failedDescription: 'There was a problem while performing this operation.',
8
+ cancel: 'Cancel',
9
+ confirm: 'Confirm',
10
+ close: 'Close',
11
+ ok: 'Ok'
12
+ }
13
+
14
+ export const setTranslations = (ts: Partial<Translations>) => {
15
+ for (const key in ts) {
16
+ // @ts-expect-error
17
+ translations[key] = ts[key as keyof Translations]!
18
+ }
19
+ }
20
+
21
+ export const setTranslation = <K extends keyof Translations>(key: K, value: Translations[K]) => {
22
+ translations[key] = value
23
+ }
@@ -1,19 +1,19 @@
1
- import { default as React, isValidElement } from 'react'
1
+ import { isValidElement, type ComponentType, type ReactElement, type ReactNode } from 'react'
2
2
 
3
- export function isReactComponent(Component: any): Component is React.ComponentType<any> {
3
+ export function isReactComponent(Component: any): Component is ComponentType<any> {
4
4
  return (
5
5
  typeof Component === 'function' &&
6
6
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- React component, it's fine
7
- (Component.prototype instanceof React.Component || Component.displayName !== undefined)
7
+ (Component.prototype instanceof Component || Component.displayName !== undefined)
8
8
  )
9
9
  }
10
10
 
11
- export function isReactElement(element: any): element is React.ReactElement {
11
+ export function isReactElement(element: any): element is ReactElement {
12
12
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- isValidElement is a validation function
13
13
  return isValidElement(element)
14
14
  }
15
15
 
16
- export function isReactNode(node: any): node is React.ReactNode {
16
+ export function isReactNode(node: any): node is ReactNode {
17
17
  if (
18
18
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- isValidElement is a validation function
19
19
  isValidElement(node) || // Check if it's a React element
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/cjs/translations.js')
@@ -0,0 +1 @@
1
+ export * from './dist/translations'