@reviewpush/rp-treeselect 0.0.0
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/README.md +172 -0
- package/dist/rp-treeselect.cjs.js +3656 -0
- package/dist/rp-treeselect.cjs.js.map +1 -0
- package/dist/rp-treeselect.cjs.min.js +2 -0
- package/dist/rp-treeselect.cjs.min.js.map +1 -0
- package/dist/rp-treeselect.css +947 -0
- package/dist/rp-treeselect.css.map +1 -0
- package/dist/rp-treeselect.min.css +1 -0
- package/dist/rp-treeselect.umd.js +4837 -0
- package/dist/rp-treeselect.umd.js.map +1 -0
- package/dist/rp-treeselect.umd.min.js +2 -0
- package/dist/rp-treeselect.umd.min.js.map +1 -0
- package/package.json +140 -0
- package/src/assets/checkbox-checked-disabled.png +0 -0
- package/src/assets/checkbox-checked-disabled@2x.png +0 -0
- package/src/assets/checkbox-checked-disabled@3x.png +0 -0
- package/src/assets/checkbox-checked.png +0 -0
- package/src/assets/checkbox-checked@2x.png +0 -0
- package/src/assets/checkbox-checked@3x.png +0 -0
- package/src/assets/checkbox-indeterminate-disabled.png +0 -0
- package/src/assets/checkbox-indeterminate-disabled@2x.png +0 -0
- package/src/assets/checkbox-indeterminate-disabled@3x.png +0 -0
- package/src/assets/checkbox-indeterminate.png +0 -0
- package/src/assets/checkbox-indeterminate@2x.png +0 -0
- package/src/assets/checkbox-indeterminate@3x.png +0 -0
- package/src/components/Control.vue +153 -0
- package/src/components/HiddenFields.vue +37 -0
- package/src/components/Input.vue +295 -0
- package/src/components/Menu.vue +313 -0
- package/src/components/MenuPortal.vue +179 -0
- package/src/components/MultiValue.vue +56 -0
- package/src/components/MultiValueItem.vue +45 -0
- package/src/components/Option.vue +300 -0
- package/src/components/Placeholder.vue +21 -0
- package/src/components/SingleValue.vue +34 -0
- package/src/components/Tip.vue +32 -0
- package/src/components/Treeselect.vue +42 -0
- package/src/components/icons/Arrow.vue +11 -0
- package/src/components/icons/Delete.vue +11 -0
- package/src/constants.js +50 -0
- package/src/index.js +14 -0
- package/src/mixins/treeselectMixin.js +1949 -0
- package/src/style.less +1147 -0
- package/src/utils/.eslintrc.js +6 -0
- package/src/utils/constant.js +1 -0
- package/src/utils/createMap.js +1 -0
- package/src/utils/debounce.js +1 -0
- package/src/utils/deepExtend.js +25 -0
- package/src/utils/find.js +6 -0
- package/src/utils/identity.js +1 -0
- package/src/utils/includes.js +3 -0
- package/src/utils/index.js +38 -0
- package/src/utils/isNaN.js +3 -0
- package/src/utils/isPromise.js +1 -0
- package/src/utils/last.js +1 -0
- package/src/utils/noop.js +1 -0
- package/src/utils/onLeftClick.js +7 -0
- package/src/utils/once.js +1 -0
- package/src/utils/quickDiff.js +9 -0
- package/src/utils/removeFromArray.js +4 -0
- package/src/utils/scrollIntoView.js +15 -0
- package/src/utils/setupResizeAndScrollEventListeners.js +34 -0
- package/src/utils/warning.js +11 -0
- package/src/utils/watchSize.js +67 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as constant } from 'lodash/constant'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const createMap = () => Object.create(null)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as debounce } from 'lodash/debounce'
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
function isPlainObject(value) {
|
|
2
|
+
if (value == null || typeof value !== 'object') return false
|
|
3
|
+
return Object.getPrototypeOf(value) === Object.prototype
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
function copy(obj, key, value) {
|
|
7
|
+
if (isPlainObject(value)) {
|
|
8
|
+
obj[key] || (obj[key] = {})
|
|
9
|
+
deepExtend(obj[key], value)
|
|
10
|
+
} else {
|
|
11
|
+
obj[key] = value
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function deepExtend(target, source) {
|
|
16
|
+
if (isPlainObject(source)) {
|
|
17
|
+
const keys = Object.keys(source)
|
|
18
|
+
|
|
19
|
+
for (let i = 0, len = keys.length; i < len; i++) {
|
|
20
|
+
copy(target, keys[i], source[keys[i]])
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return target
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as identity } from 'lodash/identity'
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// ========================
|
|
2
|
+
// Debugging Helpers
|
|
3
|
+
// ========================
|
|
4
|
+
|
|
5
|
+
export { warning } from './warning'
|
|
6
|
+
|
|
7
|
+
// ========================
|
|
8
|
+
// DOM Utilities
|
|
9
|
+
// ========================
|
|
10
|
+
|
|
11
|
+
export { onLeftClick } from './onLeftClick'
|
|
12
|
+
export { scrollIntoView } from './scrollIntoView'
|
|
13
|
+
export { debounce } from './debounce'
|
|
14
|
+
export { watchSize } from './watchSize'
|
|
15
|
+
export { setupResizeAndScrollEventListeners } from './setupResizeAndScrollEventListeners'
|
|
16
|
+
|
|
17
|
+
// ========================
|
|
18
|
+
// Language Helpers
|
|
19
|
+
// ========================
|
|
20
|
+
|
|
21
|
+
export { isNaN } from './isNaN'
|
|
22
|
+
export { isPromise } from './isPromise'
|
|
23
|
+
export { once } from './once'
|
|
24
|
+
export { noop } from './noop'
|
|
25
|
+
export { identity } from './identity'
|
|
26
|
+
export { constant } from './constant'
|
|
27
|
+
export { createMap } from './createMap'
|
|
28
|
+
export { deepExtend } from './deepExtend'
|
|
29
|
+
export { last } from './last'
|
|
30
|
+
export { includes } from './includes'
|
|
31
|
+
export { find } from './find'
|
|
32
|
+
export { removeFromArray } from './removeFromArray'
|
|
33
|
+
|
|
34
|
+
// ========================
|
|
35
|
+
// Other Utilities
|
|
36
|
+
// ========================
|
|
37
|
+
|
|
38
|
+
export { quickDiff } from './quickDiff'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as isPromise } from 'is-promise'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as last } from 'lodash/last'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as noop } from 'lodash/noop'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as once } from 'lodash/once'
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// from react-select
|
|
2
|
+
export function scrollIntoView($scrollingEl, $focusedEl) {
|
|
3
|
+
const scrollingReact = $scrollingEl.getBoundingClientRect()
|
|
4
|
+
const focusedRect = $focusedEl.getBoundingClientRect()
|
|
5
|
+
const overScroll = $focusedEl.offsetHeight / 3
|
|
6
|
+
|
|
7
|
+
if (focusedRect.bottom + overScroll > scrollingReact.bottom) {
|
|
8
|
+
$scrollingEl.scrollTop = Math.min(
|
|
9
|
+
$focusedEl.offsetTop + $focusedEl.clientHeight - $scrollingEl.offsetHeight + overScroll,
|
|
10
|
+
$scrollingEl.scrollHeight,
|
|
11
|
+
)
|
|
12
|
+
} else if (focusedRect.top - overScroll < scrollingReact.top) {
|
|
13
|
+
$scrollingEl.scrollTop = Math.max($focusedEl.offsetTop - overScroll, 0)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
function findScrollParents($el) {
|
|
2
|
+
const $scrollParents = []
|
|
3
|
+
let $parent = $el.parentNode
|
|
4
|
+
|
|
5
|
+
while ($parent && $parent.nodeName !== 'BODY' && $parent.nodeType === document.ELEMENT_NODE) {
|
|
6
|
+
if (isScrollElment($parent)) $scrollParents.push($parent)
|
|
7
|
+
$parent = $parent.parentNode
|
|
8
|
+
}
|
|
9
|
+
$scrollParents.push(window)
|
|
10
|
+
|
|
11
|
+
return $scrollParents
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function isScrollElment($el) {
|
|
15
|
+
// Firefox wants us to check `-x` and `-y` variations as well
|
|
16
|
+
const { overflow, overflowX, overflowY } = getComputedStyle($el)
|
|
17
|
+
return /(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function setupResizeAndScrollEventListeners($el, listener) {
|
|
21
|
+
const $scrollParents = findScrollParents($el)
|
|
22
|
+
|
|
23
|
+
window.addEventListener('resize', listener, { passive: true })
|
|
24
|
+
$scrollParents.forEach(scrollParent => {
|
|
25
|
+
scrollParent.addEventListener('scroll', listener, { passive: true })
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
return function removeEventListeners() {
|
|
29
|
+
window.removeEventListener('resize', listener, { passive: true })
|
|
30
|
+
$scrollParents.forEach($scrollParent => {
|
|
31
|
+
$scrollParent.removeEventListener('scroll', listener, { passive: true })
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { noop } from './noop'
|
|
2
|
+
|
|
3
|
+
export const warning = process.env.NODE_ENV === 'production'
|
|
4
|
+
? /* istanbul ignore next */ noop
|
|
5
|
+
: function warning(checker, complainer) {
|
|
6
|
+
if (!checker()) {
|
|
7
|
+
const message = [ '[Rp-Treeselect Warning]' ].concat(complainer())
|
|
8
|
+
// eslint-disable-next-line no-console
|
|
9
|
+
console.error(...message)
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import watchSizeForBrowsersOtherThanIE9 from 'watch-size'
|
|
2
|
+
import { removeFromArray } from './removeFromArray'
|
|
3
|
+
|
|
4
|
+
let intervalId
|
|
5
|
+
const registered = []
|
|
6
|
+
const INTERVAL_DURATION = 100
|
|
7
|
+
|
|
8
|
+
function run() {
|
|
9
|
+
intervalId = setInterval(() => {
|
|
10
|
+
registered.forEach(test)
|
|
11
|
+
}, INTERVAL_DURATION)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function stop() {
|
|
15
|
+
clearInterval(intervalId)
|
|
16
|
+
intervalId = null
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function test(item) {
|
|
20
|
+
const { $el, listener, lastWidth, lastHeight } = item
|
|
21
|
+
const width = $el.offsetWidth
|
|
22
|
+
const height = $el.offsetHeight
|
|
23
|
+
|
|
24
|
+
if (lastWidth !== width || lastHeight !== height) {
|
|
25
|
+
item.lastWidth = width
|
|
26
|
+
item.lastHeight = height
|
|
27
|
+
|
|
28
|
+
listener({ width, height })
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function watchSizeForIE9($el, listener) {
|
|
33
|
+
const item = {
|
|
34
|
+
$el,
|
|
35
|
+
listener,
|
|
36
|
+
lastWidth: null,
|
|
37
|
+
lastHeight: null,
|
|
38
|
+
}
|
|
39
|
+
const unwatch = () => {
|
|
40
|
+
removeFromArray(registered, item)
|
|
41
|
+
if (!registered.length) stop()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
registered.push(item)
|
|
45
|
+
// The original watch-size will call the listener on initialization.
|
|
46
|
+
// Keep the same behavior here.
|
|
47
|
+
test(item)
|
|
48
|
+
run()
|
|
49
|
+
|
|
50
|
+
return unwatch
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function watchSize($el, listener) {
|
|
54
|
+
// See: https://stackoverflow.com/a/31293352
|
|
55
|
+
const isIE9 = document.documentMode === 9
|
|
56
|
+
// watch-size will call the listener on initialization.
|
|
57
|
+
// Disable this behavior with a lock to achieve a clearer code logic.
|
|
58
|
+
let locked = true
|
|
59
|
+
const wrappedListener = (...args) => locked || listener(...args)
|
|
60
|
+
const implementation = isIE9
|
|
61
|
+
? watchSizeForIE9
|
|
62
|
+
: watchSizeForBrowsersOtherThanIE9
|
|
63
|
+
const removeSizeWatcher = implementation($el, wrappedListener)
|
|
64
|
+
locked = false // unlock after initialization
|
|
65
|
+
|
|
66
|
+
return removeSizeWatcher
|
|
67
|
+
}
|