@symbo.ls/button 0.4.2 → 0.5.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 +8 -2
- package/packages/react/index.js +7 -0
- package/packages/react/node_modules/.yarn-integrity +91 -0
- package/packages/react/node_modules/@domql/cache/LICENSE +21 -0
- package/packages/react/node_modules/@domql/cache/index.js +0 -0
- package/packages/react/node_modules/@domql/cache/package.json +10 -0
- package/packages/react/node_modules/@domql/cookie/LICENSE +21 -0
- package/packages/react/node_modules/@domql/cookie/index.js +22 -0
- package/packages/react/node_modules/@domql/cookie/package.json +10 -0
- package/packages/react/node_modules/@domql/define/LICENSE +21 -0
- package/packages/react/node_modules/@domql/define/index.js +13 -0
- package/packages/react/node_modules/@domql/define/package.json +11 -0
- package/packages/react/node_modules/@domql/domql/LICENSE +21 -0
- package/packages/react/node_modules/@domql/domql/package.json +33 -0
- package/packages/react/node_modules/@domql/domql/src/all_exports.js +17 -0
- package/packages/react/node_modules/@domql/domql/src/index.js +15 -0
- package/packages/react/node_modules/@domql/element/LICENSE +21 -0
- package/packages/react/node_modules/@domql/element/package.json +20 -0
- package/packages/react/node_modules/@domql/element/src/assign.js +22 -0
- package/packages/react/node_modules/@domql/element/src/create.js +125 -0
- package/packages/react/node_modules/@domql/element/src/index.js +8 -0
- package/packages/react/node_modules/@domql/element/src/iterate.js +80 -0
- package/packages/react/node_modules/@domql/element/src/methods.js +96 -0
- package/packages/react/node_modules/@domql/element/src/set.js +44 -0
- package/packages/react/node_modules/@domql/element/src/update.js +98 -0
- package/packages/react/node_modules/@domql/event/LICENSE +21 -0
- package/packages/react/node_modules/@domql/event/package.json +14 -0
- package/packages/react/node_modules/@domql/event/src/can.js +10 -0
- package/packages/react/node_modules/@domql/event/src/index.js +11 -0
- package/packages/react/node_modules/@domql/event/src/is.js +13 -0
- package/packages/react/node_modules/@domql/event/src/on.js +33 -0
- package/packages/react/node_modules/@domql/event/src/store.js +6 -0
- package/packages/react/node_modules/@domql/event/src/wrappers.js +14 -0
- package/packages/react/node_modules/@domql/event/yarn-error.log +44 -0
- package/packages/react/node_modules/@domql/id/LICENSE +21 -0
- package/packages/react/node_modules/@domql/id/index.js +12 -0
- package/packages/react/node_modules/@domql/id/package.json +10 -0
- package/packages/react/node_modules/@domql/mixins/LICENSE +21 -0
- package/packages/react/node_modules/@domql/mixins/package.json +12 -0
- package/packages/react/node_modules/@domql/mixins/src/attr.js +19 -0
- package/packages/react/node_modules/@domql/mixins/src/classList.js +37 -0
- package/packages/react/node_modules/@domql/mixins/src/content.js +17 -0
- package/packages/react/node_modules/@domql/mixins/src/data.js +21 -0
- package/packages/react/node_modules/@domql/mixins/src/html.js +17 -0
- package/packages/react/node_modules/@domql/mixins/src/index.js +11 -0
- package/packages/react/node_modules/@domql/mixins/src/registry.js +55 -0
- package/packages/react/node_modules/@domql/mixins/src/state.js +16 -0
- package/packages/react/node_modules/@domql/mixins/src/style.js +14 -0
- package/packages/react/node_modules/@domql/mixins/src/text.js +19 -0
- package/packages/react/node_modules/@domql/node/LICENSE +21 -0
- package/packages/react/node_modules/@domql/node/package.json +17 -0
- package/packages/react/node_modules/@domql/node/src/cache.js +52 -0
- package/packages/react/node_modules/@domql/node/src/create.js +86 -0
- package/packages/react/node_modules/@domql/node/src/index.js +5 -0
- package/packages/react/node_modules/@domql/node/src/registry.js +139 -0
- package/packages/react/node_modules/@domql/parse/LICENSE +21 -0
- package/packages/react/node_modules/@domql/parse/index.js +16 -0
- package/packages/react/node_modules/@domql/parse/package.json +10 -0
- package/packages/react/node_modules/@domql/props/LICENSE +21 -0
- package/packages/react/node_modules/@domql/props/package.json +10 -0
- package/packages/react/node_modules/@domql/props/src/index.js +62 -0
- package/packages/react/node_modules/@domql/proto/LICENSE +21 -0
- package/packages/react/node_modules/@domql/proto/index.js +66 -0
- package/packages/react/node_modules/@domql/proto/package.json +10 -0
- package/packages/react/node_modules/@domql/react-transformer/LICENSE +21 -0
- package/packages/react/node_modules/@domql/react-transformer/index.js +26 -0
- package/packages/react/node_modules/@domql/react-transformer/package.json +12 -0
- package/packages/react/node_modules/@domql/react-transformer/yarn-error.log +41 -0
- package/packages/react/node_modules/@domql/report/LICENSE +21 -0
- package/packages/react/node_modules/@domql/report/index.js +62 -0
- package/packages/react/node_modules/@domql/report/package.json +7 -0
- package/packages/react/node_modules/@domql/state/LICENSE +21 -0
- package/packages/react/node_modules/@domql/state/package.json +11 -0
- package/packages/react/node_modules/@domql/state/src/index.js +51 -0
- package/packages/react/node_modules/@domql/tree/LICENSE +21 -0
- package/packages/react/node_modules/@domql/tree/index.js +6 -0
- package/packages/react/node_modules/@domql/tree/package.json +10 -0
- package/packages/react/node_modules/@domql/tree/root.js +8 -0
- package/packages/react/node_modules/@domql/utils/LICENSE +21 -0
- package/packages/react/node_modules/@domql/utils/package.json +13 -0
- package/packages/react/node_modules/@domql/utils/src/index.js +5 -0
- package/packages/react/node_modules/@domql/utils/src/node.js +10 -0
- package/packages/react/node_modules/@domql/utils/src/object.js +193 -0
- package/packages/react/node_modules/@domql/utils/src/protoUtils.js +119 -0
- package/packages/react/node_modules/js-tokens/CHANGELOG.md +151 -0
- package/packages/react/node_modules/js-tokens/LICENSE +21 -0
- package/packages/react/node_modules/js-tokens/README.md +240 -0
- package/packages/react/node_modules/js-tokens/index.js +23 -0
- package/packages/react/node_modules/js-tokens/package.json +30 -0
- package/packages/react/node_modules/loose-envify/LICENSE +21 -0
- package/packages/react/node_modules/loose-envify/README.md +45 -0
- package/packages/react/node_modules/loose-envify/cli.js +16 -0
- package/packages/react/node_modules/loose-envify/custom.js +4 -0
- package/packages/react/node_modules/loose-envify/index.js +3 -0
- package/packages/react/node_modules/loose-envify/loose-envify.js +36 -0
- package/packages/react/node_modules/loose-envify/package.json +36 -0
- package/packages/react/node_modules/loose-envify/replace.js +65 -0
- package/packages/react/node_modules/object-assign/index.js +90 -0
- package/packages/react/node_modules/object-assign/license +21 -0
- package/packages/react/node_modules/object-assign/package.json +42 -0
- package/packages/react/node_modules/object-assign/readme.md +61 -0
- package/packages/react/node_modules/react/LICENSE +21 -0
- package/packages/react/node_modules/react/README.md +13 -0
- package/packages/react/node_modules/react/build-info.json +8 -0
- package/packages/react/node_modules/react/cjs/react-jsx-dev-runtime.development.js +1203 -0
- package/packages/react/node_modules/react/cjs/react-jsx-dev-runtime.production.min.js +9 -0
- package/packages/react/node_modules/react/cjs/react-jsx-dev-runtime.profiling.min.js +9 -0
- package/packages/react/node_modules/react/cjs/react-jsx-runtime.development.js +1221 -0
- package/packages/react/node_modules/react/cjs/react-jsx-runtime.production.min.js +10 -0
- package/packages/react/node_modules/react/cjs/react-jsx-runtime.profiling.min.js +10 -0
- package/packages/react/node_modules/react/cjs/react.development.js +2333 -0
- package/packages/react/node_modules/react/cjs/react.production.min.js +23 -0
- package/packages/react/node_modules/react/index.js +7 -0
- package/packages/react/node_modules/react/jsx-dev-runtime.js +7 -0
- package/packages/react/node_modules/react/jsx-runtime.js +7 -0
- package/packages/react/node_modules/react/package.json +39 -0
- package/packages/react/node_modules/react/umd/react.development.js +3357 -0
- package/packages/react/node_modules/react/umd/react.production.min.js +31 -0
- package/packages/react/node_modules/react/umd/react.profiling.min.js +36 -0
- package/packages/react/node_modules/regenerator-runtime/LICENSE +21 -0
- package/packages/react/node_modules/regenerator-runtime/README.md +31 -0
- package/packages/react/node_modules/regenerator-runtime/package.json +19 -0
- package/packages/react/node_modules/regenerator-runtime/path.js +11 -0
- package/packages/react/node_modules/regenerator-runtime/runtime.js +754 -0
- package/packages/react/package.json +6 -2
- package/packages/react/yarn.lock +183 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 rackai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
import React, { useEffect, useRef } from 'react'
|
|
4
|
+
import { create } from '@domql/element'
|
|
5
|
+
import { clone } from '@domql/utils'
|
|
6
|
+
|
|
7
|
+
export function DOMQLRenderer (component, parent, props) {
|
|
8
|
+
create({
|
|
9
|
+
proto: component,
|
|
10
|
+
props: clone(props)
|
|
11
|
+
}, parent)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const reactTransformer = (component, props, state) => {
|
|
15
|
+
const ref = useRef(null)
|
|
16
|
+
return (
|
|
17
|
+
<React.Fragment ref={ref}>
|
|
18
|
+
{props.text}
|
|
19
|
+
{
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
DOMQLRenderer(component, ref.current, props)
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
</React.Fragment>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@domql/react-transformer",
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@domql/domql": "^1.3.0",
|
|
8
|
+
"@domql/utils": "^1.3.0",
|
|
9
|
+
"react": "^17.0.2"
|
|
10
|
+
},
|
|
11
|
+
"gitHead": "3140379c0f6da459a39068f32630275c6ea3b33f"
|
|
12
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
Arguments:
|
|
2
|
+
/Users/nikoloza/.nvm/versions/node/v14.17.1/bin/node /Users/nikoloza/.nvm/versions/node/v14.17.1/bin/yarn init
|
|
3
|
+
|
|
4
|
+
PATH:
|
|
5
|
+
/Users/nikoloza/.nvm/versions/node/v14.17.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Little Snitch.app/Contents/Components:/Library/Apple/usr/bin:/Users/nikoloza/.fzf/bin
|
|
6
|
+
|
|
7
|
+
Yarn version:
|
|
8
|
+
1.22.10
|
|
9
|
+
|
|
10
|
+
Node version:
|
|
11
|
+
14.17.1
|
|
12
|
+
|
|
13
|
+
Platform:
|
|
14
|
+
darwin x64
|
|
15
|
+
|
|
16
|
+
Trace:
|
|
17
|
+
Error: canceled
|
|
18
|
+
at Interface.<anonymous> (/Users/nikoloza/.nvm/versions/node/v14.17.1/lib/node_modules/yarn/lib/cli.js:136216:13)
|
|
19
|
+
at Interface.emit (events.js:375:28)
|
|
20
|
+
at Interface._ttyWrite (readline.js:910:16)
|
|
21
|
+
at ReadStream.onkeypress (readline.js:235:10)
|
|
22
|
+
at ReadStream.emit (events.js:375:28)
|
|
23
|
+
at emitKeys (internal/readline/utils.js:358:14)
|
|
24
|
+
at emitKeys.next (<anonymous>)
|
|
25
|
+
at ReadStream.onData (readline.js:1179:36)
|
|
26
|
+
at ReadStream.emit (events.js:375:28)
|
|
27
|
+
at addChunk (internal/streams/readable.js:290:12)
|
|
28
|
+
|
|
29
|
+
npm manifest:
|
|
30
|
+
{
|
|
31
|
+
"name": "@domql/react-transformer",
|
|
32
|
+
"version": "1.0.0",
|
|
33
|
+
"main": "index.js",
|
|
34
|
+
"license": "MIT"
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
yarn manifest:
|
|
38
|
+
No manifest
|
|
39
|
+
|
|
40
|
+
Lockfile:
|
|
41
|
+
No lockfile
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 rackai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
export const ERRORS_REGISTRY = {
|
|
4
|
+
en: {
|
|
5
|
+
DocumentNotDefined: {
|
|
6
|
+
title: 'Document is undefined',
|
|
7
|
+
description: 'To tweak with DOM, you should use browser.'
|
|
8
|
+
},
|
|
9
|
+
OverwriteToBuiltin: {
|
|
10
|
+
title: 'Overwriting to builtin method',
|
|
11
|
+
description: 'Overwriting a builtin method in the global define is not possible, please choose different name'
|
|
12
|
+
},
|
|
13
|
+
BrowserNotDefined: {
|
|
14
|
+
title: 'Can\'t recognize environment',
|
|
15
|
+
description: 'Environment should be browser application, that can run Javascript'
|
|
16
|
+
},
|
|
17
|
+
SetQuickPreferancesIsNotObject: {
|
|
18
|
+
title: 'Quick preferances object is required',
|
|
19
|
+
description: 'Please pass a plain object with "lang", "culture" and "area" properties'
|
|
20
|
+
},
|
|
21
|
+
InvalidParams: {
|
|
22
|
+
title: 'Params are invalid',
|
|
23
|
+
description: 'Please pass a plain object with "lang", "culture" and "area" properties'
|
|
24
|
+
},
|
|
25
|
+
CantCreateWithoutNode: {
|
|
26
|
+
title: 'You must provide node',
|
|
27
|
+
description: 'Can\'t create DOM element without setting node or text'
|
|
28
|
+
},
|
|
29
|
+
HTMLInvalidTag: {
|
|
30
|
+
title: 'Element tag name (or DOM nodeName) is invalid',
|
|
31
|
+
description: 'To create element, you must provide valid DOM node. See full list of them at here: http://www.w3schools.com/tags/'
|
|
32
|
+
},
|
|
33
|
+
HTMLInvalidAttr: {
|
|
34
|
+
title: 'Attibutes object is invalid',
|
|
35
|
+
description: 'Please pass a valid plain object to apply as an attributes for a DOM node'
|
|
36
|
+
},
|
|
37
|
+
HTMLInvalidData: {
|
|
38
|
+
title: 'Data object is invalid',
|
|
39
|
+
description: 'Please pass a valid plain object to apply as an dataset for a DOM node'
|
|
40
|
+
},
|
|
41
|
+
HTMLInvalidStyles: {
|
|
42
|
+
title: 'Styles object is invalid',
|
|
43
|
+
description: 'Please pass a valid plain object to apply as an style for a DOM node'
|
|
44
|
+
},
|
|
45
|
+
HTMLInvalidText: {
|
|
46
|
+
title: 'Text string is invalid',
|
|
47
|
+
description: 'Please pass a valid string to apply text to DOM node'
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const report = (err, arg, element) => {
|
|
53
|
+
const currentLang = 'en'
|
|
54
|
+
let errObj
|
|
55
|
+
if (err && typeof err === 'string') errObj = ERRORS_REGISTRY[currentLang][err]
|
|
56
|
+
|
|
57
|
+
return new Error(
|
|
58
|
+
`"${err}", "${arg}"\n\n`,
|
|
59
|
+
`${errObj.description}`,
|
|
60
|
+
element ? `\n\n${element}` : ''
|
|
61
|
+
)
|
|
62
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 rackai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
import { on } from '@domql/event'
|
|
4
|
+
import { deepClone, exec, isFunction, overwriteDeep } from '@domql/utils'
|
|
5
|
+
|
|
6
|
+
export const parseState = function () {
|
|
7
|
+
const state = this
|
|
8
|
+
const parseState = {}
|
|
9
|
+
for (const param in state) {
|
|
10
|
+
if (param !== '__element' && param !== 'update' && param !== 'parse') {
|
|
11
|
+
parseState[param] = state[param]
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return parseState
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const updateState = function (obj, options = {}) {
|
|
18
|
+
const state = this
|
|
19
|
+
const element = state.__element
|
|
20
|
+
|
|
21
|
+
// run `on.stateUpdated`
|
|
22
|
+
if (element.on && isFunction(element.on.initStateUpdated)) {
|
|
23
|
+
on.initStateUpdated(element.on.initStateUpdated, element, state)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
overwriteDeep(state, obj, ['update', 'parse', '__element'])
|
|
27
|
+
if (!options.preventUpdate) element.update()
|
|
28
|
+
|
|
29
|
+
// run `on.stateUpdated`
|
|
30
|
+
if (element.on && isFunction(element.on.stateUpdated)) {
|
|
31
|
+
on.stateUpdated(element.on.stateUpdated, element, state)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function createState (element, parent) {
|
|
36
|
+
let { state } = element
|
|
37
|
+
if (!state) return (parent && parent.state) || {}
|
|
38
|
+
if (isFunction(state)) state = exec(state, element)
|
|
39
|
+
|
|
40
|
+
state = deepClone(state, ['update', 'parse', '__element'])
|
|
41
|
+
state.__element = element
|
|
42
|
+
state.parse = parseState
|
|
43
|
+
state.update = updateState
|
|
44
|
+
|
|
45
|
+
// run `on.stateCreated`
|
|
46
|
+
if (element.on && isFunction(element.on.stateCreated)) {
|
|
47
|
+
on.stateCreated(element.on.stateCreated, element, element.state)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return state
|
|
51
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 rackai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 rackai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@domql/utils",
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"main": "src/index.js",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"vpatch": "npm version patch && npm publish --access public"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@domql/node": "^1.3.0"
|
|
11
|
+
},
|
|
12
|
+
"gitHead": "3140379c0f6da459a39068f32630275c6ea3b33f"
|
|
13
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
import { NODE_REGISTRY } from '@domql/node'
|
|
4
|
+
|
|
5
|
+
export const isValidHtmlTag = arg => NODE_REGISTRY.body.indexOf(arg)
|
|
6
|
+
|
|
7
|
+
export const isObject = arg => {
|
|
8
|
+
if (arg === null) return false
|
|
9
|
+
return (typeof arg === 'object') && (arg.constructor === Object)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const isString = arg => typeof arg === 'string'
|
|
13
|
+
|
|
14
|
+
export const isNumber = arg => typeof arg === 'number'
|
|
15
|
+
|
|
16
|
+
export const isFunction = arg => typeof arg === 'function'
|
|
17
|
+
|
|
18
|
+
export const isArray = arg => Array.isArray(arg)
|
|
19
|
+
|
|
20
|
+
export const isObjectLike = arg => {
|
|
21
|
+
if (arg === null) return false
|
|
22
|
+
// if (isArray(arg)) return false
|
|
23
|
+
return (typeof arg === 'object')
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const isNode = obj => {
|
|
27
|
+
return (
|
|
28
|
+
typeof window.Node === 'object'
|
|
29
|
+
? obj instanceof window.Node
|
|
30
|
+
: obj && typeof obj === 'object' && typeof obj.nodeType === 'number' && typeof obj.nodeName === 'string'
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const isHtmlElement = obj => {
|
|
35
|
+
return (
|
|
36
|
+
typeof window.HTMLElement === 'object'
|
|
37
|
+
? obj instanceof window.HTMLElement // DOM2
|
|
38
|
+
: obj && typeof obj === 'object' && obj !== null && obj.nodeType === 1 && typeof obj.nodeName === 'string'
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const isDefined = arg => {
|
|
43
|
+
return isObject(arg) ||
|
|
44
|
+
isObjectLike(arg) ||
|
|
45
|
+
isString(arg) ||
|
|
46
|
+
isNumber(arg) ||
|
|
47
|
+
isFunction(arg) ||
|
|
48
|
+
isArray(arg) ||
|
|
49
|
+
isObjectLike(arg)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const exec = (param, element, state) => {
|
|
53
|
+
if (isFunction(param)) return param(element, state || element.state)
|
|
54
|
+
return param
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const map = (obj, extention, element) => {
|
|
58
|
+
for (const e in extention) {
|
|
59
|
+
obj[e] = exec(extention[e], element)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const merge = (element, obj) => {
|
|
64
|
+
for (const e in obj) {
|
|
65
|
+
const elementProp = element[e]
|
|
66
|
+
const objProp = obj[e]
|
|
67
|
+
if (elementProp === undefined) {
|
|
68
|
+
element[e] = objProp
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return element
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export const deepMerge = (element, proto) => {
|
|
75
|
+
// console.groupCollapsed('deepMerge:')
|
|
76
|
+
for (const e in proto) {
|
|
77
|
+
const elementProp = element[e]
|
|
78
|
+
const protoProp = proto[e]
|
|
79
|
+
// const cachedProps = cache.props
|
|
80
|
+
if (e === 'parent' || e === 'props') continue
|
|
81
|
+
if (elementProp === undefined) {
|
|
82
|
+
element[e] = protoProp
|
|
83
|
+
} else if (isObjectLike(elementProp) && isObject(protoProp)) {
|
|
84
|
+
deepMerge(elementProp, protoProp)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// console.groupEnd('deepMerge:')
|
|
88
|
+
return element
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export const clone = obj => {
|
|
92
|
+
const o = {}
|
|
93
|
+
for (const prop in obj) {
|
|
94
|
+
if (prop === 'node') continue
|
|
95
|
+
o[prop] = obj[prop]
|
|
96
|
+
}
|
|
97
|
+
return o
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Deep cloning of object
|
|
102
|
+
*/
|
|
103
|
+
export const deepClone = (obj, excluding = ['parent', 'node', '__element', '__root']) => {
|
|
104
|
+
const o = {}
|
|
105
|
+
for (const prop in obj) {
|
|
106
|
+
if (excluding.indexOf(prop) > -1) continue
|
|
107
|
+
let objProp = obj[prop]
|
|
108
|
+
if (prop === 'proto' && isArray(objProp)) {
|
|
109
|
+
objProp = mergeArray(objProp)
|
|
110
|
+
}
|
|
111
|
+
if (isObjectLike(objProp)) {
|
|
112
|
+
o[prop] = deepClone(objProp)
|
|
113
|
+
} else o[prop] = objProp
|
|
114
|
+
}
|
|
115
|
+
return o
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Overwrites object properties with another
|
|
120
|
+
*/
|
|
121
|
+
export const overwrite = (element, params, options) => {
|
|
122
|
+
const changes = {}
|
|
123
|
+
|
|
124
|
+
for (const e in params) {
|
|
125
|
+
if (e === 'props') continue
|
|
126
|
+
|
|
127
|
+
const elementProp = element[e]
|
|
128
|
+
const paramsProp = params[e]
|
|
129
|
+
|
|
130
|
+
if (paramsProp) {
|
|
131
|
+
element.__cached[e] = changes[e] = elementProp
|
|
132
|
+
element[e] = paramsProp
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (options.cleanExec) delete element.__exec[e]
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return changes
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Overwrites DEEPly object properties with another
|
|
143
|
+
*/
|
|
144
|
+
export const overwriteDeep = (obj, params, excluding = ['node', '__root']) => {
|
|
145
|
+
for (const e in params) {
|
|
146
|
+
if (excluding.indexOf(e) > -1) continue
|
|
147
|
+
const objProp = obj[e]
|
|
148
|
+
const paramsProp = params[e]
|
|
149
|
+
if (isObjectLike(objProp) && isObjectLike(paramsProp)) {
|
|
150
|
+
overwriteDeep(objProp, paramsProp)
|
|
151
|
+
} else if (paramsProp !== undefined) {
|
|
152
|
+
obj[e] = paramsProp
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return obj
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Overwrites object properties with another
|
|
160
|
+
*/
|
|
161
|
+
export const mergeIfExisted = (a, b) => {
|
|
162
|
+
if (isObjectLike(a) && isObjectLike(b)) return deepMerge(a, b)
|
|
163
|
+
return a || b
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Merges array prototypes
|
|
168
|
+
*/
|
|
169
|
+
export const mergeArray = (arr) => {
|
|
170
|
+
return arr.reduce((a, c) => deepMerge(a, deepClone(c)), {})
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Merges array prototypes
|
|
175
|
+
*/
|
|
176
|
+
export const mergeAndCloneIfArray = obj => {
|
|
177
|
+
return isArray(obj) ? mergeArray(obj) : deepClone(obj)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Overwrites object properties with another
|
|
182
|
+
*/
|
|
183
|
+
export const flattenRecursive = (param, prop, stack = []) => {
|
|
184
|
+
const objectized = mergeAndCloneIfArray(param)
|
|
185
|
+
stack.push(objectized)
|
|
186
|
+
|
|
187
|
+
const protoOfProto = objectized[prop]
|
|
188
|
+
if (protoOfProto) flattenRecursive(protoOfProto, prop, stack)
|
|
189
|
+
|
|
190
|
+
delete objectized[prop]
|
|
191
|
+
|
|
192
|
+
return stack
|
|
193
|
+
}
|