From 562843e56062ea2df66e6d145791caf7b5651828 Mon Sep 17 00:00:00 2001 From: 07akioni <07akioni2@gmail.com> Date: Wed, 4 Nov 2020 12:31:43 +0800 Subject: [PATCH] chore: update utils paths --- README.md | 2 +- .../select-menu/src/styles/themed-size.js | 3 +- .../{composition => composable}/index.js | 0 src/_utils/cssr/index.js | 2 +- .../delegate/mutationObserverDelegate.js | 55 ------------------- src/_utils/index.js | 2 +- src/anchor/src/BaseAnchor.vue | 2 +- src/anchor/src/Link.vue | 2 +- src/avatar/src/styles/themed-size.cssr.js | 3 +- src/collapse/src/CollapseItem.vue | 2 +- src/dropdown/src/DropdownOption.js | 2 +- src/form/src/styles/themed-size.cssr.js | 3 +- src/input/src/styles/themed-size.cssr.js | 3 +- src/menu/src/MenuItem.vue | 2 +- src/menu/src/Submenu.js | 2 +- src/popover/src/styles/themed-base.cssr.js | 3 +- src/progress/src/Progress.vue | 2 +- src/slider/src/styles/themed-base.cssr.js | 3 +- .../src/styles/steps/themed-base.cssr.js | 3 +- src/tabs/src/Tabs.vue | 2 +- src/tag/src/styles/themed-size.cssr.js | 3 +- src/transfer/src/styles/themed-size.cssr.js | 4 +- 22 files changed, 20 insertions(+), 85 deletions(-) rename src/_utils/{composition => composable}/index.js (100%) delete mode 100644 src/_utils/delegate/mutationObserverDelegate.js diff --git a/README.md b/README.md index 75351bfdd..4b48d545b 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ ## Features ### Caring About Styles As is. -> The reason I started to build the library is I'm not satisfied with the UI framework I used. I think maybe it's possible to caring about nearily all the details of an UI framework, except the compatibility of IE. +> The reason I started to build the library is I'm not satisfied with the UI framework I used. I think maybe it's possible to caring about nearily all the details of an UI framework, except the compitability of IE. ### Themed Dark theme included. Theme switching is seamlessly. > At first there's only dark mode UI design drafts. It's wired but true. After you starting to build a dark mode UI, sooner or later you will have to create a light theme for it. As a result, naive-ui has both of them. diff --git a/src/_base/select-menu/src/styles/themed-size.js b/src/_base/select-menu/src/styles/themed-size.js index 426daf6bd..ddd8ffb01 100644 --- a/src/_base/select-menu/src/styles/themed-size.js +++ b/src/_base/select-menu/src/styles/themed-size.js @@ -1,6 +1,5 @@ import { cTB, c, cB, cM, createKey } from '../../../../_utils/cssr' -import depx from '../../../../_utils/css/depx' -import pxfy from '../../../../_utils/css/pxfy' +import { depx, pxfy } from '../../../../_utils/css' export default c([ ({ props }) => { diff --git a/src/_utils/composition/index.js b/src/_utils/composable/index.js similarity index 100% rename from src/_utils/composition/index.js rename to src/_utils/composable/index.js diff --git a/src/_utils/cssr/index.js b/src/_utils/cssr/index.js index 98efae4f0..be33f4c3a 100644 --- a/src/_utils/cssr/index.js +++ b/src/_utils/cssr/index.js @@ -22,7 +22,7 @@ function insideFormItem (status, style) { if (status === null) return style return c(`${prefix}form-item`, [ c(`${prefix}form-item-blank`, [ - c(({ props }) => `&${prefix}form-item-blank${modifierPrefix}${status}`, [ + c(() => `&${prefix}form-item-blank${modifierPrefix}${status}`, [ style ]) ]) diff --git a/src/_utils/delegate/mutationObserverDelegate.js b/src/_utils/delegate/mutationObserverDelegate.js deleted file mode 100644 index 08d692b8d..000000000 --- a/src/_utils/delegate/mutationObserverDelegate.js +++ /dev/null @@ -1,55 +0,0 @@ -class MutationObserverDelegate { - constructor () { - if (__DEV__) { - console.debug('[MutationObserverDelegate]: Ctor called') - } - this.handlers = new Map() - this.observers = new Map() - this.handleMutation = this.handleMutation.bind(this) - } - - handleMutation (mutationList) { - for (const mutationRecord of mutationList) { - const handlers = this.handlers.get(mutationRecord.target) - if (handlers) { - for (const handler of handlers) { - handler() - } - } - } - } - - unregisterHandler (el, handler) { - const handlers = this.handlers.get(el) - if (handlers) { - const handlerIndex = handlers.findIndex(h => handler === h) - if (~handlerIndex) { - handlers.splice(handlerIndex, 1) - } - if (!handler.length) { - this.handlers.delete(el) - const observer = this.observers.get(el) - if (observer) this.observer.disconnect() - this.observers.delete(el) - } - } - } - - registerHandler (el, handler) { - if (this.handlers.get(el)) { - this.handlers.get(el).push(handler) - } else { - const observer = new MutationObserver(mutationList => { - this.handleMutation(mutationList) - }) - this.observers.set(el, observer) - this.handlers.set(el, [handler]) - observer.observe(el, { - attributes: true, - attributeFilter: ['class'] - }) - } - } -} - -export default new MutationObserverDelegate() diff --git a/src/_utils/index.js b/src/_utils/index.js index 91867e373..8106f8112 100644 --- a/src/_utils/index.js +++ b/src/_utils/index.js @@ -16,7 +16,7 @@ export { depx, formatLength } from './css' -export * from './composition' +export * from './composable' export { nextFrame } from './misc' diff --git a/src/anchor/src/BaseAnchor.vue b/src/anchor/src/BaseAnchor.vue index e91c8b7c5..106b58259 100644 --- a/src/anchor/src/BaseAnchor.vue +++ b/src/anchor/src/BaseAnchor.vue @@ -31,7 +31,7 @@ import { themeable, usecssr } from '../../_mixins' -import { onFontReady } from '../../_utils/composition/index' +import { onFontReady } from '../../_utils/composable/index' import { warn } from '../../_utils/naive/warn' import getTarget from '../../_utils/dom/get-target' import styles from './styles' diff --git a/src/anchor/src/Link.vue b/src/anchor/src/Link.vue index f3a07ab10..6d61d67c9 100644 --- a/src/anchor/src/Link.vue +++ b/src/anchor/src/Link.vue @@ -24,7 +24,7 @@ import { useInjectionRef, useInjectionCollection, useInjectionElementCollection -} from '../../_utils/composition' +} from '../../_utils/composable' export default { name: 'AnchorLink', diff --git a/src/avatar/src/styles/themed-size.cssr.js b/src/avatar/src/styles/themed-size.cssr.js index 7a00eaf6f..1c6e7dc6a 100644 --- a/src/avatar/src/styles/themed-size.cssr.js +++ b/src/avatar/src/styles/themed-size.cssr.js @@ -1,6 +1,5 @@ import { c, cE, cM, cTB, cB } from '../../../_utils/cssr' -import depx from '../../../_utils/css/depx' -import pxfy from '../../../_utils/css/pxfy' +import { depx, pxfy } from '../../../../_utils/css' export default c([ ({ props }) => { diff --git a/src/collapse/src/CollapseItem.vue b/src/collapse/src/CollapseItem.vue index fd6a58449..28286c5c7 100644 --- a/src/collapse/src/CollapseItem.vue +++ b/src/collapse/src/CollapseItem.vue @@ -41,7 +41,7 @@ import { toRef } from 'vue' import NIcon from '../../icon' import { ChevronRightIcon as ArrowIcon } from '../../_base/icons' import NCollapseItemContent from './CollapseItemContent.js' -import { useInjectionCollection } from '../../_utils/composition' +import { useInjectionCollection } from '../../_utils/composable' export default { name: 'CollapseItem', diff --git a/src/dropdown/src/DropdownOption.js b/src/dropdown/src/DropdownOption.js index f41ed6131..35b230761 100644 --- a/src/dropdown/src/DropdownOption.js +++ b/src/dropdown/src/DropdownOption.js @@ -4,7 +4,7 @@ import { placeable } from '../../_mixins' import { ChevronRightIcon } from '../../_base/icons' import NIcon from '../../icon' import { useMemo } from 'vooks' -import { useDelayedTrue } from '../../_utils/composition' +import { useDelayedTrue } from '../../_utils/composable' import NDropdownMenu from './DropdownMenu' import { isSubmenuNode } from './utils' diff --git a/src/form/src/styles/themed-size.cssr.js b/src/form/src/styles/themed-size.cssr.js index 505cc7062..497708543 100644 --- a/src/form/src/styles/themed-size.cssr.js +++ b/src/form/src/styles/themed-size.cssr.js @@ -1,6 +1,5 @@ import { c, cB, cM, createKey } from '../../../_utils/cssr' -import depx from '../../../_utils/css/depx' -import pxfy from '../../../_utils/css/pxfy' +import { depx, pxfy } from '../../../../_utils/css' export default c([ ({ props }) => { diff --git a/src/input/src/styles/themed-size.cssr.js b/src/input/src/styles/themed-size.cssr.js index 22644be36..5b9246b17 100644 --- a/src/input/src/styles/themed-size.cssr.js +++ b/src/input/src/styles/themed-size.cssr.js @@ -1,6 +1,5 @@ import { cTB, c, cE, cM, cNotM, createKey } from '../../../_utils/cssr' -import depx from '../../../_utils/css/depx' -import pxfy from '../../../_utils/css/pxfy' +import { depx, pxfy } from '../../../_utils/css' export default c([ ({ props }) => { diff --git a/src/menu/src/MenuItem.vue b/src/menu/src/MenuItem.vue index 7189354ac..1a8b28ee6 100644 --- a/src/menu/src/MenuItem.vue +++ b/src/menu/src/MenuItem.vue @@ -34,7 +34,7 @@ import NMenuItemContent from './MenuItemContent.vue' import NTooltip from '../../tooltip' import menuChildMixin from './menu-child-mixin' import { useMemo } from 'vooks' -import { useInjectionRef } from '../../_utils/composition' +import { useInjectionRef } from '../../_utils/composable' export default { name: 'MenuItem', diff --git a/src/menu/src/Submenu.js b/src/menu/src/Submenu.js index 314c05bf5..fe3e35f25 100644 --- a/src/menu/src/Submenu.js +++ b/src/menu/src/Submenu.js @@ -5,7 +5,7 @@ import NMenuItemContent from './MenuItemContent.vue' import menuChildMixin from './menu-child-mixin' import { itemRenderer } from './utils' import { useMemo } from 'vooks' -import { useInjectionRef } from '../../_utils/composition' +import { useInjectionRef } from '../../_utils/composable' export default { name: 'Submenu', diff --git a/src/popover/src/styles/themed-base.cssr.js b/src/popover/src/styles/themed-base.cssr.js index d7101650c..e99cf6cc2 100644 --- a/src/popover/src/styles/themed-base.cssr.js +++ b/src/popover/src/styles/themed-base.cssr.js @@ -1,6 +1,5 @@ import { c, cTB, cB, cM } from '../../../_utils/cssr' -import depx from '../../../_utils/css/depx' -import pxfy from '../../../_utils/css/pxfy' +import { depx, pxfy } from '../../../../_utils/css' export default c([ ({ props }) => { diff --git a/src/progress/src/Progress.vue b/src/progress/src/Progress.vue index 524a59982..67c98189b 100644 --- a/src/progress/src/Progress.vue +++ b/src/progress/src/Progress.vue @@ -251,7 +251,7 @@ import { } from '../../_mixins' import styles from './styles/index.js' import formatLength from '../../_utils/css/formatLength.js' -import { onFontReady } from '../../_utils/composition' +import { onFontReady } from '../../_utils/composable' function circlePath (r, sw, vw = 100) { return `m ${vw / 2} ${vw / 2 - r} a ${r} ${r} 0 1 1 0 ${2 * r} a ${r} ${r} 0 1 1 0 -${2 * r}` diff --git a/src/slider/src/styles/themed-base.cssr.js b/src/slider/src/styles/themed-base.cssr.js index d995d6278..2feb16d9b 100644 --- a/src/slider/src/styles/themed-base.cssr.js +++ b/src/slider/src/styles/themed-base.cssr.js @@ -1,7 +1,6 @@ import { cTB, c, cB, cM, cE } from '../../../_utils/cssr' import fadeInScaleUpTransition from '../../../_styles/transitions/fade-in-scale-up' -import pxfy from '../../../_utils/css/pxfy' -import depx from '../../../_utils/css/depx' +import { depx, pxfy } from '../../../_utils/css' export default c([ ({ props }) => { diff --git a/src/steps/src/styles/steps/themed-base.cssr.js b/src/steps/src/styles/steps/themed-base.cssr.js index 447ec4ac1..a88f7e661 100644 --- a/src/steps/src/styles/steps/themed-base.cssr.js +++ b/src/steps/src/styles/steps/themed-base.cssr.js @@ -1,6 +1,5 @@ import { c, cTB, cB, cE, cM, createKey } from '../../../../_utils/cssr' -import depx from '../../../../_utils/css/depx' -import pxfy from '../../../../_utils/css/pxfy' +import { depx, pxfy } from '../../../../_utils/css' import iconSwitchTransition from '../../../../_styles/transitions/icon-switch' export default c([ diff --git a/src/tabs/src/Tabs.vue b/src/tabs/src/Tabs.vue index 6e2c505a3..ed940f77d 100644 --- a/src/tabs/src/Tabs.vue +++ b/src/tabs/src/Tabs.vue @@ -107,7 +107,7 @@ import { throttle } from 'lodash-es' import styles from './styles' import { warn } from '../../_utils/naive/warn' import { useCompitable } from 'vooks' -import { onFontReady } from '../../_utils/composition' +import { onFontReady } from '../../_utils/composable' export default { name: 'Tabs', diff --git a/src/tag/src/styles/themed-size.cssr.js b/src/tag/src/styles/themed-size.cssr.js index fefe00c33..2dd75b8ab 100644 --- a/src/tag/src/styles/themed-size.cssr.js +++ b/src/tag/src/styles/themed-size.cssr.js @@ -1,6 +1,5 @@ import { c, cE, cM, cTB } from '../../../_utils/cssr' -import depx from '../../../_utils/css/depx' -import pxfy from '../../../_utils/css/pxfy' +import { depx, pxfy } from '../../../_utils/css' export default c([ ({ props }) => { diff --git a/src/transfer/src/styles/themed-size.cssr.js b/src/transfer/src/styles/themed-size.cssr.js index c0a87b730..1fb533eeb 100644 --- a/src/transfer/src/styles/themed-size.cssr.js +++ b/src/transfer/src/styles/themed-size.cssr.js @@ -1,7 +1,5 @@ import { c, cTB, cB, cM, createKey } from '../../../_utils/cssr' -import depx from '../../../_utils/css/depx' -import pxfy from '../../../_utils/css/pxfy' - +import { depx, pxfy } from '../../../_utils/css' export default c([ ({ props }) => { const size = props.$instance.mergedSize