letalkui 0.0.6 → 0.0.7

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,9 +1,12 @@
1
1
  {
2
2
  "name": "letalkui",
3
3
  "private": false,
4
- "version": "0.0.6",
4
+ "version": "0.0.7",
5
5
  "type": "module",
6
- "scripts": {
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "scripts": {
7
10
  "lint": "eslint .",
8
11
  "dev": "storybook dev -p 6006",
9
12
  "build": "tsup",
package/.editorconfig DELETED
@@ -1,11 +0,0 @@
1
- root = true
2
-
3
- [*]
4
- indent_style = tab
5
- indent_size = 4
6
- # LF (Line Feed) and CRLF (Carriage Return + Line Feed) are different line-ending conventions used to mark the end of a line in text files:
7
- # More information in this post: https://medium.com/@feldy7k/understanding-line-break-types-cr-lf-and-crlf-278069b8da29
8
- end_of_line = lf
9
- charset = utf-8
10
- trim_trailing_whitespace = true
11
- insert_final_newline = true
@@ -1,33 +0,0 @@
1
- on:
2
- push:
3
- branches:
4
- - master
5
-
6
- pull_request:
7
-
8
- workflow_dispatch:
9
-
10
- name: Check
11
-
12
- jobs:
13
- check:
14
- name: Check
15
- runs-on: ubuntu-latest
16
-
17
- steps:
18
- - name: Checkout
19
- uses: actions/checkout@v2
20
-
21
- - name: Setup NodeJS
22
- uses: actions/setup-node@v1
23
- with:
24
- node-version: "18.20.3"
25
-
26
- - name: Install All Dependencies
27
- run: npm i -f
28
-
29
- - name: Build
30
- env:
31
- CI: true
32
- NODE_OPTIONS: --max-old-space-size=4096
33
- run: npm run build
@@ -1,25 +0,0 @@
1
- on: pull_request
2
-
3
- name: Lint
4
-
5
- jobs:
6
- check:
7
- name: Lint
8
- runs-on: ubuntu-latest
9
- container:
10
- image: node:18.20.3
11
-
12
- steps:
13
- - name: Checkout
14
- uses: actions/checkout@v2
15
-
16
- - name: Setup NodeJS
17
- uses: actions/setup-node@v2
18
- with:
19
- node-version: "18.20.3"
20
-
21
- - name: Install packages
22
- run: npm ci
23
-
24
- - name: Check Lint
25
- run: npx eslint 'src/**'
@@ -1,27 +0,0 @@
1
- name: Release
2
-
3
- on:
4
- push:
5
- branches:
6
- - master
7
-
8
- jobs:
9
- release:
10
- runs-on: ubuntu-latest
11
- steps:
12
- - name: Checkout
13
- uses: actions/checkout@v3
14
-
15
- - name: Setup Node.js
16
- uses: actions/setup-node@v3
17
- with:
18
- node-version: "18.20.3"
19
- registry-url: 'https://registry.npmjs.org'
20
-
21
- - name: Install dependencies
22
- run: npm i -f
23
-
24
- - name: Release
25
- run: npm publish
26
- env:
27
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/.nvmrc DELETED
@@ -1 +0,0 @@
1
- 14.18.1
@@ -1,13 +0,0 @@
1
- import type { StorybookConfig } from "@storybook/react-vite";
2
-
3
- const config: StorybookConfig = {
4
- stories: ["../src/**/*.mdx", "../src/components/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
5
- addons: [
6
- "@storybook/addon-essentials"
7
- ],
8
- framework: {
9
- name: "@storybook/react-vite",
10
- options: {},
11
- },
12
- };
13
- export default config;
@@ -1,14 +0,0 @@
1
- import type { Preview } from "@storybook/react";
2
-
3
- const preview: Preview = {
4
- parameters: {
5
- controls: {
6
- matchers: {
7
- color: /(background|color)$/i,
8
- date: /Date$/i,
9
- },
10
- },
11
- },
12
- };
13
-
14
- export default preview;
package/eslint.config.js DELETED
@@ -1,68 +0,0 @@
1
- import js from "@eslint/js"
2
- import globals from "globals"
3
- import reactHooks from "eslint-plugin-react-hooks"
4
- import reactRefresh from "eslint-plugin-react-refresh"
5
- import react from "eslint-plugin-react"
6
- import typescriptEslint from "@typescript-eslint/eslint-plugin"
7
- import jsxA11Y from "eslint-plugin-jsx-a11y"
8
- import _import from "eslint-plugin-import"
9
- import tsParser from "@typescript-eslint/parser"
10
-
11
- export default [
12
- {
13
- ignores: ["dist", ".storybook", "vite.config.ts", "tsup.config.ts"],
14
- },
15
- js.configs.recommended,
16
- {
17
- files: ["**/*.{ts,tsx}"],
18
- languageOptions: {
19
- ecmaVersion: 2020,
20
- sourceType: "module",
21
- globals: {
22
- ...globals.browser,
23
- ...globals.node,
24
- ...globals.jest,
25
- },
26
- parser: tsParser,
27
- parserOptions: {
28
- project: "./tsconfig.eslint.json",
29
- ecmaFeatures: {
30
- jsx: true,
31
- },
32
- },
33
- },
34
- plugins: {
35
- "react-hooks": reactHooks,
36
- "react-refresh": reactRefresh,
37
- react,
38
- "@typescript-eslint": typescriptEslint,
39
- "jsx-a11y": jsxA11Y,
40
- import: _import,
41
- },
42
- rules: {
43
- ...reactHooks.configs.recommended.rules,
44
- "react-refresh/only-export-components": [
45
- "warn",
46
- { allowConstantExport: true },
47
- ],
48
- ...typescriptEslint.configs.recommended.rules,
49
- ...react.configs.recommended.rules,
50
- "@typescript-eslint/no-unused-vars": "error",
51
- indent: ["error", "tab"],
52
- quotes: ["error", "double"],
53
- semi: ["error", "never"],
54
- "object-curly-spacing": ["error", "always"],
55
- "comma-dangle": ["error", "never"]
56
- },
57
- settings: {
58
- "import/resolver": {
59
- typescript: {
60
- project: ["./tsconfig.json"],
61
- },
62
- },
63
- react: {
64
- version: "detect",
65
- },
66
- },
67
- },
68
- ]
package/index.html DELETED
@@ -1,13 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <title>Vite + React + TS</title>
8
- </head>
9
- <body>
10
- <div id="root"></div>
11
- <script type="module" src="/src/main.tsx"></script>
12
- </body>
13
- </html>
@@ -1,35 +0,0 @@
1
- import React from "react"
2
-
3
- import {
4
- Button,
5
- CircularProgress
6
- } from "@mui/material"
7
-
8
- type ActionButtonProps = {
9
- onSave: () => void
10
- loading: boolean
11
- }
12
-
13
- export const ActionButton: React.FC<ActionButtonProps> = (props) => {
14
- const {
15
- onSave,
16
- loading
17
- } = props
18
-
19
- const handleSave = () => {
20
- onSave()
21
- }
22
-
23
- return (
24
- <Button
25
- onClick={handleSave}
26
- color="primary"
27
- variant="contained"
28
- disableElevation
29
- disabled={loading}
30
- endIcon={loading && <CircularProgress size={20} color="inherit" />}
31
- >
32
- Salvar
33
- </Button>
34
- )
35
- }
@@ -1,23 +0,0 @@
1
- import React from "react"
2
- import {
3
- Grid2 as Grid
4
- } from "@mui/material"
5
-
6
- type ActionsButtonsProps = {
7
- children: React.ReactNode
8
- }
9
-
10
- export const ActionsButtons: React.FC<ActionsButtonsProps> = (props) => {
11
- return (
12
- <Grid
13
- container
14
- justify="flex-end"
15
- >
16
- <Grid
17
- item
18
- >
19
- {props.children}
20
- </Grid>
21
- </Grid>
22
- )
23
- }
@@ -1,67 +0,0 @@
1
- import React from "react"
2
- import AceEditor, { IAceEditorProps } from "react-ace"
3
- import {
4
- FormControl,
5
- FormHelperText,
6
- Grid2 as Grid
7
- } from "@mui/material"
8
-
9
- export type JsonValue = Record<string | number, unknown>
10
-
11
- export type Overwrite<T, NewT> = Omit<T, keyof NewT> & NewT;
12
-
13
- export type ContentProps = Overwrite<IAceEditorProps, {
14
- value?: JsonValue | null
15
- onChange?: (updatedJson: string) => void
16
- currentError?: boolean
17
- currentHelperText?: string
18
- }>
19
-
20
- const INPUT_NAME = "json-editor"
21
-
22
- export const Content: React.FC<ContentProps> = (props) => {
23
- const {
24
- value,
25
- onChange,
26
- currentError,
27
- currentHelperText,
28
- ...rest
29
- } = props
30
-
31
- const stringifyValue = JSON.stringify(value, null, 2)
32
-
33
- return (
34
- <Grid>
35
- <FormControl
36
- error={currentError}
37
- fullWidth
38
- >
39
- <AceEditor
40
- {...rest}
41
- name={INPUT_NAME}
42
- value={stringifyValue}
43
- wrapEnabled={true}
44
- mode="json"
45
- theme="textmate"
46
- onChange={onChange}
47
- fontSize={16}
48
- showPrintMargin={true}
49
- showGutter={true}
50
- highlightActiveLine={true}
51
- editorProps={{ $blockScrolling: true }}
52
- setOptions={{
53
- showLineNumbers: true,
54
- tabSize: 2
55
- }}
56
- />
57
- </FormControl>
58
- {currentHelperText && (
59
- <FormHelperText
60
- error={currentError}
61
- >
62
- {currentHelperText}
63
- </FormHelperText>
64
- )}
65
- </Grid>
66
- )
67
- }
@@ -1,21 +0,0 @@
1
- import React from "react"
2
-
3
- import {
4
- Grid2 as Grid
5
- } from "@mui/material"
6
-
7
- type RootProps = {
8
- children: React.ReactNode
9
- }
10
-
11
- export const Root: React.FC<RootProps> = (props) => {
12
- return (
13
- <Grid
14
- container
15
- direction="column"
16
- spacing={2}
17
- >
18
- {props.children}
19
- </Grid>
20
- )
21
- }
@@ -1,11 +0,0 @@
1
- import { Root } from "@/componentPatterns/JsonForm/Root"
2
- import { ActionButton } from "@/componentPatterns/JsonForm/ActionButton"
3
- import { ActionsButtons } from "@/componentPatterns/JsonForm/ActionsButtons"
4
- import { Content } from "@/componentPatterns/JsonForm/Content"
5
-
6
- export const JsonForm = {
7
- Root,
8
- ActionButton,
9
- ActionsButtons,
10
- Content
11
- }
@@ -1,53 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/react"
2
- import { fn } from "@storybook/test"
3
-
4
- import { Button } from "@/components/Button"
5
-
6
- const meta: Meta<typeof Button> = {
7
- title: "Example/Button",
8
- component: Button,
9
- parameters: {
10
- layout: "centered"
11
- },
12
- tags: ["autodocs"],
13
- argTypes: {
14
- backgroundColor: {
15
- control: "color"
16
- }
17
- },
18
- args: {
19
- onClick: fn()
20
- }
21
- }
22
-
23
- export default meta
24
-
25
- type Story = StoryObj<typeof meta>
26
-
27
- export const Primary: Story = {
28
- args: {
29
- primary: true,
30
- label: "Button",
31
- size: "large"
32
- }
33
- }
34
-
35
- export const Secondary: Story = {
36
- args: {
37
- label: "Button"
38
- }
39
- }
40
-
41
- export const Large: Story = {
42
- args: {
43
- size: "large",
44
- label: "Button"
45
- }
46
- }
47
-
48
- export const Small: Story = {
49
- args: {
50
- size: "small",
51
- label: "Button"
52
- }
53
- }
@@ -1,30 +0,0 @@
1
- import React from "react"
2
-
3
- export interface ButtonProps {
4
- primary?: boolean
5
- backgroundColor?: string
6
- size?: "small" | "medium" | "large"
7
- label: string
8
- onClick?: () => void
9
- }
10
-
11
- export const Button = (props: ButtonProps) => {
12
- const {
13
- backgroundColor,
14
- label,
15
- size,
16
- primary
17
- } = props
18
-
19
- const mode = primary ? "storybook-button--primary" : "storybook-button--secondary"
20
- return (
21
- <button
22
- type="button"
23
- className={["storybook-button", `storybook-button--${size}`, mode].join("")}
24
- style={{ backgroundColor }}
25
- {...props}
26
- >
27
- {label}
28
- </button>
29
- )
30
- }
@@ -1,47 +0,0 @@
1
- import {
2
- Meta,
3
- StoryObj
4
- } from "@storybook/react"
5
-
6
- import { JsonEditor } from "@/components/JsonEditor"
7
-
8
- const meta: Meta<typeof JsonEditor> = {
9
- title: "Example/JsonEditor",
10
- component: JsonEditor,
11
- parameters: {
12
- layout: "centered"
13
- },
14
- tags: ["autodocs"],
15
- argTypes: {
16
- value: {
17
- type: "string"
18
- }
19
- }
20
- }
21
-
22
- export default meta
23
-
24
- type Story = StoryObj<typeof meta>
25
-
26
- export const Primary: Story = {
27
- args: {
28
- value: {
29
- "id": 1,
30
- "nome": "dsadsa",
31
- "ativo": true,
32
- "dataCriacao": "2025-02-07T12:00:00.000Z",
33
-
34
- "itens": [{
35
- "id": 101,
36
- "descricao": "Item 1",
37
- "quantidade": 10,
38
- "preco": 19.99
39
- }, {
40
- "id": 102,
41
- "descricao": "Item 2",
42
- "quantidade": 5,
43
- "preco": 49.99
44
- }]
45
- }
46
- }
47
- }
@@ -1,93 +0,0 @@
1
- import React, { useState } from "react"
2
- import { IAceEditorProps } from "react-ace"
3
-
4
- import { JsonForm } from "@/componentPatterns/JsonForm"
5
- import {
6
- JsonValue,
7
- Overwrite
8
- } from "@/componentPatterns/JsonForm/Content"
9
-
10
- import useValidation from "@/hooks/useValidation"
11
-
12
- type JsonEditorProps = Overwrite<IAceEditorProps, {
13
- value?: JsonValue | null
14
- onChange?: (value: string) => void
15
- onSave?: (value: JsonValue) => Promise<JsonValue>
16
- helperText?: string
17
- error?: boolean
18
- }>
19
-
20
- const INPUT_NAME = "json-editor"
21
-
22
- export const JsonEditor: React.FC<JsonEditorProps> = (props) => {
23
- const {
24
- value,
25
- onChange,
26
- onSave,
27
- helperText,
28
- error,
29
- ...rest
30
- } = props
31
-
32
- const { addValidation, clearValidation, validation } = useValidation()
33
-
34
- const stringifyValue = JSON.stringify(value, null, 2)
35
-
36
- const [jsonData, setJsonData] = useState<string>(stringifyValue)
37
- const [loadingSaveJson, setLoadingSaveJson] = useState<boolean>(false)
38
-
39
- const currentError: boolean = Boolean(validation[INPUT_NAME]) ?? error
40
-
41
- const currentHelperText = (): string => {
42
- if (INPUT_NAME in validation) {
43
- if (helperText) return helperText
44
-
45
- return "Ocorreu um erro inesperado. Por favor, tente novamente mais tarde."
46
- }
47
-
48
- return "Ocorreu um erro inesperado. Por favor, tente novamente mais tarde."
49
- }
50
-
51
- const handleChange = (newValue: string) => {
52
- clearValidation(INPUT_NAME)
53
-
54
- setJsonData(newValue)
55
-
56
- onChange?.(newValue)
57
- }
58
-
59
- const handleSave = async () => {
60
- setLoadingSaveJson(true)
61
-
62
- if (onSave) {
63
- try {
64
- const parseJsonData = JSON.parse(jsonData)
65
-
66
- await onSave(parseJsonData)
67
- } catch (error) {
68
- addValidation({ [INPUT_NAME]: error })
69
- }
70
- }
71
-
72
- setLoadingSaveJson(false)
73
- }
74
-
75
- return (
76
- <JsonForm.Root>
77
- <JsonForm.Content
78
- {...rest}
79
- value={value}
80
- onChange={handleChange}
81
- currentError={currentError}
82
- currentHelperText={currentHelperText()}
83
- />
84
-
85
- <JsonForm.ActionsButtons>
86
- <JsonForm.ActionButton
87
- onSave={handleSave}
88
- loading={loadingSaveJson}
89
- />
90
- </JsonForm.ActionsButtons>
91
- </JsonForm.Root>
92
- )
93
- }
@@ -1,42 +0,0 @@
1
- import type {
2
- Meta,
3
- StoryObj
4
- } from "@storybook/react"
5
-
6
- import { JsonView } from "@/components/JsonView"
7
-
8
- const meta: Meta<typeof JsonView> = {
9
- title: "Example/JsonView",
10
- component: JsonView,
11
- parameters: {
12
- layout: "centered"
13
- },
14
- tags: ["autodocs"]
15
- }
16
-
17
- export default meta
18
-
19
- type Story = StoryObj<typeof meta>
20
-
21
- export const Primary: Story = {
22
- args: {
23
- value: {
24
- "id": 1,
25
- "nome": "dsadsa",
26
- "ativo": true,
27
- "dataCriacao": "2025-02-07T12:00:00.000Z",
28
-
29
- "itens": [{
30
- "id": 101,
31
- "descricao": "Item 1",
32
- "quantidade": 10,
33
- "preco": 19.99
34
- }, {
35
- "id": 102,
36
- "descricao": "Item 2",
37
- "quantidade": 5,
38
- "preco": 49.99
39
- }]
40
- }
41
- }
42
- }
@@ -1,29 +0,0 @@
1
- import React from "react"
2
- import { IAceEditorProps } from "react-ace"
3
-
4
- import { JsonForm } from "@/componentPatterns/JsonForm"
5
-
6
- import {
7
- JsonValue,
8
- Overwrite
9
- } from "@/componentPatterns/JsonForm/Content"
10
-
11
- type JsonViewProps = Overwrite<IAceEditorProps, {
12
- value?: JsonValue | null
13
- }>
14
-
15
- export const JsonView: React.FC<JsonViewProps> = (props) => {
16
- const {
17
- value,
18
- ...rest
19
- } = props
20
-
21
- return (
22
- <JsonForm.Root>
23
- <JsonForm.Content
24
- {...rest}
25
- value={value}
26
- />
27
- </JsonForm.Root>
28
- )
29
- }
@@ -1,39 +0,0 @@
1
- import { useState } from "react"
2
-
3
- export type ValidationType = Record<string, unknown>
4
-
5
- const useValidation = () => {
6
- const [validation, setValidation] = useState<ValidationType>({})
7
-
8
- const addValidation = (newValidation: ValidationType) => {
9
- setValidation((lastValidation) => ({
10
- ...lastValidation,
11
- ...newValidation
12
- }))
13
- }
14
-
15
- const clearValidation = (key: string) => {
16
- if (key in validation) {
17
- setValidation((lastValidation) => {
18
- const updatedData: ValidationType = { ...lastValidation }
19
-
20
- delete updatedData[key]
21
-
22
- return updatedData
23
- })
24
- }
25
- }
26
-
27
- const clearAllValidations = () => {
28
- setValidation({})
29
- }
30
-
31
- return {
32
- addValidation,
33
- clearValidation,
34
- clearAllValidations,
35
- validation
36
- }
37
- }
38
-
39
- export default useValidation
package/src/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from "@/components/Button"
2
- export * from "@/components/JsonEditor"
3
- export * from "@/components/JsonView"
package/tsconfig.app.json DELETED
@@ -1,31 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
4
- "target": "ES2020",
5
- "useDefineForClassFields": true,
6
- "lib": ["ES2020", "DOM", "DOM.Iterable"],
7
- "module": "ESNext",
8
- "skipLibCheck": true,
9
-
10
- /* Bundler mode */
11
- "moduleResolution": "bundler",
12
- "allowImportingTsExtensions": true,
13
- "isolatedModules": true,
14
- "moduleDetection": "force",
15
- "noEmit": true,
16
- "jsx": "react-jsx",
17
-
18
- /* Linting */
19
- "strict": true,
20
- "noUnusedLocals": true,
21
- "noUnusedParameters": true,
22
- "noFallthroughCasesInSwitch": true,
23
- "noUncheckedSideEffectImports": true,
24
- "baseUrl": ".",
25
- "paths": {
26
- "@/*": ["src/*"]
27
- },
28
- "allowSyntheticDefaultImports": true
29
- },
30
- "include": ["src"]
31
- }
@@ -1,18 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "jsx": "react-jsx",
4
- "target": "ES2022",
5
- "esModuleInterop": true,
6
- "moduleResolution": "node",
7
- "strict": true,
8
- "module": "ESNext",
9
- "sourceMap": true,
10
- "declaration": true,
11
- "lib": ["ES2022", "DOM", "DOM.Iterable"],
12
- "baseUrl": ".",
13
- "paths": {
14
- "@/*": ["src/*"]
15
- }
16
- },
17
- "include": ["src"]
18
- }
@@ -1,4 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.stories.ts"]
4
- }
package/tsconfig.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "files": [],
3
- "references": [
4
- { "path": "./tsconfig.app.json" },
5
- { "path": "./tsconfig.node.json" }
6
- ]
7
- }
@@ -1,24 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
4
- "target": "ES2022",
5
- "lib": ["ES2023"],
6
- "module": "ESNext",
7
- "skipLibCheck": true,
8
-
9
- /* Bundler mode */
10
- "moduleResolution": "bundler",
11
- "allowImportingTsExtensions": true,
12
- "isolatedModules": true,
13
- "moduleDetection": "force",
14
- "noEmit": true,
15
-
16
- /* Linting */
17
- "strict": true,
18
- "noUnusedLocals": true,
19
- "noUnusedParameters": true,
20
- "noFallthroughCasesInSwitch": true,
21
- "noUncheckedSideEffectImports": true
22
- },
23
- "include": ["vite.config.ts"]
24
- }
package/tsup.config.ts DELETED
@@ -1,12 +0,0 @@
1
- import { defineConfig } from "tsup"
2
-
3
- export default defineConfig({
4
- minify: true,
5
- entry: ["src/index.ts"],
6
- sourcemap: true,
7
- outDir: "dist",
8
- clean: true,
9
- format: ["cjs", "esm"],
10
- dts: true,
11
- tsconfig: "tsconfig.build.json"
12
- })
package/vite.config.ts DELETED
@@ -1,13 +0,0 @@
1
- import { defineConfig } from 'vite'
2
- import react from '@vitejs/plugin-react-swc'
3
- import path from 'node:path'
4
-
5
- // https://vite.dev/config/
6
- export default defineConfig({
7
- plugins: [react()],
8
- resolve: {
9
- alias: {
10
- "@": path.resolve(__dirname, "./src")
11
- }
12
- }
13
- })