@startlibs/form 1.1.0 → 1.1.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/lib/AutoComplete.mjs +4 -1
- package/lib/AutoComplete.mjs.map +1 -1
- package/lib/RichText.mjs +4 -1
- package/lib/RichText.mjs.map +1 -1
- package/lib/index.cjs +11 -5
- package/lib/index.cjs.map +1 -1
- package/lib/useDraftConfirmation.mjs +1 -1
- package/lib/useDraftConfirmation.mjs.map +1 -1
- package/package.json +5 -4
- package/src/AutoComplete.jsx +4 -1
- package/src/RichText.jsx +4 -1
- package/src/useDraftConfirmation.jsx +1 -1
|
@@ -40,7 +40,7 @@ const useDraftConfirmation = (submit, discard, meta) => {
|
|
|
40
40
|
const Dialog = startlibs.dialogs[dialog.isOpen];
|
|
41
41
|
if (process.env.NODE_ENV !== 'production') {
|
|
42
42
|
if (dialog.isOpen && !Dialog) {
|
|
43
|
-
console.log("Dialog [".concat(
|
|
43
|
+
console.log("Dialog [".concat(dialog.isOpen, "] not registered in startlibs.dialogs"));
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
const feedback = dialog.isOpen ? /*#__PURE__*/React.createElement(Dialog, _extends({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDraftConfirmation.mjs","sources":["../src/useDraftConfirmation.jsx"],"sourcesContent":["import React, {useContext} from 'react'\nimport {useToggle, useRefToggle, StartlibsContext, useRefState} from '@startlibs/core'\nimport {callIfFunction} from '@startlibs/utils'\n\nexport const useDraftConfirmation = (submit, discard, meta) => {\n const loading = useToggle()\n const dialog = useToggle()\n const draft = useRefToggle()\n const promiseResolver = useRefState()\n const startlibs = useContext(StartlibsContext)\n\n const confirmation = (dialogType = 'submit-draft', callback) => {\n if (callIfFunction(draft.isOpen)) {\n dialog.openWith(dialogType)\n return new Promise((res) =>\n promiseResolver.set(() => (r) => {\n dialog.close()\n callIfFunction(callback,r)\n res(r)\n }))\n } else {\n return Promise.resolve()\n }\n }\n\n\n const submitAndResolve = async () => {\n loading.open()\n try {\n await submit()\n callIfFunction(promiseResolver.get())\n } catch (e) { } finally {\n dialog.close()\n loading.close()\n }\n }\n\n const discardAndResolve = () => {\n callIfFunction(discard)\n callIfFunction(promiseResolver.get())\n }\n\n const Dialog = startlibs.dialogs[dialog.isOpen]\n if (process.env.NODE_ENV !== 'production') {\n if (dialog.isOpen && !Dialog) { console.log(`Dialog [${
|
|
1
|
+
{"version":3,"file":"useDraftConfirmation.mjs","sources":["../src/useDraftConfirmation.jsx"],"sourcesContent":["import React, {useContext} from 'react'\nimport {useToggle, useRefToggle, StartlibsContext, useRefState} from '@startlibs/core'\nimport {callIfFunction} from '@startlibs/utils'\n\nexport const useDraftConfirmation = (submit, discard, meta) => {\n const loading = useToggle()\n const dialog = useToggle()\n const draft = useRefToggle()\n const promiseResolver = useRefState()\n const startlibs = useContext(StartlibsContext)\n\n const confirmation = (dialogType = 'submit-draft', callback) => {\n if (callIfFunction(draft.isOpen)) {\n dialog.openWith(dialogType)\n return new Promise((res) =>\n promiseResolver.set(() => (r) => {\n dialog.close()\n callIfFunction(callback,r)\n res(r)\n }))\n } else {\n return Promise.resolve()\n }\n }\n\n\n const submitAndResolve = async () => {\n loading.open()\n try {\n await submit()\n callIfFunction(promiseResolver.get())\n } catch (e) { } finally {\n dialog.close()\n loading.close()\n }\n }\n\n const discardAndResolve = () => {\n callIfFunction(discard)\n callIfFunction(promiseResolver.get())\n }\n\n const Dialog = startlibs.dialogs[dialog.isOpen]\n if (process.env.NODE_ENV !== 'production') {\n if (dialog.isOpen && !Dialog) { console.log(`Dialog [${dialog.isOpen}] not registered in startlibs.dialogs`) }\n }\n\n const feedback =\n dialog.isOpen\n ? <Dialog\n submit={submitAndResolve}\n discard={discardAndResolve}\n isLoading={loading.isOpen}\n cancel={dialog.close}\n {...meta}\n />\n : null\n\n return [feedback, draft, confirmation]\n}"],"names":["useDraftConfirmation","submit","discard","meta","loading","useToggle","dialog","draft","useRefToggle","promiseResolver","useRefState","startlibs","useContext","StartlibsContext","confirmation","dialogType","arguments","length","undefined","callback","callIfFunction","isOpen","openWith","Promise","res","set","r","close","resolve","submitAndResolve","open","get","e","discardAndResolve","Dialog","dialogs","process","env","NODE_ENV","console","log","concat","feedback","React","createElement","_extends","isLoading","cancel"],"mappings":";;;;;AAIO,MAAMA,oBAAoB,GAAGA,CAACC,MAAM,EAAEC,OAAO,EAAEC,IAAI,KAAK;AAC7D,EAAA,MAAMC,OAAO,GAAGC,SAAS,EAAE,CAAA;AAC3B,EAAA,MAAMC,MAAM,GAAGD,SAAS,EAAE,CAAA;AAC1B,EAAA,MAAME,KAAK,GAAGC,YAAY,EAAE,CAAA;AAC5B,EAAA,MAAMC,eAAe,GAAGC,WAAW,EAAE,CAAA;AACrC,EAAA,MAAMC,SAAS,GAAGC,UAAU,CAACC,gBAAgB,CAAC,CAAA;AAE9C,EAAA,MAAMC,YAAY,GAAG,YAA2C;AAAA,IAAA,IAA1CC,UAAU,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,cAAc,CAAA;IAAA,IAAEG,QAAQ,GAAAH,SAAA,CAAAC,MAAA,GAAAD,CAAAA,GAAAA,SAAA,MAAAE,SAAA,CAAA;AACzD,IAAA,IAAIE,cAAc,CAACb,KAAK,CAACc,MAAM,CAAC,EAAE;AAChCf,MAAAA,MAAM,CAACgB,QAAQ,CAACP,UAAU,CAAC,CAAA;MAC3B,OAAO,IAAIQ,OAAO,CAAEC,GAAG,IACrBf,eAAe,CAACgB,GAAG,CAAC,MAAOC,CAAC,IAAK;QAC/BpB,MAAM,CAACqB,KAAK,EAAE,CAAA;AACdP,QAAAA,cAAc,CAACD,QAAQ,EAACO,CAAC,CAAC,CAAA;QAC1BF,GAAG,CAACE,CAAC,CAAC,CAAA;AACR,OAAC,CAAC,CAAC,CAAA;AAC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ACT,CAAC,GACA,IAAI,CAAA;AAER,EAAA,OAAO,CAACuC,QAAQ,EAAEnC,KAAK,EAAEO,YAAY,CAAC,CAAA;AACxC;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startlibs/form",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Startlibs Form",
|
|
5
5
|
"main": "lib/index.cjs",
|
|
6
6
|
"exports": {
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"polished": "^2.0.0 || ^3.0.0 || ^4.0.0",
|
|
26
26
|
"react": ">=16.8",
|
|
27
27
|
"react-contenteditable": ">=3.3.7",
|
|
28
|
+
"reselect": "^4.0.0 || ^5.0.0",
|
|
28
29
|
"styled-components": ">=5"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
@@ -39,6 +40,7 @@
|
|
|
39
40
|
"lodash": "^4.17.21",
|
|
40
41
|
"patch-package": "^8.0.1",
|
|
41
42
|
"polished": "^4.3.1",
|
|
43
|
+
"reselect": "^4.0.0 || ^5.0.0",
|
|
42
44
|
"rollup": "^2.79.2",
|
|
43
45
|
"rollup-plugin-auto-external": "^2.0.0",
|
|
44
46
|
"rollup-plugin-babel": "^4.0.3",
|
|
@@ -49,7 +51,7 @@
|
|
|
49
51
|
"scripts": {
|
|
50
52
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
51
53
|
"build": "rollup -c",
|
|
52
|
-
"
|
|
54
|
+
"prepare": "patch-package"
|
|
53
55
|
},
|
|
54
56
|
"repository": {
|
|
55
57
|
"type": "git",
|
|
@@ -67,8 +69,7 @@
|
|
|
67
69
|
"homepage": "https://github.com/felipeko/startlibs#readme",
|
|
68
70
|
"dependencies": {
|
|
69
71
|
"@babel/runtime": "^7.20.0",
|
|
70
|
-
"react-window": "^1.8.6"
|
|
71
|
-
"reselect": "^4.0.0 || ^5.0.0"
|
|
72
|
+
"react-window": "^1.8.6"
|
|
72
73
|
},
|
|
73
74
|
"files": [
|
|
74
75
|
"lib",
|
package/src/AutoComplete.jsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, {useEffect, useRef, useState} from 'react'
|
|
2
|
-
import
|
|
2
|
+
import ContentEditableModule from 'react-contenteditable'
|
|
3
3
|
import {useRefState, useToggle, useEnsureRef} from '@startlibs/core'
|
|
4
4
|
import {ContextMenu, Li, Loading, Icon} from '@startlibs/components'
|
|
5
5
|
import {Errors, useProvideErrors} from './Errors'
|
|
@@ -10,6 +10,9 @@ import {callIfFunction, stopPropagation, constrainEvent, getColor, media, custom
|
|
|
10
10
|
import styled, {css} from 'styled-components'
|
|
11
11
|
import {darken} from 'polished'
|
|
12
12
|
|
|
13
|
+
// Node/esbuild interop em .mjs devolve module.exports; Rollup devolve o default. Cobre os dois.
|
|
14
|
+
const ContentEditable = ContentEditableModule.default || ContentEditableModule
|
|
15
|
+
|
|
13
16
|
const ua = navigator.userAgent.toLowerCase();
|
|
14
17
|
const isSafari = ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0
|
|
15
18
|
|
package/src/RichText.jsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, {useContext, useEffect, useRef, useState} from 'react'
|
|
2
2
|
import styled, {css} from 'styled-components'
|
|
3
|
-
import
|
|
3
|
+
import ContentEditableModule from 'react-contenteditable'
|
|
4
4
|
import {darken} from 'polished'
|
|
5
5
|
import _ from 'lodash/fp'
|
|
6
6
|
import {getColor, linkRegex, stopPropagation} from '@startlibs/utils'
|
|
@@ -12,6 +12,9 @@ import {TextInput} from './TextInput'
|
|
|
12
12
|
import {useInput} from './enhanceInput'
|
|
13
13
|
import {Button, Icon} from '@startlibs/components'
|
|
14
14
|
|
|
15
|
+
// Node/esbuild interop em .mjs devolve module.exports; Rollup devolve o default. Cobre os dois.
|
|
16
|
+
const ContentEditable = ContentEditableModule.default || ContentEditableModule
|
|
17
|
+
|
|
15
18
|
const InputIcon = styled(Icon)`
|
|
16
19
|
position: absolute;
|
|
17
20
|
outline: none;
|
|
@@ -42,7 +42,7 @@ export const useDraftConfirmation = (submit, discard, meta) => {
|
|
|
42
42
|
|
|
43
43
|
const Dialog = startlibs.dialogs[dialog.isOpen]
|
|
44
44
|
if (process.env.NODE_ENV !== 'production') {
|
|
45
|
-
if (dialog.isOpen && !Dialog) { console.log(`Dialog [${
|
|
45
|
+
if (dialog.isOpen && !Dialog) { console.log(`Dialog [${dialog.isOpen}] not registered in startlibs.dialogs`) }
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
const feedback =
|