nitro-web 0.0.11 → 0.0.13
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/.eslintrc.json +4 -19
- package/_example/.env +1 -1
- package/_example/client/config.ts +2 -1
- package/_example/client/index.ts +6 -24
- package/_example/components/index.tsx +1 -1
- package/_example/package.json +1 -1
- package/_example/server/config.js +6 -7
- package/_example/tailwind.config.js +1 -1
- package/_example/tsconfig.json +10 -2
- package/_example/types.ts +1 -0
- package/client/{app.js → app.tsx} +101 -99
- package/client/globals.ts +42 -0
- package/client/index.ts +52 -0
- package/client/store.ts +31 -0
- package/components/auth/auth.api.js +3 -2
- package/components/auth/{reset.jsx → reset.tsx} +21 -23
- package/components/auth/{signin.jsx → signin.tsx} +14 -16
- package/components/auth/{signup.jsx → signup.tsx} +15 -17
- package/components/billing/stripe.api.js +2 -1
- package/components/dashboard/{dashboard.jsx → dashboard.tsx} +3 -3
- package/components/partials/element/{accordion.jsx → accordion.tsx} +21 -13
- package/components/partials/element/avatar.tsx +40 -0
- package/components/partials/element/{button.jsx → button.tsx} +20 -16
- package/components/partials/element/{dropdown.jsx → dropdown.tsx} +32 -30
- package/components/partials/element/{github-link.jsx → github-link.tsx} +3 -3
- package/components/partials/element/{initials.jsx → initials.tsx} +11 -2
- package/components/partials/element/{message.jsx → message.tsx} +22 -23
- package/components/partials/element/{modal.jsx → modal.tsx} +4 -3
- package/components/partials/element/{sidebar.jsx → sidebar.tsx} +14 -7
- package/components/partials/element/{tooltip.jsx → tooltip.tsx} +11 -3
- package/components/partials/element/{topbar.jsx → topbar.tsx} +9 -7
- package/components/partials/form/{checkbox.jsx → checkbox.tsx} +13 -13
- package/components/partials/form/drop-handler.tsx +68 -0
- package/components/partials/form/{drop.jsx → drop.tsx} +51 -33
- package/components/partials/form/form-error.tsx +27 -0
- package/components/partials/form/{input-color.jsx → input-color.tsx} +27 -15
- package/components/partials/form/{input-currency.jsx → input-currency.tsx} +37 -32
- package/components/partials/form/{input-date.jsx → input-date.tsx} +4 -3
- package/components/partials/form/{input.jsx → input.tsx} +35 -19
- package/components/partials/form/{location.jsx → location.tsx} +21 -8
- package/components/partials/form/{select.jsx → select.tsx} +142 -143
- package/components/partials/form/{toggle.jsx → toggle.tsx} +10 -2
- package/components/partials/{is-first-render.js → is-first-render.ts} +1 -2
- package/components/partials/layout/layout1.tsx +29 -0
- package/components/partials/layout/{layout2.jsx → layout2.tsx} +3 -3
- package/components/partials/{styleguide.jsx → styleguide.tsx} +16 -19
- package/components/settings/{settings-account.jsx → settings-account.tsx} +9 -13
- package/components/settings/{settings-business.jsx → settings-business.tsx} +7 -8
- package/components/settings/{settings-team--member.jsx → settings-team--member.tsx} +4 -11
- package/components/settings/{settings-team.jsx → settings-team.tsx} +4 -8
- package/components/settings/settings.api.js +1 -0
- package/package.json +17 -31
- package/readme.md +1 -1
- package/server/email/index.js +2 -1
- package/server/index.js +1 -0
- package/server/models/company.js +2 -1
- package/server/models/user.js +2 -1
- package/server/router.js +8 -2
- package/tsconfig.json +36 -0
- package/types/required-globals.d.ts +39 -0
- package/types/util.d.ts +12 -2
- package/types/util.d.ts.map +1 -1
- package/types.ts +43 -0
- package/util.js +14 -34
- package/webpack.config.js +23 -4
- package/_example/types/index.d.ts +0 -13
- package/_example/types/twin.d.ts +0 -19
- package/client/index.js +0 -44
- package/components/partials/element/avatar.jsx +0 -31
- package/components/partials/form/drop-handler.jsx +0 -62
- package/components/partials/form/form-error.jsx +0 -21
- package/components/partials/layout/layout1.jsx +0 -38
- package/types/client/app.d.ts +0 -2
- package/types/client/app.d.ts.map +0 -1
- package/types/client/index.d.ts +0 -29
- package/types/client/index.d.ts.map +0 -1
- package/types/components/auth/reset.d.ts +0 -3
- package/types/components/auth/reset.d.ts.map +0 -1
- package/types/components/auth/signin.d.ts +0 -4
- package/types/components/auth/signin.d.ts.map +0 -1
- package/types/components/auth/signup.d.ts +0 -4
- package/types/components/auth/signup.d.ts.map +0 -1
- package/types/components/dashboard/dashboard.d.ts +0 -4
- package/types/components/dashboard/dashboard.d.ts.map +0 -1
- package/types/components/partials/element/accordion.d.ts +0 -7
- package/types/components/partials/element/accordion.d.ts.map +0 -1
- package/types/components/partials/element/avatar.d.ts +0 -8
- package/types/components/partials/element/avatar.d.ts.map +0 -1
- package/types/components/partials/element/button.d.ts +0 -11
- package/types/components/partials/element/button.d.ts.map +0 -1
- package/types/components/partials/element/dropdown.d.ts +0 -17
- package/types/components/partials/element/dropdown.d.ts.map +0 -1
- package/types/components/partials/element/initials.d.ts +0 -9
- package/types/components/partials/element/initials.d.ts.map +0 -1
- package/types/components/partials/element/message.d.ts +0 -2
- package/types/components/partials/element/message.d.ts.map +0 -1
- package/types/components/partials/element/modal.d.ts +0 -10
- package/types/components/partials/element/modal.d.ts.map +0 -1
- package/types/components/partials/element/sidebar.d.ts +0 -6
- package/types/components/partials/element/sidebar.d.ts.map +0 -1
- package/types/components/partials/element/tooltip.d.ts +0 -8
- package/types/components/partials/element/tooltip.d.ts.map +0 -1
- package/types/components/partials/element/topbar.d.ts +0 -8
- package/types/components/partials/element/topbar.d.ts.map +0 -1
- package/types/components/partials/form/checkbox.d.ts +0 -14
- package/types/components/partials/form/checkbox.d.ts.map +0 -1
- package/types/components/partials/form/drop-handler.d.ts +0 -6
- package/types/components/partials/form/drop-handler.d.ts.map +0 -1
- package/types/components/partials/form/drop.d.ts +0 -11
- package/types/components/partials/form/drop.d.ts.map +0 -1
- package/types/components/partials/form/form-error.d.ts +0 -6
- package/types/components/partials/form/form-error.d.ts.map +0 -1
- package/types/components/partials/form/input-color.d.ts +0 -10
- package/types/components/partials/form/input-color.d.ts.map +0 -1
- package/types/components/partials/form/input-currency.d.ts +0 -10
- package/types/components/partials/form/input-currency.d.ts.map +0 -1
- package/types/components/partials/form/input.d.ts +0 -9
- package/types/components/partials/form/input.d.ts.map +0 -1
- package/types/components/partials/form/location.d.ts +0 -12
- package/types/components/partials/form/location.d.ts.map +0 -1
- package/types/components/partials/form/select.d.ts +0 -27
- package/types/components/partials/form/select.d.ts.map +0 -1
- package/types/components/partials/form/toggle.d.ts +0 -9
- package/types/components/partials/form/toggle.d.ts.map +0 -1
- package/types/components/partials/is-first-render.d.ts +0 -2
- package/types/components/partials/is-first-render.d.ts.map +0 -1
- package/types/components/partials/layout/layout1.d.ts +0 -13
- package/types/components/partials/layout/layout1.d.ts.map +0 -1
- package/types/components/partials/layout/layout2.d.ts +0 -4
- package/types/components/partials/layout/layout2.d.ts.map +0 -1
- package/types/components/partials/not-found.d.ts +0 -2
- package/types/components/partials/not-found.d.ts.map +0 -1
- package/types/components/partials/styleguide.d.ts +0 -4
- package/types/components/partials/styleguide.d.ts.map +0 -1
- package/types/components/settings/settings-account.d.ts +0 -6
- package/types/components/settings/settings-account.d.ts.map +0 -1
- package/types/components/settings/settings-business.d.ts +0 -4
- package/types/components/settings/settings-business.d.ts.map +0 -1
- package/types/components/settings/settings-team--member.d.ts +0 -5
- package/types/components/settings/settings-team--member.d.ts.map +0 -1
- package/types/components/settings/settings-team.d.ts +0 -4
- package/types/components/settings/settings-team.d.ts.map +0 -1
- /package/components/partials/{not-found.jsx → not-found.tsx} +0 -0
|
@@ -1,12 +1,8 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
// todo: finish tailwind conversion
|
|
2
|
-
import * as util from '
|
|
3
|
-
import SvgPlus from '
|
|
4
|
-
import { Button } from '
|
|
5
|
-
import { Table } from '../partials/element/table.jsx'
|
|
6
|
-
import { Avatar } from '../partials/element/avatar.jsx'
|
|
7
|
-
import { Tabbar } from '../partials/element/tabbar.jsx'
|
|
8
|
-
import { Topbar } from '../partials/element/topbar.jsx'
|
|
9
|
-
import { SettingsTeamMember } from './settings-team--member.jsx'
|
|
3
|
+
import * as util from 'nitro-web/util'
|
|
4
|
+
import SvgPlus from 'nitro-web/client/imgs/icons/plus.svg'
|
|
5
|
+
import { Button, Table, Avatar, Tabbar, Topbar, SettingsTeamMember } from 'nitro-web'
|
|
10
6
|
|
|
11
7
|
export function SettingsTeam({ config }) {
|
|
12
8
|
const isLoading = useState('')
|
package/package.json
CHANGED
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
"description": "Nitro is a battle-tested, modular base project to turbocharge your projects, styled using Tailwind 🚀",
|
|
4
4
|
"repository": "github:boycce/nitro-web",
|
|
5
5
|
"homepage": "https://boycce.github.io/nitro-web/",
|
|
6
|
-
"version": "0.0.
|
|
7
|
-
"main": "./client/index.
|
|
8
|
-
"types": "./types/client/index.d.ts",
|
|
6
|
+
"version": "0.0.13",
|
|
7
|
+
"main": "./client/index.ts",
|
|
9
8
|
"type": "module",
|
|
10
9
|
"keywords": [
|
|
11
10
|
"express",
|
|
@@ -20,35 +19,31 @@
|
|
|
20
19
|
"_example"
|
|
21
20
|
],
|
|
22
21
|
"exports": {
|
|
23
|
-
".":
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"types": "./types/server/index.d.ts"
|
|
32
|
-
},
|
|
22
|
+
".": "./client/index.ts",
|
|
23
|
+
"./client/imgs/*": "./client/imgs/*",
|
|
24
|
+
"./client/globals": "./client/globals.ts",
|
|
25
|
+
"./server": "./server/index.js",
|
|
26
|
+
"./types": "./types.ts",
|
|
27
|
+
"./.eslintrc.json": "./.eslintrc.json",
|
|
28
|
+
"./tsconfig.json": "./tsconfig.json",
|
|
29
|
+
"./webpack.config.js": "./webpack.config.js",
|
|
33
30
|
"./util": {
|
|
34
31
|
"require": "./util.js",
|
|
35
32
|
"import": "./util.js",
|
|
36
33
|
"types": "./types/util.d.ts"
|
|
37
|
-
}
|
|
38
|
-
"./.eslintrc.json": "./.eslintrc.json",
|
|
39
|
-
"./webpack.config.js": "./webpack.config.js"
|
|
34
|
+
}
|
|
40
35
|
},
|
|
41
36
|
"scripts": {
|
|
42
37
|
"dev": "npm run dev -w example",
|
|
43
38
|
"dev:client": "npm run dev:client -w example",
|
|
44
|
-
"dev:client-only": "
|
|
39
|
+
"dev:client-only": "isStatic=true npm run dev:client -w example",
|
|
45
40
|
"dev:server": "npm run dev:server -w example",
|
|
46
|
-
"build": "
|
|
47
|
-
"major": "standard-version --release-as major && npm publish",
|
|
48
|
-
"minor": "standard-version --release-as minor && npm publish",
|
|
49
|
-
"patch": "standard-version --release-as patch && npm publish",
|
|
41
|
+
"build": "isStatic=true npm run build -w example",
|
|
42
|
+
"major": "npm run types && standard-version --release-as major && npm publish",
|
|
43
|
+
"minor": "npm run types && standard-version --release-as minor && npm publish",
|
|
44
|
+
"patch": "npm run types && standard-version --release-as patch && npm publish",
|
|
50
45
|
"start": "npm run start -w example",
|
|
51
|
-
"types": "tsc
|
|
46
|
+
"types": "tsc util.js --declaration --declarationMap --allowJs --emitDeclarationOnly --jsx react-jsx --esModuleInterop --outDir types"
|
|
52
47
|
},
|
|
53
48
|
"dependencies": {
|
|
54
49
|
"@uiw/color-convert": "^2.3.0",
|
|
@@ -92,15 +87,6 @@
|
|
|
92
87
|
"tailwindcss": "^3.4.17",
|
|
93
88
|
"twin.macro": "^3.4.1"
|
|
94
89
|
},
|
|
95
|
-
"devDependencies": {
|
|
96
|
-
"@emotion/eslint-plugin": "^11.11.0",
|
|
97
|
-
"babel-eslint": "^10.0.3",
|
|
98
|
-
"eslint": "^8.57.1",
|
|
99
|
-
"eslint-plugin-import": "^2.26.0",
|
|
100
|
-
"eslint-plugin-react": "^7.19.0",
|
|
101
|
-
"eslint-plugin-react-hooks": "^4.0.0",
|
|
102
|
-
"standard-version": "^9.3.2"
|
|
103
|
-
},
|
|
104
90
|
"engines": {
|
|
105
91
|
"node": "^18"
|
|
106
92
|
},
|
package/readme.md
CHANGED
|
@@ -11,7 +11,7 @@ npm i nitro-web
|
|
|
11
11
|
### Install
|
|
12
12
|
|
|
13
13
|
1. Copy ./_example into your project
|
|
14
|
-
2. In package.json, replace `"nitro-web": "file:.."` with `"nitro-web": "~0.0.
|
|
14
|
+
2. In package.json, replace `"nitro-web": "file:.."` with `"nitro-web": "~0.0.13"`
|
|
15
15
|
3. In package.json, replace `"../.eslintrc.json"` with `"./node_modules/nitro-web/.eslintrc.json"`
|
|
16
16
|
4. Run `npm i`
|
|
17
17
|
|
package/server/email/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
// import axios from '@hokify/axios'
|
|
2
3
|
import nodemailer from 'nodemailer'
|
|
3
4
|
import mailgun from 'nodemailer-mailgun-transport'
|
|
@@ -6,7 +7,7 @@ import inlineCss from 'inline-css'
|
|
|
6
7
|
import { dirname, join } from 'path'
|
|
7
8
|
import { fileURLToPath } from 'url'
|
|
8
9
|
import path from 'path'
|
|
9
|
-
import { getDirectories } from '
|
|
10
|
+
import { getDirectories } from 'nitro-web/util'
|
|
10
11
|
|
|
11
12
|
let templates = {}
|
|
12
13
|
let nodemailerMailgun = undefined
|
package/server/index.js
CHANGED
package/server/models/company.js
CHANGED
package/server/models/user.js
CHANGED
package/server/router.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
import fs from 'fs'
|
|
2
3
|
import path, { dirname } from 'path'
|
|
3
4
|
import http from 'http'
|
|
@@ -8,8 +9,8 @@ import express from 'express'
|
|
|
8
9
|
import bodyParser from 'body-parser'
|
|
9
10
|
import sortRouteAddressesNodeps from 'sort-route-addresses-nodeps'
|
|
10
11
|
|
|
11
|
-
import { sendEmail } from '
|
|
12
|
-
import * as util from '
|
|
12
|
+
import { sendEmail } from 'nitro-web/server'
|
|
13
|
+
import * as util from 'nitro-web/util'
|
|
13
14
|
|
|
14
15
|
const _dirname = dirname(fileURLToPath(import.meta.url)) + '/'
|
|
15
16
|
|
|
@@ -43,6 +44,11 @@ export async function setupRouter (config) {
|
|
|
43
44
|
let name = filepath.replace(/^.*[\\\/]|\.api\.js$/g, '') // eslint-disable-line
|
|
44
45
|
controllers[name] = file
|
|
45
46
|
|
|
47
|
+
if (!file) {
|
|
48
|
+
console.warn(`API warning: no default export found on file ${filepath}`)
|
|
49
|
+
continue
|
|
50
|
+
}
|
|
51
|
+
|
|
46
52
|
if (file.setup) file.setup(allMiddleware, config)
|
|
47
53
|
if (file.routes) {
|
|
48
54
|
util.each(file.routes, (_middleware, key) => {
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"allowJs": true,
|
|
4
|
+
"checkJs": true,
|
|
5
|
+
"allowSyntheticDefaultImports": true,
|
|
6
|
+
"downlevelIteration": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"forceConsistentCasingInFileNames": true,
|
|
9
|
+
"isolatedModules": true,
|
|
10
|
+
"jsx": "react-jsx",
|
|
11
|
+
"lib": ["es6", "dom", "dom.iterable", "esnext"],
|
|
12
|
+
"module": "esnext",
|
|
13
|
+
"moduleResolution": "node",
|
|
14
|
+
"noEmit": false,
|
|
15
|
+
"noFallthroughCasesInSwitch": true,
|
|
16
|
+
"noImplicitAny": true,
|
|
17
|
+
"noImplicitReturns": false,
|
|
18
|
+
"noImplicitThis": true,
|
|
19
|
+
"noStrictGenericChecks": false,
|
|
20
|
+
"outDir": "./dist",
|
|
21
|
+
"paths": {
|
|
22
|
+
"types": ["./types.ts"]
|
|
23
|
+
},
|
|
24
|
+
"resolveJsonModule": true,
|
|
25
|
+
"skipLibCheck": true,
|
|
26
|
+
"sourceMap": true,
|
|
27
|
+
"strict": true,
|
|
28
|
+
"target": "es6"
|
|
29
|
+
},
|
|
30
|
+
"include": [
|
|
31
|
+
"client",
|
|
32
|
+
"components/**/*.tsx",
|
|
33
|
+
"components/**/*.ts",
|
|
34
|
+
"types"
|
|
35
|
+
]
|
|
36
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Required global types
|
|
2
|
+
import 'twin.macro'
|
|
3
|
+
import { css as cssImport } from '@emotion/react'
|
|
4
|
+
import styledImport from '@emotion/styled'
|
|
5
|
+
import { CSSInterpolation } from '@emotion/serialize'
|
|
6
|
+
|
|
7
|
+
declare global {
|
|
8
|
+
/** Webpack injected config variables */
|
|
9
|
+
const INJECTED: Record<string, string|boolean|object>
|
|
10
|
+
/** Webpack svg loader */
|
|
11
|
+
module '*.svg' {
|
|
12
|
+
const content: React.FC<React.SVGProps<SVGElement>>
|
|
13
|
+
export default content
|
|
14
|
+
}
|
|
15
|
+
/** Webpack image loader */
|
|
16
|
+
module '*.jpg' {
|
|
17
|
+
const content: string
|
|
18
|
+
export default content
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Webpack: Twin.macro css extension
|
|
23
|
+
// https://github.com/ben-rogerson/twin.examples/tree/master/react-emotion-typescript
|
|
24
|
+
declare module 'twin.macro' {
|
|
25
|
+
// The styled and css imports
|
|
26
|
+
const styled: typeof styledImport
|
|
27
|
+
const css: typeof cssImport
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Webpack: Twin & React-Html-Attrs babel plugins extend dom attributes
|
|
31
|
+
declare module 'react' {
|
|
32
|
+
// The tw and css prop
|
|
33
|
+
interface DOMAttributes<T> { // eslint-disable-line
|
|
34
|
+
tw?: string
|
|
35
|
+
css?: CSSInterpolation
|
|
36
|
+
class?: string | undefined,
|
|
37
|
+
for?: string | undefined
|
|
38
|
+
}
|
|
39
|
+
}
|
package/types/util.d.ts
CHANGED
|
@@ -88,7 +88,6 @@ export function getDirectories(path: any, pwd: any): {
|
|
|
88
88
|
tmpDir: any;
|
|
89
89
|
};
|
|
90
90
|
export function getLink(obj: any, query: any): string;
|
|
91
|
-
export function getPublicPath(env: any, homepage: any, publicPath: any): string;
|
|
92
91
|
export function getStripeClientPromise(stripePublishableKey: any): any;
|
|
93
92
|
export function getResponseErrors(errs: any): any;
|
|
94
93
|
export function inArray(array: any, key: any, value: any): any;
|
|
@@ -134,7 +133,18 @@ export function mongoDocWithinPassedAddress(address: any, km: any, prefix: any):
|
|
|
134
133
|
export function mongoPointDifference(point1: any, point2: any): string;
|
|
135
134
|
export function objectMap(object: any, fn: any): {};
|
|
136
135
|
export function omit(obj: any, fields: any): any;
|
|
137
|
-
|
|
136
|
+
/**
|
|
137
|
+
* Updates state from an input event, you can also update deep state properties
|
|
138
|
+
* @param {Function} setState
|
|
139
|
+
* @param {Empty | Event | Array[{string}, {string|number|fn}]}
|
|
140
|
+
* {Empty} - pass undefined to return a reusable function, e.g. const _onChange = onChange(setState)
|
|
141
|
+
* {Event} - pass the event object, e.g. <input onChange={_onChange}>
|
|
142
|
+
* {Array} - pass an array with [path, value], e.g. <input onChange={() => _onChange(['name', 'Joe'])}>
|
|
143
|
+
* @param {Function} [beforeSetState] - optional function to run before setting the state
|
|
144
|
+
*
|
|
145
|
+
* @return {Function | Promise({state, chunks, target})}
|
|
146
|
+
*/
|
|
147
|
+
export function onChange(setState: Function, event: any, beforeSetState?: Function): Function | Promise<any>;
|
|
138
148
|
export function pad(num: any, padLeft: any, fixedRight: any): any;
|
|
139
149
|
export function pick(obj: any, keys: any): {};
|
|
140
150
|
export function queryObject(search: any, assignTrue: any): any;
|
package/types/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../util.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../util.js"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8BC;AAED,6DAaC;AAED,4DAQC;AAED,iFAaC;AAED,0EAIC;AAED,gDAEC;AAED,0CAEC;AAED,qFAQC;AAED,uDAIC;AAED,iEAoBC;AAED;;;;EAgIC;AAED,wCASC;AAED,mDAYC;AAED,+DAyBC;AAED,iEAeC;AAED,kFA2BC;AAED,gEAIC;AAED,6CASC;AAED,qEAsEC;AAED,8CAGC;AAED,kDAQC;AAED;;;;IAOC;AAED;;;IAOC;AAED,mFAUC;AAED;;;;;;;EAUC;AAED,sDAYC;AAED,uEAEC;AAED,kDAsBC;AAED,+DAaC;AAED,0DAEC;AAED,+CAEC;AAED,kDAEC;AAED,6CAIC;AAED,kEAOC;AAED,mDAEC;AAED,6CAiBC;AAED,iDAEC;AAED,iDAGC;AAED,gDAEC;AAED,iDAEC;AAED,0CAEC;AAED,yEAWC;AAED,mFAwCC;AAED;;;;;;;;;;;;;;;;;;;;;;;;EA0CC;AAED,uEAmBC;AAED,oDAKC;AAED,iDAOC;AAED;;;;;;;;;;GAUG;AAEH,qFAHY,uBAAkB,CA4C7B;AAED,kEAQC;AAED,8CAeC;AAED,+DAiCC;AAED,8CAcC;AAED,yFAiDC;AAED,oDAYC;AAED,4EAmBC;AAED,kDAUC;AAED,mFAiDC;AAED,oEAaC;AAED,8EAIC;AAED,0DAQC;AAED,uDAMC;AAED,mFAwBC;AAED;;;;EAyBC;AAED,8CAIC;AAED,uCAGC;AAED,0CAGC;AAhoCD,6BAAoC"}
|
package/types.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Expected config to be available
|
|
2
|
+
export type Config = {
|
|
3
|
+
clientUrl: string
|
|
4
|
+
env: string
|
|
5
|
+
awsUrl?: string
|
|
6
|
+
currencies?: object
|
|
7
|
+
countries?: object
|
|
8
|
+
googleMapsApiKey?: string
|
|
9
|
+
isStatic?: boolean
|
|
10
|
+
placeholderEmail?: string
|
|
11
|
+
stripePublishableKey?: string
|
|
12
|
+
middleware?: Record<string, (route: unknown, store: Store) => undefined | { redirect: string }>
|
|
13
|
+
beforeApp?: () => Promise<object>
|
|
14
|
+
beforeStoreUpdate?: (prevStore: Store | null, newData: Store) => Store
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type User = {
|
|
18
|
+
_id?: string
|
|
19
|
+
firstName?: string
|
|
20
|
+
lastName?: string
|
|
21
|
+
name?: string
|
|
22
|
+
avatar?: MonasteryImage
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type Errors = Array<{ title: string, detail: string }> | null
|
|
26
|
+
|
|
27
|
+
export type MonasteryImage = {
|
|
28
|
+
url: string
|
|
29
|
+
filename: string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type MessageObject = {
|
|
33
|
+
date?: number
|
|
34
|
+
text: string | React.ReactNode
|
|
35
|
+
type?: 'error' | 'info' | 'success' | 'warning'
|
|
36
|
+
timeout?: number
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type Store = {
|
|
40
|
+
message?: MessageObject | string | null
|
|
41
|
+
user?: User | null,
|
|
42
|
+
apiAvailable?: boolean
|
|
43
|
+
}
|
package/util.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
import _axios from '@hokify/axios'
|
|
2
3
|
import axiosRetry from 'axios-retry'
|
|
3
4
|
import dateformat from 'dateformat'
|
|
@@ -59,7 +60,7 @@ export function buildUrl (url, parameters) {
|
|
|
59
60
|
*/
|
|
60
61
|
const params = Object.keys(parameters).map((p) => `${encodeURIComponent(p)}=${encodeURIComponent(parameters[p])}`)
|
|
61
62
|
return [url, params.join('&')].join('?')
|
|
62
|
-
}
|
|
63
|
+
}
|
|
63
64
|
|
|
64
65
|
export function camelCase (str, capitaliseFirst, allowNumber) {
|
|
65
66
|
let regex = (capitaliseFirst ? '(?:^[a-z0-9]|' : '(?:') + '[-]+[a-z0-9])'
|
|
@@ -516,27 +517,6 @@ export function getLink (obj, query) {
|
|
|
516
517
|
return queryString(newQueryObj) || '?'
|
|
517
518
|
}
|
|
518
519
|
|
|
519
|
-
export function getPublicPath(env, homepage, publicPath) {
|
|
520
|
-
/**
|
|
521
|
-
* Returns public path used for webapck (we can't use relative paths)
|
|
522
|
-
* @param {string} env - 'development', 'staging', 'production'
|
|
523
|
-
* @param {string} publicPath - proces.env.publicPath
|
|
524
|
-
* @param {string} homepage - package.json homepage
|
|
525
|
-
*/
|
|
526
|
-
if (publicPath) {
|
|
527
|
-
const publicPathObj = new URL(publicPath, 'https://domain.com')
|
|
528
|
-
return publicPathObj.pathname
|
|
529
|
-
|
|
530
|
-
} else if (homepage) {
|
|
531
|
-
const homepageObj = new URL(homepage, 'https://domain.com')
|
|
532
|
-
if (env === 'development') return '/'
|
|
533
|
-
else return homepageObj.pathname
|
|
534
|
-
|
|
535
|
-
} else {
|
|
536
|
-
return '/'
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
|
|
540
520
|
export function getStripeClientPromise (stripePublishableKey) {
|
|
541
521
|
return global.stripeClientPromise || (global.stripeClientPromise = loadStripe(stripePublishableKey))
|
|
542
522
|
}
|
|
@@ -787,19 +767,19 @@ export function omit (obj, fields) {
|
|
|
787
767
|
return shallowCopy
|
|
788
768
|
}
|
|
789
769
|
|
|
770
|
+
/**
|
|
771
|
+
* Updates state from an input event, you can also update deep state properties
|
|
772
|
+
* @param {Function} setState
|
|
773
|
+
* @param {Empty | Event | Array[{string}, {string|number|fn}]}
|
|
774
|
+
* {Empty} - pass undefined to return a reusable function, e.g. const _onChange = onChange(setState)
|
|
775
|
+
* {Event} - pass the event object, e.g. <input onChange={_onChange}>
|
|
776
|
+
* {Array} - pass an array with [path, value], e.g. <input onChange={() => _onChange(['name', 'Joe'])}>
|
|
777
|
+
* @param {Function} [beforeSetState] - optional function to run before setting the state
|
|
778
|
+
*
|
|
779
|
+
* @return {Function | Promise({state, chunks, target})}
|
|
780
|
+
*/
|
|
781
|
+
/////////////////////////////////////////////////////////////////////convert to bind
|
|
790
782
|
export function onChange (setState, event, beforeSetState) {
|
|
791
|
-
/**
|
|
792
|
-
* Updates state from an input event, you can also update deep state properties
|
|
793
|
-
*
|
|
794
|
-
* @param {function} setState
|
|
795
|
-
* @param {Empty | Event | Array[{string}, {string|number|fn}]}
|
|
796
|
-
* {Empty} - pass undefined to return a reusable function, e.g. const _onChange = onChange(setState)
|
|
797
|
-
* {Event} - pass the event object, e.g. <input onChange={_onChange}>
|
|
798
|
-
* {Array} - pass an array with [path, value], e.g. <input onChange={() => _onChange(['name', 'Joe'])}>
|
|
799
|
-
* @param {function} beforeSetState - optional function to run before setting the state
|
|
800
|
-
*
|
|
801
|
-
* @return {Function | Promise({state, chunks, target})}
|
|
802
|
-
*/
|
|
803
783
|
if (typeof event === 'undefined') {
|
|
804
784
|
return onChange.bind(this, setState)
|
|
805
785
|
}
|
package/webpack.config.js
CHANGED
|
@@ -16,7 +16,7 @@ import postcssImport from 'postcss-import'
|
|
|
16
16
|
import postcssNested from 'postcss-nested'
|
|
17
17
|
import postcssFor from 'postcss-for'
|
|
18
18
|
import { createRequire } from 'module'
|
|
19
|
-
import { getDirectories
|
|
19
|
+
import { getDirectories } from 'nitro-web/util'
|
|
20
20
|
|
|
21
21
|
const _require = createRequire(import.meta.url)
|
|
22
22
|
const pick = (object, list) => list.reduce((o, e) => ((o[e] = object[e]), o), {})
|
|
@@ -278,10 +278,8 @@ export const getConfig = (config) => {
|
|
|
278
278
|
],
|
|
279
279
|
}),
|
|
280
280
|
new webpack.DefinePlugin({
|
|
281
|
-
|
|
281
|
+
INJECTED: JSON.stringify({
|
|
282
282
|
...pick(config, config.inject ? config.inject.split(' ') : []),
|
|
283
|
-
isDemo: process.env.isDemo,
|
|
284
|
-
version: config.version,
|
|
285
283
|
}),
|
|
286
284
|
}),
|
|
287
285
|
new ESLintPlugin({
|
|
@@ -338,4 +336,25 @@ class InterpolateHtmlPlugin {
|
|
|
338
336
|
})
|
|
339
337
|
})
|
|
340
338
|
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function getPublicPath(env, homepage, publicPath) {
|
|
342
|
+
/**
|
|
343
|
+
* Returns public path used for webapck (we can't use relative paths)
|
|
344
|
+
* @param {string} env - 'development', 'staging', 'production'
|
|
345
|
+
* @param {string} publicPath - proces.env.publicPath
|
|
346
|
+
* @param {string} homepage - package.json homepage
|
|
347
|
+
*/
|
|
348
|
+
if (publicPath) {
|
|
349
|
+
const publicPathObj = new URL(publicPath, 'https://domain.com')
|
|
350
|
+
return publicPathObj.pathname
|
|
351
|
+
|
|
352
|
+
} else if (homepage) {
|
|
353
|
+
const homepageObj = new URL(homepage, 'https://domain.com')
|
|
354
|
+
if (env === 'development') return '/'
|
|
355
|
+
else return homepageObj.pathname
|
|
356
|
+
|
|
357
|
+
} else {
|
|
358
|
+
return '/'
|
|
359
|
+
}
|
|
341
360
|
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// Shared store
|
|
2
|
-
declare global {
|
|
3
|
-
const sharedStore: Record<string, unknown>
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
// Svgs
|
|
7
|
-
declare module '*.svg' {
|
|
8
|
-
const content: string | React.FC<React.SVGProps<SVGElement>>
|
|
9
|
-
export default content
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// Webpack config
|
|
13
|
-
declare const CONFIG: Record<string, string>
|
package/_example/types/twin.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// Twin.macro - https://github.com/ben-rogerson/twin.examples/tree/master/react-emotion-typescript
|
|
2
|
-
import 'twin.macro'
|
|
3
|
-
import { css as cssImport } from '@emotion/react'
|
|
4
|
-
import styledImport from '@emotion/styled'
|
|
5
|
-
import { CSSInterpolation } from '@emotion/serialize'
|
|
6
|
-
|
|
7
|
-
declare module 'twin.macro' {
|
|
8
|
-
// The styled and css imports
|
|
9
|
-
const styled: typeof styledImport
|
|
10
|
-
const css: typeof cssImport
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
declare module 'react' {
|
|
14
|
-
// The tw and css prop
|
|
15
|
-
interface DOMAttributes<T> {
|
|
16
|
-
tw?: string
|
|
17
|
-
css?: CSSInterpolation
|
|
18
|
-
}
|
|
19
|
-
}
|
package/client/index.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// export const pi = parseFloat(3.142)
|
|
2
|
-
export * from './app.js'
|
|
3
|
-
export * from '../util.js'
|
|
4
|
-
export * as util from '../util.js'
|
|
5
|
-
|
|
6
|
-
// Component Pages
|
|
7
|
-
export { Signin } from '../components/auth/signin.jsx'
|
|
8
|
-
export { Signup } from '../components/auth/signup.jsx'
|
|
9
|
-
export { ResetInstructions, ResetPassword } from '../components/auth/reset.jsx'
|
|
10
|
-
export { Dashboard } from '../components/dashboard/dashboard.jsx'
|
|
11
|
-
export { NotFound } from '../components/partials/not-found.jsx'
|
|
12
|
-
export { Styleguide } from '../components/partials/styleguide.jsx'
|
|
13
|
-
// export { SettingsAccount } from '../components/settings/settings-account.jsx'
|
|
14
|
-
// export { SettingsBusiness } from '../components/settings/settings-business.jsx'
|
|
15
|
-
// export { SettingsTeamMember } from '../components/settings/settings-team--member.jsx'
|
|
16
|
-
// export { SettingsTeam } from '../components/settings/settings-team.jsx'
|
|
17
|
-
|
|
18
|
-
// Component Elements
|
|
19
|
-
export { Accordion } from '../components/partials/element/accordion.jsx'
|
|
20
|
-
export { Avatar } from '../components/partials/element/avatar.jsx'
|
|
21
|
-
export { Button } from '../components/partials/element/button.jsx'
|
|
22
|
-
export { Dropdown } from '../components/partials/element/dropdown.jsx'
|
|
23
|
-
export { Initials } from '../components/partials/element/initials.jsx'
|
|
24
|
-
export { Message } from '../components/partials/element/message.jsx'
|
|
25
|
-
// export { Modal } from '../components/partials/element/modal.jsx'
|
|
26
|
-
export { Sidebar } from '../components/partials/element/sidebar.jsx'
|
|
27
|
-
export { Tooltip } from '../components/partials/element/tooltip.jsx'
|
|
28
|
-
export { Topbar } from '../components/partials/element/topbar.jsx'
|
|
29
|
-
|
|
30
|
-
// Component Form
|
|
31
|
-
export { Checkbox } from '../components/partials/form/checkbox.jsx'
|
|
32
|
-
export { Drop } from '../components/partials/form/drop.jsx'
|
|
33
|
-
export { FormError } from '../components/partials/form/form-error.jsx'
|
|
34
|
-
export { Input } from '../components/partials/form/input.jsx'
|
|
35
|
-
export { Location } from '../components/partials/form/location.jsx'
|
|
36
|
-
export { Select } from '../components/partials/form/select.jsx'
|
|
37
|
-
export { Toggle } from '../components/partials/form/toggle.jsx'
|
|
38
|
-
|
|
39
|
-
// Component Layouts
|
|
40
|
-
export { Layout1 } from '../components/partials/layout/layout1.jsx'
|
|
41
|
-
export { Layout2 } from '../components/partials/layout/layout2.jsx'
|
|
42
|
-
|
|
43
|
-
// Component Other
|
|
44
|
-
export { IsFirstRender } from '../components/partials/is-first-render.js'
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { s3Image } from '../../../util.js'
|
|
2
|
-
import { Initials } from './initials.jsx'
|
|
3
|
-
import noImage from '../../../client/imgs/no-image.svg'
|
|
4
|
-
import avatarImg from '../../../client/imgs/avatar.jpg'
|
|
5
|
-
|
|
6
|
-
export function Avatar({ awsUrl, isRound, user, showPlaceholderImage, className }) {
|
|
7
|
-
const classes = 'rounded-full w-[30px] h-[30px] object-cover transition-all duration-150 ease ' + (className || '')
|
|
8
|
-
|
|
9
|
-
function getInitials(user) {
|
|
10
|
-
const text = (user.firstName ? [user.firstName, user.lastName] : user.name.split(' ')).map((o) => o.charAt(0))
|
|
11
|
-
if (text.length == 1) return text[0]
|
|
12
|
-
if (text.length > 1) return `${text[0]}${text[text.length - 1]}`
|
|
13
|
-
return ''
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function getHex(user) {
|
|
17
|
-
let colors = ['#067306', '#AA33FF', '#FF54AF', '#F44336', '#c03c3c', '#7775f2', '#d88c1b']
|
|
18
|
-
let charIndex = (user.firstName||'a').toLowerCase().charCodeAt(0) - 97
|
|
19
|
-
let charIndexLimited = (charIndex < 0 || charIndex > 25) ? 25 : charIndex
|
|
20
|
-
let index = Math.round(charIndexLimited / 25 * (colors.length-1))
|
|
21
|
-
return colors[index]
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
user.avatar
|
|
26
|
-
? <img class={classes} src={s3Image(awsUrl, user.avatar, 'small') || noImage} />
|
|
27
|
-
: showPlaceholderImage ? <img class={classes} src={avatarImg} width="30px" />
|
|
28
|
-
: <Initials class={classes} icon={{ initials: getInitials(user), hex: getHex(user) }} isRound={isRound} isMedium={true} />
|
|
29
|
-
)
|
|
30
|
-
}
|
|
31
|
-
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
export const DropHandler = ({ onDrop, children, className }) => {
|
|
2
|
-
const dropRef = useRef()
|
|
3
|
-
let dragCounter = useRef(0).current
|
|
4
|
-
const [dragging, setDragging] = useState(false)
|
|
5
|
-
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
let div = dropRef.current
|
|
8
|
-
div.addEventListener('dragenter', handleDragIn)
|
|
9
|
-
div.addEventListener('dragleave', handleDragOut)
|
|
10
|
-
div.addEventListener('dragover', handleDragOver)
|
|
11
|
-
div.addEventListener('drop', handleDrop)
|
|
12
|
-
return () => {
|
|
13
|
-
div.removeEventListener('dragenter', handleDragIn)
|
|
14
|
-
div.removeEventListener('dragleave', handleDragOut)
|
|
15
|
-
div.removeEventListener('dragover', handleDragOver)
|
|
16
|
-
div.removeEventListener('drop', handleDrop)
|
|
17
|
-
}
|
|
18
|
-
}, [])
|
|
19
|
-
|
|
20
|
-
const handleDragIn = (e) => {
|
|
21
|
-
e.preventDefault()
|
|
22
|
-
e.stopPropagation()
|
|
23
|
-
dragCounter++
|
|
24
|
-
if (e.dataTransfer.items && e.dataTransfer.items.length > 0) {
|
|
25
|
-
setDragging(true)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const handleDragOut = (e) => {
|
|
30
|
-
e.preventDefault()
|
|
31
|
-
e.stopPropagation()
|
|
32
|
-
dragCounter--
|
|
33
|
-
if (dragCounter === 0) {
|
|
34
|
-
setDragging(false)
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const handleDragOver = (e) => {
|
|
39
|
-
e.preventDefault()
|
|
40
|
-
e.stopPropagation()
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const handleDrop = (e) => {
|
|
44
|
-
e.preventDefault()
|
|
45
|
-
e.stopPropagation()
|
|
46
|
-
setDragging(false)
|
|
47
|
-
if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {
|
|
48
|
-
onDrop(e.dataTransfer.files)
|
|
49
|
-
// e.dataTransfer.clearData() // causes an error in firefox
|
|
50
|
-
dragCounter = 0
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<div
|
|
56
|
-
ref={dropRef}
|
|
57
|
-
class={`${className} relative w-full p-[20px] border-2 border-dashed border-input-border rounded-md ${dragging ? 'border-primary before:content-[""] before:absolute before:inset-0 before:bg-primary before:opacity-5' : ''}`}
|
|
58
|
-
>
|
|
59
|
-
{children}
|
|
60
|
-
</div>
|
|
61
|
-
)
|
|
62
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export function FormError({ state, fields, className }) {
|
|
2
|
-
/**
|
|
3
|
-
* this is a catch all error component that should be placed next to the submit button
|
|
4
|
-
* @param {object} state
|
|
5
|
-
* @param {array} <fields> - display all errors except these field titles, e.g. ['name', 'address']
|
|
6
|
-
*/
|
|
7
|
-
for (let item of state.errors || []) {
|
|
8
|
-
if (!item.title || item.title.match(/^(error|invalid)$/i) || (fields && !fields.includes(item.title))) {
|
|
9
|
-
var error = item
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return (
|
|
13
|
-
<>
|
|
14
|
-
{error ? (
|
|
15
|
-
<div class={`text-danger mt-1 text-sm ${className||''}`}>
|
|
16
|
-
{error.detail}
|
|
17
|
-
</div>
|
|
18
|
-
) : null}
|
|
19
|
-
</>
|
|
20
|
-
)
|
|
21
|
-
}
|