nitro-web 0.0.16 → 0.0.18
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/_example/client/css/index.css +1 -1
- package/_example/client/index.ts +1 -2
- package/_example/tailwind.config.js +14 -14
- package/client/index.ts +6 -5
- package/components/auth/reset.tsx +4 -4
- package/components/auth/signin.tsx +3 -3
- package/components/auth/signup.tsx +5 -5
- package/components/partials/element/button.tsx +4 -3
- package/components/partials/element/calendar.tsx +123 -0
- package/components/partials/element/dropdown.tsx +6 -2
- package/components/partials/element/modal.tsx +54 -196
- package/components/partials/element/sidebar.tsx +2 -2
- package/components/partials/form/checkbox.tsx +1 -1
- package/components/partials/form/input-color.tsx +21 -20
- package/components/partials/form/input-currency.tsx +51 -35
- package/components/partials/form/input-date.tsx +137 -166
- package/components/partials/form/input.tsx +123 -92
- package/components/partials/form/select.tsx +4 -4
- package/components/partials/styleguide.tsx +89 -42
- package/components/settings/settings-account.tsx +6 -6
- package/components/settings/settings-business.tsx +12 -12
- package/components/settings/settings-team--member.tsx +8 -8
- package/package.json +8 -4
- package/readme.md +11 -7
- package/types/util.d.ts +19 -10
- package/types/util.d.ts.map +1 -1
- package/types.ts +5 -3
- package/util.js +22 -14
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
// todo: finish tailwind conversion
|
|
3
|
-
import { Button, FormError,
|
|
3
|
+
import { Button, FormError, Field, Modal, Select } from 'nitro-web'
|
|
4
4
|
import SvgTick from 'nitro-web/client/imgs/icons/tick.svg'
|
|
5
5
|
|
|
6
6
|
export function SettingsTeamMember ({ showModal, setShowModal }) {
|
|
@@ -38,7 +38,7 @@ export function SettingsTeamMember ({ showModal, setShowModal }) {
|
|
|
38
38
|
name="role"
|
|
39
39
|
isSearchable={false}
|
|
40
40
|
placeholder="Select a role"
|
|
41
|
-
onChange={onChange(setState)}
|
|
41
|
+
onChange={onChange.bind(setState)}
|
|
42
42
|
state={state}
|
|
43
43
|
minMenuWidth={460}
|
|
44
44
|
options={[
|
|
@@ -65,26 +65,26 @@ export function SettingsTeamMember ({ showModal, setShowModal }) {
|
|
|
65
65
|
</div>
|
|
66
66
|
<div class="col">
|
|
67
67
|
<label for="email">Email Address</label>
|
|
68
|
-
<
|
|
68
|
+
<Field
|
|
69
69
|
name="email" type="email" placeholder="Your email address..." state={state}
|
|
70
|
-
onChange={onChange(setState)}
|
|
70
|
+
onChange={onChange.bind(setState)}
|
|
71
71
|
/>
|
|
72
72
|
</div>
|
|
73
73
|
<div class="col">
|
|
74
74
|
<label for="firstName">First Name</label>
|
|
75
|
-
<
|
|
75
|
+
<Field name="firstName" placeholder="E.g. Bruce" state={state} onChange={onChange.bind(setState)} />
|
|
76
76
|
</div>
|
|
77
77
|
<div class="col">
|
|
78
78
|
<label for="lastName">Last Name</label>
|
|
79
|
-
<
|
|
79
|
+
<Field name="lastName" placeholder="E.g. Wayne" state={state} onChange={onChange.bind(setState)} />
|
|
80
80
|
</div>
|
|
81
81
|
<div class="col-12">
|
|
82
82
|
<label for="message">Invitation Message</label>
|
|
83
|
-
<
|
|
83
|
+
<Field
|
|
84
84
|
name="message"
|
|
85
85
|
type="textarea"
|
|
86
86
|
placeholder={`${user.firstName} is inviting you to collaborate on Nitro.`}
|
|
87
|
-
state={state} onChange={onChange(setState)}
|
|
87
|
+
state={state} onChange={onChange.bind(setState)}
|
|
88
88
|
/>
|
|
89
89
|
</div>
|
|
90
90
|
</div>
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
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.
|
|
6
|
+
"version": "0.0.18",
|
|
7
7
|
"main": "./client/index.ts",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"keywords": [
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"passport": "^0.4.1",
|
|
68
68
|
"passport-local": "^1.0.0",
|
|
69
69
|
"react-currency-input-field": "^3.8.0",
|
|
70
|
-
"react-day-picker": "^
|
|
70
|
+
"react-day-picker": "^9.6.4",
|
|
71
71
|
"react-number-format": "^5.4.0",
|
|
72
72
|
"react-router-dom": "6.24.1",
|
|
73
73
|
"react-select": "^5.9.0",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"twin.macro": "^3.4.1"
|
|
89
89
|
},
|
|
90
90
|
"engines": {
|
|
91
|
-
"node": "
|
|
91
|
+
"node": ">=18"
|
|
92
92
|
},
|
|
93
93
|
"standard-version": {
|
|
94
94
|
"releaseCommitMessageFormat": "{{currentTag}}",
|
|
@@ -107,5 +107,9 @@
|
|
|
107
107
|
]
|
|
108
108
|
},
|
|
109
109
|
"author": "",
|
|
110
|
-
"license": "ISC"
|
|
110
|
+
"license": "ISC",
|
|
111
|
+
"devDependencies": {
|
|
112
|
+
"@types/lodash": "^4.17.15",
|
|
113
|
+
"lodash": "^4.17.21"
|
|
114
|
+
}
|
|
111
115
|
}
|
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.18"`
|
|
15
15
|
3. In package.json, replace `"../.eslintrc.json"` with `"./node_modules/nitro-web/.eslintrc.json"`
|
|
16
16
|
4. Run `npm i`
|
|
17
17
|
|
|
@@ -31,21 +31,25 @@ const server = await setupRouter(config)
|
|
|
31
31
|
server.listen(3001, '0.0.0.0')
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
###
|
|
34
|
+
### Run
|
|
35
35
|
|
|
36
36
|
```bash
|
|
37
|
+
# Running in development (watching for changes)
|
|
37
38
|
npm run dev:server # run and watch the nodemon server
|
|
38
39
|
npm run dev:client # run and watch the webpack dev server
|
|
39
|
-
npm run dev # or
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### Building for production
|
|
40
|
+
npm run dev # or run and watch both the server and client
|
|
43
41
|
|
|
44
|
-
|
|
42
|
+
# Building for production
|
|
45
43
|
npm run build
|
|
46
44
|
npm run start
|
|
47
45
|
```
|
|
48
46
|
|
|
47
|
+
### Nitro Development
|
|
48
|
+
|
|
49
|
+
The same run commands can be used in ./ which are actually executed in ./example/ via npm workspaces (`-w` flag).
|
|
50
|
+
|
|
51
|
+
If util.js is updated, you must run `npm run types` to update the types file.
|
|
52
|
+
|
|
49
53
|
### Versions
|
|
50
54
|
|
|
51
55
|
- Express `^4.17`
|
package/types/util.d.ts
CHANGED
|
@@ -78,7 +78,13 @@ export function getCurrencyOptions(currencies: any): {
|
|
|
78
78
|
value: string;
|
|
79
79
|
label: any;
|
|
80
80
|
}[];
|
|
81
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Get the width of a prefix
|
|
83
|
+
* @param {string} prefix
|
|
84
|
+
* @param {number} paddingRight
|
|
85
|
+
* @returns {number}
|
|
86
|
+
*/
|
|
87
|
+
export function getPrefixWidth(prefix: string, paddingRight?: number): number;
|
|
82
88
|
export function getDirectories(path: any, pwd: any): {
|
|
83
89
|
clientDir: any;
|
|
84
90
|
componentsDir: any;
|
|
@@ -99,7 +105,12 @@ export function isEmpty(obj: any, truthyValuesOnly: any): boolean;
|
|
|
99
105
|
export function isFunction(variable: any): boolean;
|
|
100
106
|
export function isHex24(value: any): boolean;
|
|
101
107
|
export function isNumber(variable: any): boolean;
|
|
102
|
-
|
|
108
|
+
/**
|
|
109
|
+
* Checks if a variable is an object
|
|
110
|
+
* @param {unknown} variable
|
|
111
|
+
* @returns {boolean}
|
|
112
|
+
*/
|
|
113
|
+
export function isObject(variable: unknown): boolean;
|
|
103
114
|
export function isRegex(variable: any): boolean;
|
|
104
115
|
export function isString(variable: any): boolean;
|
|
105
116
|
export function lcFirst(string: any): any;
|
|
@@ -135,16 +146,14 @@ export function objectMap(object: any, fn: any): {};
|
|
|
135
146
|
export function omit(obj: any, fields: any): any;
|
|
136
147
|
/**
|
|
137
148
|
* Updates state from an input event, you can also update deep state properties
|
|
138
|
-
* @param {
|
|
139
|
-
*
|
|
140
|
-
* {
|
|
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'])}>
|
|
149
|
+
* @param {Event|Array[{string},{string|number|fn}]}
|
|
150
|
+
* {Event} - pass the event object e.g. <input onChange={(e) => onChange.call(setState, e)}>
|
|
151
|
+
* {Array} - pass an array with [path, value] e.g. <input onChange={(e) => onChange.call(setState, e, ['name', 'Joe'])}>
|
|
143
152
|
* @param {Function} [beforeSetState] - optional function to run before setting the state
|
|
144
|
-
*
|
|
145
|
-
* @return {
|
|
153
|
+
* @this {Function} setState
|
|
154
|
+
* @return {Promise({state, chunks, target})}
|
|
146
155
|
*/
|
|
147
|
-
export function onChange(
|
|
156
|
+
export function onChange(this: Function, event: any, beforeSetState?: Function): Promise<any>;
|
|
148
157
|
export function pad(num: any, padLeft: any, fixedRight: any): any;
|
|
149
158
|
export function pick(obj: any, keys: any): {};
|
|
150
159
|
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":"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,
|
|
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;;;;;GAKG;AACH,uCAJW,MAAM,iBACN,MAAM,GACJ,MAAM,CAYlB;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;;;;GAIG;AACH,mCAHW,OAAO,GACL,OAAO,CAKnB;AAED,gDAEC;AAED,iDAEC;AAED,0CAEC;AAED,yEAWC;AAED,mFAwCC;AAED;;;;;;;;;;;;;;;;;;;;;;;;EA0CC;AAED,uEAmBC;AAED,oDAKC;AAED,iDAOC;AAED;;;;;;;;GAQG;AACH,8FAyCC;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;AAxoCD,6BAAoC"}
|
package/types.ts
CHANGED
|
@@ -3,8 +3,9 @@ export type Config = {
|
|
|
3
3
|
clientUrl: string
|
|
4
4
|
env: string
|
|
5
5
|
awsUrl?: string
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
// needed for input-currency.tsx
|
|
7
|
+
currencies: { [key: string]: { symbol: string, digits: number } }
|
|
8
|
+
countries: { [key: string]: { numberFormats: { currency: string } } }
|
|
8
9
|
googleMapsApiKey?: string
|
|
9
10
|
isStatic?: boolean
|
|
10
11
|
placeholderEmail?: string
|
|
@@ -22,7 +23,8 @@ export type User = {
|
|
|
22
23
|
avatar?: MonasteryImage
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
export type
|
|
26
|
+
export type Error = { title: string, detail: string }
|
|
27
|
+
export type Errors = Array<Error> | null
|
|
26
28
|
|
|
27
29
|
export type MonasteryImage = {
|
|
28
30
|
url: string
|
package/util.js
CHANGED
|
@@ -479,8 +479,14 @@ export function getCurrencyOptions (currencies) {
|
|
|
479
479
|
return output
|
|
480
480
|
}
|
|
481
481
|
|
|
482
|
-
|
|
483
|
-
|
|
482
|
+
/**
|
|
483
|
+
* Get the width of a prefix
|
|
484
|
+
* @param {string} prefix
|
|
485
|
+
* @param {number} paddingRight
|
|
486
|
+
* @returns {number}
|
|
487
|
+
*/
|
|
488
|
+
export function getPrefixWidth (prefix, paddingRight=0) {
|
|
489
|
+
if (!prefix) return 0
|
|
484
490
|
const span = document.createElement('span')
|
|
485
491
|
span.classList.add('input-prefix')
|
|
486
492
|
span.style.visibility = 'hidden'
|
|
@@ -614,6 +620,11 @@ export function isNumber (variable) {
|
|
|
614
620
|
return !isNaN(parseFloat(variable)) && isFinite(variable)
|
|
615
621
|
}
|
|
616
622
|
|
|
623
|
+
/**
|
|
624
|
+
* Checks if a variable is an object
|
|
625
|
+
* @param {unknown} variable
|
|
626
|
+
* @returns {boolean}
|
|
627
|
+
*/
|
|
617
628
|
export function isObject (variable) {
|
|
618
629
|
// Excludes null and array's
|
|
619
630
|
return variable !== null && typeof variable === 'object' && !(variable instanceof Array) ? true : false
|
|
@@ -769,19 +780,16 @@ export function omit (obj, fields) {
|
|
|
769
780
|
|
|
770
781
|
/**
|
|
771
782
|
* Updates state from an input event, you can also update deep state properties
|
|
772
|
-
* @param {
|
|
773
|
-
*
|
|
774
|
-
* {
|
|
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'])}>
|
|
783
|
+
* @param {Event|Array[{string},{string|number|fn}]}
|
|
784
|
+
* {Event} - pass the event object e.g. <input onChange={(e) => onChange.call(setState, e)}>
|
|
785
|
+
* {Array} - pass an array with [path, value] e.g. <input onChange={(e) => onChange.call(setState, e, ['name', 'Joe'])}>
|
|
777
786
|
* @param {Function} [beforeSetState] - optional function to run before setting the state
|
|
778
|
-
*
|
|
779
|
-
* @return {
|
|
787
|
+
* @this {Function} setState
|
|
788
|
+
* @return {Promise({state, chunks, target})}
|
|
780
789
|
*/
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
return onChange.bind(this, setState)
|
|
790
|
+
export function onChange (event, beforeSetState) {
|
|
791
|
+
if (!isFunction(this)) {
|
|
792
|
+
throw new Error('Missing setState, please either call or bind setState to the function. E.g. onChange.call(setState, e)')
|
|
785
793
|
}
|
|
786
794
|
let elem = event.target ? event.target : { id: event[0], value: event[1] }
|
|
787
795
|
let chunks = (elem.id || elem.name).split('.')
|
|
@@ -800,7 +808,7 @@ export function onChange (setState, event, beforeSetState) {
|
|
|
800
808
|
|
|
801
809
|
// Update state
|
|
802
810
|
return new Promise((resolve) => {
|
|
803
|
-
|
|
811
|
+
this((state) => {
|
|
804
812
|
const newState = { ...state, ...(elem.files ? { hasFiles: true } : {}) }
|
|
805
813
|
let target = newState
|
|
806
814
|
for (var i = 0, l = chunks.length; i < l; i++) {
|