@taiga-ui/cdk 2.50.2 → 2.52.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/bundles/taiga-ui-cdk-directives-copy-processor.umd.js +7 -7
- package/bundles/taiga-ui-cdk-directives-copy-processor.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-copy-processor.umd.min.js +1 -1
- package/bundles/taiga-ui-cdk-directives-copy-processor.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-overscroll.umd.js +4 -1
- package/bundles/taiga-ui-cdk-directives-overscroll.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-overscroll.umd.min.js +1 -1
- package/bundles/taiga-ui-cdk-directives-overscroll.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-exceptions.umd.js +39 -0
- package/bundles/taiga-ui-cdk-exceptions.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-exceptions.umd.min.js +1 -1
- package/bundles/taiga-ui-cdk-exceptions.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-utils-dom.umd.js +26 -0
- package/bundles/taiga-ui-cdk-utils-dom.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-utils-dom.umd.min.js +1 -1
- package/bundles/taiga-ui-cdk-utils-dom.umd.min.js.map +1 -1
- package/directives/copy-processor/taiga-ui-cdk-directives-copy-processor.metadata.json +1 -1
- package/esm2015/directives/copy-processor/copy-processor.directive.js +5 -4
- package/esm2015/directives/overscroll/overscroll.directive.js +5 -2
- package/esm2015/exceptions/invalid-day.exception.js +8 -1
- package/esm2015/exceptions/invalid-month.exception.js +8 -1
- package/esm2015/exceptions/invalid-year.exception.js +8 -1
- package/esm2015/utils/dom/get-selected-text.js +16 -0
- package/esm2015/utils/dom/index.js +3 -1
- package/esm2015/utils/dom/is-form-field.js +8 -0
- package/esm5/directives/copy-processor/copy-processor.directive.js +5 -4
- package/esm5/directives/overscroll/overscroll.directive.js +5 -2
- package/esm5/exceptions/invalid-day.exception.js +14 -1
- package/esm5/exceptions/invalid-month.exception.js +14 -1
- package/esm5/exceptions/invalid-year.exception.js +14 -1
- package/esm5/utils/dom/get-selected-text.js +17 -0
- package/esm5/utils/dom/index.js +3 -1
- package/esm5/utils/dom/is-form-field.js +8 -0
- package/exceptions/invalid-day.exception.d.ts +6 -0
- package/exceptions/invalid-month.exception.d.ts +6 -0
- package/exceptions/invalid-year.exception.d.ts +6 -0
- package/exceptions/taiga-ui-cdk-exceptions.metadata.json +1 -1
- package/fesm2015/taiga-ui-cdk-directives-copy-processor.js +4 -3
- package/fesm2015/taiga-ui-cdk-directives-copy-processor.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-overscroll.js +4 -1
- package/fesm2015/taiga-ui-cdk-directives-overscroll.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-exceptions.js +22 -1
- package/fesm2015/taiga-ui-cdk-exceptions.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-utils-dom.js +24 -1
- package/fesm2015/taiga-ui-cdk-utils-dom.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-copy-processor.js +4 -3
- package/fesm5/taiga-ui-cdk-directives-copy-processor.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-overscroll.js +4 -1
- package/fesm5/taiga-ui-cdk-directives-overscroll.js.map +1 -1
- package/fesm5/taiga-ui-cdk-exceptions.js +37 -1
- package/fesm5/taiga-ui-cdk-exceptions.js.map +1 -1
- package/fesm5/taiga-ui-cdk-utils-dom.js +25 -1
- package/fesm5/taiga-ui-cdk-utils-dom.js.map +1 -1
- package/package.json +1 -1
- package/schematics/ng-update/constants/modules.js +1 -0
- package/schematics/ng-update/constants/services.js +9 -0
- package/schematics/ng-update/constants/templates.d.ts +17 -0
- package/schematics/ng-update/constants/templates.js +32 -0
- package/schematics/ng-update/constants/types.js +30 -0
- package/schematics/ng-update/index.js +39 -4
- package/schematics/ng-update/steps/migrate-date-time.d.ts +1 -0
- package/schematics/ng-update/steps/migrate-date-time.js +152 -0
- package/schematics/ng-update/steps/migrate-progress.d.ts +3 -0
- package/schematics/ng-update/steps/migrate-progress.js +41 -0
- package/schematics/ng-update/steps/migrate-sliders/index.d.ts +2 -2
- package/schematics/ng-update/steps/migrate-sliders/index.js +3 -3
- package/schematics/ng-update/steps/migrate-sliders/migrate-input-range.d.ts +2 -2
- package/schematics/ng-update/steps/migrate-sliders/migrate-input-range.js +32 -27
- package/schematics/ng-update/steps/migrate-sliders/migrate-input-slider.d.ts +2 -2
- package/schematics/ng-update/steps/migrate-sliders/migrate-input-slider.js +30 -22
- package/schematics/ng-update/steps/migrate-templates.d.ts +2 -2
- package/schematics/ng-update/steps/migrate-templates.js +61 -21
- package/schematics/ng-update/steps/miscellaneous.js +2 -6
- package/schematics/ng-update/steps/replace-services.js +5 -1
- package/schematics/ng-update/steps/show-warnings.js +1 -1
- package/schematics/utils/colored-log.d.ts +2 -0
- package/schematics/utils/colored-log.js +10 -0
- package/schematics/utils/insert-todo.d.ts +2 -0
- package/schematics/utils/insert-todo.js +8 -0
- package/schematics/utils/templates/elements.d.ts +1 -0
- package/schematics/utils/templates/elements.js +9 -19
- package/schematics/utils/templates/ng-component-input-manipulations.js +2 -1
- package/utils/dom/get-selected-text.d.ts +9 -0
- package/utils/dom/index.d.ts +2 -0
- package/utils/dom/is-form-field.d.ts +1 -0
- package/utils/dom/taiga-ui-cdk-utils-dom.metadata.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taiga-ui-cdk-utils-dom.js","sources":["ng://@taiga-ui/cdk/utils/dom/can-scroll.ts","ng://@taiga-ui/cdk/utils/dom/contains-or-after.ts","ng://@taiga-ui/cdk/utils/dom/custom-event.ts","ng://@taiga-ui/cdk/utils/dom/get-actual-target.ts","ng://@taiga-ui/cdk/utils/dom/get-clipboard-data-text.ts","ng://@taiga-ui/cdk/utils/dom/get-closest-element.ts","ng://@taiga-ui/cdk/utils/dom/get-document-or-shadow-root.ts","ng://@taiga-ui/cdk/utils/dom/get-element-obscurers.ts","ng://@taiga-ui/cdk/utils/dom/get-element-offset.ts","ng://@taiga-ui/cdk/utils/dom/get-scroll-parent.ts","ng://@taiga-ui/cdk/utils/dom/is-current-target.ts","ng://@taiga-ui/cdk/utils/dom/is-inside-iframe.ts","ng://@taiga-ui/cdk/utils/dom/is-node-in.ts","ng://@taiga-ui/cdk/utils/dom/taiga-ui-cdk-utils-dom.ts"],"sourcesContent":["export function canScroll(\n element: Element,\n rootElement: Element,\n vertical: boolean,\n scrollEnd: boolean,\n): boolean {\n return vertical\n ? canScrollVertical(element, rootElement, scrollEnd)\n : canScrollHorizontal(element, rootElement, scrollEnd);\n}\n\nfunction canScrollVertical(\n element: Element,\n rootElement: Element,\n scrollEnd: boolean,\n): boolean {\n let currentElement = element;\n\n while (currentElement !== rootElement.parentElement) {\n if (\n (Math.floor(currentElement.scrollTop) > 0 && !scrollEnd) ||\n (Math.ceil(currentElement.scrollTop + currentElement.clientHeight) <\n currentElement.scrollHeight &&\n scrollEnd)\n ) {\n return true;\n }\n\n if (currentElement.parentElement) {\n currentElement = currentElement.parentElement;\n } else {\n return false;\n }\n }\n\n return false;\n}\n\nfunction canScrollHorizontal(\n element: Element,\n rootElement: Element,\n scrollEnd: boolean,\n): boolean {\n let currentElement = element;\n\n while (currentElement !== rootElement.parentElement) {\n if (\n (Math.floor(currentElement.scrollLeft) > 0 && !scrollEnd) ||\n (Math.ceil(currentElement.scrollLeft + currentElement.clientWidth) <\n currentElement.scrollWidth &&\n scrollEnd)\n ) {\n return true;\n }\n\n if (currentElement.parentElement) {\n currentElement = currentElement.parentElement;\n } else {\n return false;\n }\n }\n\n return false;\n}\n","export function containsOrAfter(current: Node, node: Node): boolean {\n return (\n current.contains(node) ||\n !!(node.compareDocumentPosition(current) & Node.DOCUMENT_POSITION_PRECEDING)\n );\n}\n","/** @deprecated only needed for IE, remove in 3.0 */\nexport function tuiCustomEvent<T = null>(\n name: string,\n {bubbles = false, cancelable = false, detail = null}: CustomEventInit<T | null> = {},\n documentRef: Document,\n): CustomEvent {\n if (typeof CustomEvent === 'function') {\n return new CustomEvent(name, {bubbles, cancelable, detail});\n }\n\n const customEvent = documentRef.createEvent('CustomEvent');\n\n customEvent.initCustomEvent(name, bubbles, cancelable, detail);\n\n return customEvent;\n}\n","/**\n * Gets actual target from open Shadow DOM if event happened within it\n */\nexport function getActualTarget(event: Event): Node {\n if ('composedPath' in event) {\n return (event as any).composedPath()[0];\n }\n\n return (event as any).target;\n}\n","const DEFAULT_FORMAT = 'text/plain';\n\n/**\n * Gets text from data of clipboardEvent, it also works in IE and Edge browsers\n */\nexport function getClipboardDataText(\n event: ClipboardEvent,\n format: string = DEFAULT_FORMAT,\n): string {\n return 'clipboardData' in event && event.clipboardData !== null\n ? event.clipboardData.getData(format) ||\n event.clipboardData.getData(DEFAULT_FORMAT)\n : (event as any).target.ownerDocument.defaultView.clipboardData.getData('text');\n}\n","/**\n * Gets closest element by selector i.e. {@link Element.closest}\n * @deprecated only needed for IE, remove in 3.0\n */\nexport function getClosestElement(element: Element, selector: string): Element | null {\n const closest = Element.prototype.closest;\n\n if (closest) {\n return closest.call(element, selector);\n }\n\n const matchesSelector =\n Element.prototype.matches || (Element.prototype as any).msMatchesSelector;\n\n do {\n if (matchesSelector.call(element, selector)) {\n return element;\n }\n\n (element as Element | null) = element.parentElement;\n } while (element !== null);\n\n return null;\n}\n","export function getDocumentOrShadowRoot(node: Node): DocumentOrShadowRoot {\n return 'getRootNode' in node && node.isConnected\n ? (node.getRootNode() as Document)\n : node.ownerDocument!;\n}\n","import {clamp} from '@taiga-ui/cdk/utils/math';\nimport {isPresent} from '@taiga-ui/cdk/utils/miscellaneous';\n\nimport {getDocumentOrShadowRoot} from './get-document-or-shadow-root';\n\n/**\n * Returns array of Elements covering edges of given element or null if at least one edge middle point is visible\n *\n * CAUTION: Empty array means element if offscreen i.e. covered by no elements, rather than not covered\n */\nexport function getElementObscurers(element: Element): readonly Element[] | null {\n const {ownerDocument} = element;\n\n if (!ownerDocument || !ownerDocument.defaultView) {\n return null;\n }\n\n const {innerWidth, innerHeight} = ownerDocument.defaultView;\n const documentRef = getDocumentOrShadowRoot(element);\n const rect = element.getBoundingClientRect();\n const left = clamp(Math.round(rect.left) + 2, 0, innerWidth);\n const top = clamp(Math.round(rect.top) + 2, 0, innerHeight);\n const right = clamp(Math.round(rect.right) - 2, 0, innerWidth);\n const bottom = clamp(Math.round(rect.bottom) - 2, 0, innerHeight);\n const horizontalMiddle = clamp(Math.round(rect.left + rect.width / 2), 0, innerWidth);\n const verticalMiddle = clamp(Math.round(rect.top + rect.height / 2), 0, innerHeight);\n const elements = [\n documentRef.elementFromPoint(horizontalMiddle, top),\n documentRef.elementFromPoint(horizontalMiddle, bottom),\n documentRef.elementFromPoint(left, verticalMiddle),\n documentRef.elementFromPoint(right, verticalMiddle),\n ];\n const nonNull = elements.filter(isPresent);\n\n if (!nonNull.length) {\n return nonNull;\n }\n\n const filtered = nonNull.filter(el => !element.contains(el));\n\n return filtered.length === 4 ? filtered : null;\n}\n","import {tuiAssert} from '@taiga-ui/cdk/classes';\n\n/**\n * Calculates offset for an element relative to it's parent several levels above\n *\n * @param host parent element\n * @param element\n * @return object with offsetTop and offsetLeft number properties\n */\nexport function getElementOffset(\n host: Element,\n element: HTMLElement,\n): {offsetTop: number; offsetLeft: number} {\n tuiAssert.assert(host.contains(element), 'Host must contain element');\n\n let {offsetTop, offsetLeft, offsetParent} = element;\n\n // TODO: iframe warning\n while (offsetParent && offsetParent instanceof HTMLElement && offsetParent !== host) {\n offsetTop += offsetParent.offsetTop;\n offsetLeft += offsetParent.offsetLeft;\n offsetParent = offsetParent.offsetParent;\n }\n\n return {offsetTop, offsetLeft};\n}\n","/**\n * Finds nearest parent with scroll in it\n *\n * @param element initial element\n * @param vertical flag for orientation of scroll\n */\nexport function getScrollParent(\n element: Element | null,\n vertical: boolean = true,\n): Element | null {\n if (element === null) {\n return null;\n }\n\n if (vertical && element.scrollHeight > element.clientHeight) {\n return element;\n }\n\n if (!vertical && element.scrollWidth > element.clientWidth) {\n return element;\n }\n\n return getScrollParent(element.parentElement, vertical);\n}\n","export function isCurrentTarget({target, currentTarget}: Event): boolean {\n return target === currentTarget;\n}\n","/**\n * Checks if an app is running inside <iframe /> tag\n */\nexport function isInsideIframe(windowRef: Window): boolean {\n return windowRef.parent !== windowRef;\n}\n","import {getClosestElement} from './get-closest-element';\n\n/**\n * Checks if node is inside a specific selector\n *\n * @param node\n * @param selector\n * @return true if node is inside a particular selector\n */\nexport function isNodeIn(node: Node, selector: string): boolean {\n return node.nodeType === Node.TEXT_NODE\n ? !!node.parentElement && !!getClosestElement(node.parentElement, selector)\n : node.nodeType === Node.ELEMENT_NODE &&\n !!getClosestElement(node as Element, selector);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;SAAgB,SAAS,CACrB,OAAgB,EAChB,WAAoB,EACpB,QAAiB,EACjB,SAAkB;IAElB,OAAO,QAAQ;UACT,iBAAiB,CAAC,OAAO,EAAE,WAAW,EAAE,SAAS,CAAC;UAClD,mBAAmB,CAAC,OAAO,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;AAC/D,CAAC;AAED,SAAS,iBAAiB,CACtB,OAAgB,EAChB,WAAoB,EACpB,SAAkB;IAElB,IAAI,cAAc,GAAG,OAAO,CAAC;IAE7B,OAAO,cAAc,KAAK,WAAW,CAAC,aAAa,EAAE;QACjD,IACI,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS;aACtD,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,SAAS,GAAG,cAAc,CAAC,YAAY,CAAC;gBAC9D,cAAc,CAAC,YAAY;gBAC3B,SAAS,CAAC,EAChB;YACE,OAAO,IAAI,CAAC;SACf;QAED,IAAI,cAAc,CAAC,aAAa,EAAE;YAC9B,cAAc,GAAG,cAAc,CA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QAAwB;IAAxB,yBAAA,EAAA,eAAwB;IAExB,IAAI,OAAO,KAAK,IAAI,EAAE;QAClB,OAAO,IAAI,CAAC;KACf;IAED,IAAI,QAAQ,IAAI,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,EAAE;QACzD,OAAO,OAAO,CAAC;KAClB;IAED,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,EAAE;QACxD,OAAO,OAAO,CAAC;KAClB;IAED,OAAO,eAAe,CAAC,OAAO,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;AAC5D;;SCvBgB,eAAe,CAAC,EAA8B;QAA7B,kBAAM,EAAE,gCAAa;IAClD,OAAO,MAAM,KAAK,aAAa,CAAC;AACpC;;ACFA;;;SAGgB,cAAc,CAAC,SAAiB;IAC5C,OAAO,SAAS,CAAC,MAAM,KAAK,SAAS,CAAC;AAC1C;;ACHA;;;;;;;SAOgB,QAAQ,CAAC,IAAU,EAAE,QAAgB;IACjD,OAAO,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,SAAS;UACjC,CAAC,CAAC,IAAI,CAAC,aAAa,IAAI,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC;UACzE,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,YAAY;YAC/B,CAAC,CAAC,iBAAiB,CAAC,IAAe,EAAE,QAAQ,CAAC,CAAC;AAC7D;;ACdA;;;;;;"}
|
|
1
|
+
{"version":3,"file":"taiga-ui-cdk-utils-dom.js","sources":["ng://@taiga-ui/cdk/utils/dom/can-scroll.ts","ng://@taiga-ui/cdk/utils/dom/contains-or-after.ts","ng://@taiga-ui/cdk/utils/dom/custom-event.ts","ng://@taiga-ui/cdk/utils/dom/get-actual-target.ts","ng://@taiga-ui/cdk/utils/dom/get-clipboard-data-text.ts","ng://@taiga-ui/cdk/utils/dom/get-closest-element.ts","ng://@taiga-ui/cdk/utils/dom/get-document-or-shadow-root.ts","ng://@taiga-ui/cdk/utils/dom/get-element-obscurers.ts","ng://@taiga-ui/cdk/utils/dom/get-element-offset.ts","ng://@taiga-ui/cdk/utils/dom/get-scroll-parent.ts","ng://@taiga-ui/cdk/utils/dom/is-form-field.ts","ng://@taiga-ui/cdk/utils/dom/get-selected-text.ts","ng://@taiga-ui/cdk/utils/dom/is-current-target.ts","ng://@taiga-ui/cdk/utils/dom/is-inside-iframe.ts","ng://@taiga-ui/cdk/utils/dom/is-node-in.ts","ng://@taiga-ui/cdk/utils/dom/taiga-ui-cdk-utils-dom.ts"],"sourcesContent":["export function canScroll(\n element: Element,\n rootElement: Element,\n vertical: boolean,\n scrollEnd: boolean,\n): boolean {\n return vertical\n ? canScrollVertical(element, rootElement, scrollEnd)\n : canScrollHorizontal(element, rootElement, scrollEnd);\n}\n\nfunction canScrollVertical(\n element: Element,\n rootElement: Element,\n scrollEnd: boolean,\n): boolean {\n let currentElement = element;\n\n while (currentElement !== rootElement.parentElement) {\n if (\n (Math.floor(currentElement.scrollTop) > 0 && !scrollEnd) ||\n (Math.ceil(currentElement.scrollTop + currentElement.clientHeight) <\n currentElement.scrollHeight &&\n scrollEnd)\n ) {\n return true;\n }\n\n if (currentElement.parentElement) {\n currentElement = currentElement.parentElement;\n } else {\n return false;\n }\n }\n\n return false;\n}\n\nfunction canScrollHorizontal(\n element: Element,\n rootElement: Element,\n scrollEnd: boolean,\n): boolean {\n let currentElement = element;\n\n while (currentElement !== rootElement.parentElement) {\n if (\n (Math.floor(currentElement.scrollLeft) > 0 && !scrollEnd) ||\n (Math.ceil(currentElement.scrollLeft + currentElement.clientWidth) <\n currentElement.scrollWidth &&\n scrollEnd)\n ) {\n return true;\n }\n\n if (currentElement.parentElement) {\n currentElement = currentElement.parentElement;\n } else {\n return false;\n }\n }\n\n return false;\n}\n","export function containsOrAfter(current: Node, node: Node): boolean {\n return (\n current.contains(node) ||\n !!(node.compareDocumentPosition(current) & Node.DOCUMENT_POSITION_PRECEDING)\n );\n}\n","/** @deprecated only needed for IE, remove in 3.0 */\nexport function tuiCustomEvent<T = null>(\n name: string,\n {bubbles = false, cancelable = false, detail = null}: CustomEventInit<T | null> = {},\n documentRef: Document,\n): CustomEvent {\n if (typeof CustomEvent === 'function') {\n return new CustomEvent(name, {bubbles, cancelable, detail});\n }\n\n const customEvent = documentRef.createEvent('CustomEvent');\n\n customEvent.initCustomEvent(name, bubbles, cancelable, detail);\n\n return customEvent;\n}\n","/**\n * Gets actual target from open Shadow DOM if event happened within it\n */\nexport function getActualTarget(event: Event): Node {\n if ('composedPath' in event) {\n return (event as any).composedPath()[0];\n }\n\n return (event as any).target;\n}\n","const DEFAULT_FORMAT = 'text/plain';\n\n/**\n * Gets text from data of clipboardEvent, it also works in IE and Edge browsers\n */\nexport function getClipboardDataText(\n event: ClipboardEvent,\n format: string = DEFAULT_FORMAT,\n): string {\n return 'clipboardData' in event && event.clipboardData !== null\n ? event.clipboardData.getData(format) ||\n event.clipboardData.getData(DEFAULT_FORMAT)\n : (event as any).target.ownerDocument.defaultView.clipboardData.getData('text');\n}\n","/**\n * Gets closest element by selector i.e. {@link Element.closest}\n * @deprecated only needed for IE, remove in 3.0\n */\nexport function getClosestElement(element: Element, selector: string): Element | null {\n const closest = Element.prototype.closest;\n\n if (closest) {\n return closest.call(element, selector);\n }\n\n const matchesSelector =\n Element.prototype.matches || (Element.prototype as any).msMatchesSelector;\n\n do {\n if (matchesSelector.call(element, selector)) {\n return element;\n }\n\n (element as Element | null) = element.parentElement;\n } while (element !== null);\n\n return null;\n}\n","export function getDocumentOrShadowRoot(node: Node): DocumentOrShadowRoot {\n return 'getRootNode' in node && node.isConnected\n ? (node.getRootNode() as Document)\n : node.ownerDocument!;\n}\n","import {clamp} from '@taiga-ui/cdk/utils/math';\nimport {isPresent} from '@taiga-ui/cdk/utils/miscellaneous';\n\nimport {getDocumentOrShadowRoot} from './get-document-or-shadow-root';\n\n/**\n * Returns array of Elements covering edges of given element or null if at least one edge middle point is visible\n *\n * CAUTION: Empty array means element if offscreen i.e. covered by no elements, rather than not covered\n */\nexport function getElementObscurers(element: Element): readonly Element[] | null {\n const {ownerDocument} = element;\n\n if (!ownerDocument || !ownerDocument.defaultView) {\n return null;\n }\n\n const {innerWidth, innerHeight} = ownerDocument.defaultView;\n const documentRef = getDocumentOrShadowRoot(element);\n const rect = element.getBoundingClientRect();\n const left = clamp(Math.round(rect.left) + 2, 0, innerWidth);\n const top = clamp(Math.round(rect.top) + 2, 0, innerHeight);\n const right = clamp(Math.round(rect.right) - 2, 0, innerWidth);\n const bottom = clamp(Math.round(rect.bottom) - 2, 0, innerHeight);\n const horizontalMiddle = clamp(Math.round(rect.left + rect.width / 2), 0, innerWidth);\n const verticalMiddle = clamp(Math.round(rect.top + rect.height / 2), 0, innerHeight);\n const elements = [\n documentRef.elementFromPoint(horizontalMiddle, top),\n documentRef.elementFromPoint(horizontalMiddle, bottom),\n documentRef.elementFromPoint(left, verticalMiddle),\n documentRef.elementFromPoint(right, verticalMiddle),\n ];\n const nonNull = elements.filter(isPresent);\n\n if (!nonNull.length) {\n return nonNull;\n }\n\n const filtered = nonNull.filter(el => !element.contains(el));\n\n return filtered.length === 4 ? filtered : null;\n}\n","import {tuiAssert} from '@taiga-ui/cdk/classes';\n\n/**\n * Calculates offset for an element relative to it's parent several levels above\n *\n * @param host parent element\n * @param element\n * @return object with offsetTop and offsetLeft number properties\n */\nexport function getElementOffset(\n host: Element,\n element: HTMLElement,\n): {offsetTop: number; offsetLeft: number} {\n tuiAssert.assert(host.contains(element), 'Host must contain element');\n\n let {offsetTop, offsetLeft, offsetParent} = element;\n\n // TODO: iframe warning\n while (offsetParent && offsetParent instanceof HTMLElement && offsetParent !== host) {\n offsetTop += offsetParent.offsetTop;\n offsetLeft += offsetParent.offsetLeft;\n offsetParent = offsetParent.offsetParent;\n }\n\n return {offsetTop, offsetLeft};\n}\n","/**\n * Finds nearest parent with scroll in it\n *\n * @param element initial element\n * @param vertical flag for orientation of scroll\n */\nexport function getScrollParent(\n element: Element | null,\n vertical: boolean = true,\n): Element | null {\n if (element === null) {\n return null;\n }\n\n if (vertical && element.scrollHeight > element.clientHeight) {\n return element;\n }\n\n if (!vertical && element.scrollWidth > element.clientWidth) {\n return element;\n }\n\n return getScrollParent(element.parentElement, vertical);\n}\n","export function tuiIsFormFieldElement(\n element: unknown | null,\n): element is HTMLInputElement | HTMLTextAreaElement {\n const textfield = element as Record<string, unknown> | null;\n\n return (\n !!textfield &&\n 'value' in textfield &&\n 'selectionStart' in textfield &&\n 'selectionEnd' in textfield\n );\n}\n","import {tuiIsFormFieldElement} from './is-form-field';\n\n/**\n * @description:\n * cross browser way to get selected text\n *\n * History:\n * BUG - window.getSelection() fails when text selected in a form field\n * https://bugzilla.mozilla.org/show_bug.cgi?id=85686\n */\nexport function tuiGetSelectedText({getSelection, document}: Window): string | null {\n return tuiIsFormFieldElement(document.activeElement)\n ? document.activeElement.value.slice(\n document.activeElement.selectionStart || 0,\n document.activeElement.selectionEnd || 0,\n )\n : getSelection()?.toString() || null;\n}\n","export function isCurrentTarget({target, currentTarget}: Event): boolean {\n return target === currentTarget;\n}\n","/**\n * Checks if an app is running inside <iframe /> tag\n */\nexport function isInsideIframe(windowRef: Window): boolean {\n return windowRef.parent !== windowRef;\n}\n","import {getClosestElement} from './get-closest-element';\n\n/**\n * Checks if node is inside a specific selector\n *\n * @param node\n * @param selector\n * @return true if node is inside a particular selector\n */\nexport function isNodeIn(node: Node, selector: string): boolean {\n return node.nodeType === Node.TEXT_NODE\n ? !!node.parentElement && !!getClosestElement(node.parentElement, selector)\n : node.nodeType === Node.ELEMENT_NODE &&\n !!getClosestElement(node as Element, selector);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;SAAgB,SAAS,CACrB,OAAgB,EAChB,WAAoB,EACpB,QAAiB,EACjB,SAAkB;IAElB,OAAO,QAAQ;UACT,iBAAiB,CAAC,OAAO,EAAE,WAAW,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,CAAC,aAAa,CAAC;UAC9C,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,CAC9B,QAAQ,CAAC,aAAa,CAAC,cAAc,IAAI,CAAC,EAC1C,QAAQ,CAAC,aAAa,CAAC,YAAY,IAAI,CAAC,CAC3C;UACD,OAAA,YAAY,EAAE,0CAAE,QAAQ,OAAM,IAAI,CAAC;AAC7C;;SCjBgB,eAAe,CAAC,EAA8B;QAA7B,kBAAM,EAAE,gCAAa;IAClD,OAAO,MAAM,KAAK,aAAa,CAAC;AACpC;;ACFA;;;SAGgB,cAAc,CAAC,SAAiB;IAC5C,OAAO,SAAS,CAAC,MAAM,KAAK,SAAS,CAAC;AAC1C;;ACHA;;;;;;;SAOgB,QAAQ,CAAC,IAAU,EAAE,QAAgB;IACjD,OAAO,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,SAAS;UACjC,CAAC,CAAC,IAAI,CAAC,aAAa,IAAI,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC;UACzE,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,YAAY;YAC/B,CAAC,CAAC,iBAAiB,CAAC,IAAe,EAAE,QAAQ,CAAC,CAAC;AAC7D;;ACdA;;;;;;"}
|
package/package.json
CHANGED
|
@@ -25,3 +25,20 @@ export interface AttributeToDirective {
|
|
|
25
25
|
export declare const ATTRS_TO_REPLACE: ReplacementAttributes[];
|
|
26
26
|
export declare const TAGS_TO_REPLACE: ReplacementTags[];
|
|
27
27
|
export declare const ATTR_TO_DIRECTIVE: AttributeToDirective[];
|
|
28
|
+
export declare const TEMPLATE_COMMENTS: readonly [{
|
|
29
|
+
readonly tag: "tui-input-slider";
|
|
30
|
+
readonly withAttr: "pluralize";
|
|
31
|
+
readonly comment: "[pluralize] => Use [postfix] instead. See https://taiga-ui.dev/components/input-slider/API?postfix=apples";
|
|
32
|
+
}, {
|
|
33
|
+
readonly tag: "tui-input-slider";
|
|
34
|
+
readonly withAttr: "segmentsPluralize";
|
|
35
|
+
readonly comment: "See examples how create labels for ticks without this property (outside the component): https://taiga-ui.dev/components/input-slider#slider-segments";
|
|
36
|
+
}, {
|
|
37
|
+
readonly tag: "tui-input-range";
|
|
38
|
+
readonly withAttr: "segmentsPluralize";
|
|
39
|
+
readonly comment: "See examples how create labels for ticks without this property (outside the component): https://taiga-ui.dev/components/input-range#segments";
|
|
40
|
+
}, {
|
|
41
|
+
readonly tag: "tui-range";
|
|
42
|
+
readonly withAttr: "pluralize";
|
|
43
|
+
readonly comment: "See examples how create labels for ticks without this property (outside the component): https://taiga-ui.dev/components/range#segments";
|
|
44
|
+
}];
|
|
@@ -51,6 +51,7 @@ exports.ATTRS_TO_REPLACE = [
|
|
|
51
51
|
from: {
|
|
52
52
|
attrName: '[quantum]',
|
|
53
53
|
withAttrsNames: ['tuiSlider'],
|
|
54
|
+
withTagNames: ['tui-slider'],
|
|
54
55
|
},
|
|
55
56
|
to: {
|
|
56
57
|
attrName: '[step]',
|
|
@@ -129,4 +130,35 @@ exports.ATTR_TO_DIRECTIVE = [
|
|
|
129
130
|
moduleSpecifier: '@taiga-ui/core',
|
|
130
131
|
},
|
|
131
132
|
},
|
|
133
|
+
{
|
|
134
|
+
componentSelector: '*',
|
|
135
|
+
inputProperty: 'scrollIntoView',
|
|
136
|
+
directive: 'tuiScrollIntoViewLink',
|
|
137
|
+
directiveModule: {
|
|
138
|
+
name: 'TuiScrollIntoViewLinkModule',
|
|
139
|
+
moduleSpecifier: '@taiga-ui/addon-doc',
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
];
|
|
143
|
+
exports.TEMPLATE_COMMENTS = [
|
|
144
|
+
{
|
|
145
|
+
tag: 'tui-input-slider',
|
|
146
|
+
withAttr: 'pluralize',
|
|
147
|
+
comment: '[pluralize] => Use [postfix] instead. See https://taiga-ui.dev/components/input-slider/API?postfix=apples',
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
tag: 'tui-input-slider',
|
|
151
|
+
withAttr: 'segmentsPluralize',
|
|
152
|
+
comment: 'See examples how create labels for ticks without this property (outside the component): https://taiga-ui.dev/components/input-slider#slider-segments',
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
tag: 'tui-input-range',
|
|
156
|
+
withAttr: 'segmentsPluralize',
|
|
157
|
+
comment: 'See examples how create labels for ticks without this property (outside the component): https://taiga-ui.dev/components/input-range#segments',
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
tag: 'tui-range',
|
|
161
|
+
withAttr: 'pluralize',
|
|
162
|
+
comment: 'See examples how create labels for ticks without this property (outside the component): https://taiga-ui.dev/components/range#segments',
|
|
163
|
+
},
|
|
132
164
|
];
|
|
@@ -121,4 +121,34 @@ exports.TYPES_TO_RENAME = [
|
|
|
121
121
|
to: 'TuiLanguage',
|
|
122
122
|
moduleSpecifier: ['@taiga-ui/i18n'],
|
|
123
123
|
},
|
|
124
|
+
{
|
|
125
|
+
from: 'ScrollIntoViewDirective',
|
|
126
|
+
to: 'TuiScrollIntoViewLinkDirective',
|
|
127
|
+
moduleSpecifier: ['@taiga-ui/addon-doc'],
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
from: 'CodeComponent',
|
|
131
|
+
to: 'TuiCodeComponent',
|
|
132
|
+
moduleSpecifier: ['@taiga-ui/addon-doc'],
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
from: 'TableBar',
|
|
136
|
+
to: 'TuiTableBar',
|
|
137
|
+
moduleSpecifier: ['@taiga-ui/addon-tablebars'],
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
from: 'InvalidDayException',
|
|
141
|
+
to: 'TuiInvalidDayException',
|
|
142
|
+
moduleSpecifier: ['@taiga-ui/cdk'],
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
from: 'InvalidMonthException',
|
|
146
|
+
to: 'TuiInvalidMonthException',
|
|
147
|
+
moduleSpecifier: ['@taiga-ui/cdk'],
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
from: 'InvalidYearException',
|
|
151
|
+
to: 'TuiInvalidYearException',
|
|
152
|
+
moduleSpecifier: ['@taiga-ui/cdk'],
|
|
153
|
+
},
|
|
124
154
|
];
|
|
@@ -14,22 +14,57 @@ const migrate_sliders_1 = require("./steps/migrate-sliders");
|
|
|
14
14
|
const remove_module_1 = require("./steps/remove-module");
|
|
15
15
|
const miscellaneous_1 = require("./steps/miscellaneous");
|
|
16
16
|
const replace_functions_1 = require("./steps/replace-functions");
|
|
17
|
+
const migrate_progress_1 = require("./steps/migrate-progress");
|
|
18
|
+
const colored_log_1 = require("../utils/colored-log");
|
|
19
|
+
const migrate_date_time_1 = require("./steps/migrate-date-time");
|
|
17
20
|
function updateToV3(_) {
|
|
18
21
|
return (tree, context) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
console.info('\x1b[35m', `taiga packages will be updated to ${versions_1.TAIGA_VERSION}`);
|
|
23
|
+
const fileSystem = getFileSystem(tree);
|
|
24
|
+
colored_log_1.infoLog('replacing deep imports...');
|
|
21
25
|
replace_deep_import_1.replaceDeepImports();
|
|
26
|
+
colored_log_1.successLog('deep imports replaced');
|
|
27
|
+
colored_log_1.infoLog('replacing enums imports...');
|
|
22
28
|
replace_enums_1.replaceEnums();
|
|
29
|
+
colored_log_1.successLog('enums replaced');
|
|
30
|
+
colored_log_1.infoLog('renaming types...');
|
|
23
31
|
rename_types_1.renameTypes();
|
|
32
|
+
colored_log_1.successLog('types renamed');
|
|
33
|
+
colored_log_1.infoLog('replacing consts...');
|
|
24
34
|
replace_const_1.replaceConsts();
|
|
35
|
+
colored_log_1.successLog('constants replaced');
|
|
36
|
+
colored_log_1.infoLog('replacing services...');
|
|
25
37
|
replace_services_1.replaceServices();
|
|
38
|
+
colored_log_1.successLog('services replaced');
|
|
26
39
|
show_warnings_1.showWarnings(context);
|
|
27
|
-
|
|
28
|
-
|
|
40
|
+
colored_log_1.infoLog('migrating templates...');
|
|
41
|
+
migrate_templates_1.migrateTemplates(fileSystem);
|
|
42
|
+
colored_log_1.successLog('templates migrated');
|
|
43
|
+
fileSystem.commitEdits();
|
|
44
|
+
ng_morph_1.saveActiveProject();
|
|
45
|
+
const updatedFileSystem = getFileSystem(tree);
|
|
46
|
+
colored_log_1.infoLog('migrating sliders...');
|
|
47
|
+
migrate_sliders_1.migrateSliders(updatedFileSystem);
|
|
48
|
+
colored_log_1.successLog('sliders migrated');
|
|
49
|
+
colored_log_1.infoLog('migrating progress bars');
|
|
50
|
+
migrate_progress_1.migrateProgress(updatedFileSystem);
|
|
51
|
+
colored_log_1.successLog('progress bars migrated');
|
|
52
|
+
colored_log_1.infoLog('removing modules...');
|
|
29
53
|
remove_module_1.removeModules();
|
|
54
|
+
colored_log_1.successLog('modules removed');
|
|
55
|
+
colored_log_1.infoLog('migrating taiga date/time ...');
|
|
56
|
+
migrate_date_time_1.dateTimeMigrations();
|
|
57
|
+
colored_log_1.successLog('date/time migrated');
|
|
58
|
+
colored_log_1.infoLog('miscellaneous migrating...');
|
|
30
59
|
replace_functions_1.replaceFunctions();
|
|
31
60
|
miscellaneous_1.miscellaneousMigrations();
|
|
61
|
+
colored_log_1.successLog('miscellaneous migrated');
|
|
32
62
|
ng_morph_1.saveActiveProject();
|
|
33
63
|
});
|
|
34
64
|
}
|
|
35
65
|
exports.updateToV3 = updateToV3;
|
|
66
|
+
function getFileSystem(tree) {
|
|
67
|
+
const project = ng_morph_1.createProject(tree, '/', '**/**.{html,ts}');
|
|
68
|
+
ng_morph_1.setActiveProject(project);
|
|
69
|
+
return project.getFileSystem().fs;
|
|
70
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function dateTimeMigrations(): void;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ng_morph_1 = require("ng-morph");
|
|
4
|
+
const get_named_import_references_1 = require("../../utils/get-named-import-references");
|
|
5
|
+
const insert_todo_1 = require("../../utils/insert-todo");
|
|
6
|
+
function dateTimeMigrations() {
|
|
7
|
+
migrateProperty({
|
|
8
|
+
namedImport: 'TuiDay',
|
|
9
|
+
moduleSpecifier: '@taiga-ui/cdk',
|
|
10
|
+
from: 'formattedDay',
|
|
11
|
+
callback: node => node.replaceWithText(node.getText().replace('formattedDay', 'getFormattedDay("DMY", ".")')),
|
|
12
|
+
});
|
|
13
|
+
migrateProperty({
|
|
14
|
+
namedImport: 'TuiDayRange',
|
|
15
|
+
moduleSpecifier: '@taiga-ui/cdk',
|
|
16
|
+
from: 'formattedDayRange',
|
|
17
|
+
callback: node => node.replaceWithText(node
|
|
18
|
+
.getText()
|
|
19
|
+
.replace('formattedDayRange', 'getFormattedDayRange("DMY", ".")')),
|
|
20
|
+
});
|
|
21
|
+
migrateProperty({
|
|
22
|
+
namedImport: 'TuiDayRange',
|
|
23
|
+
moduleSpecifier: '@taiga-ui/cdk',
|
|
24
|
+
from: 'normalizeParse',
|
|
25
|
+
callback: node => {
|
|
26
|
+
const parent = node.getParent();
|
|
27
|
+
if (ng_morph_1.Node.isCallExpression(parent)) {
|
|
28
|
+
changeNormalizeArgs(parent);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
[
|
|
33
|
+
{
|
|
34
|
+
namedImport: 'TuiMonthRange',
|
|
35
|
+
field: 'formattedMonthRange',
|
|
36
|
+
message: 'formattedMonthRange has been removed in 3.0. Please use TUI_MONTH_FORMATTER from @taiga-ui/kit',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
namedImport: 'TuiMonth',
|
|
40
|
+
field: 'formattedMonth',
|
|
41
|
+
message: 'formattedMonth has been removed in 3.0. Please use TUI_MONTH_FORMATTER from @taiga-ui/kit',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
namedImport: 'TuiDay',
|
|
45
|
+
field: 'getDayFromMonthRowCol',
|
|
46
|
+
message: 'getDayFromMonthRowCol has been removed in 3.0. If you need this utils check out this pipe https://github.com/Tinkoff/taiga-ui/tree/main/projects/core/pipes/calendar-sheet',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
namedImport: 'TuiMonth',
|
|
50
|
+
field: 'monthStartDaysOffset',
|
|
51
|
+
message: 'monthStartDaysOffset has been removed in 3.0. If you need this utils check out this pipe https://github.com/Tinkoff/taiga-ui/tree/main/projects/core/pipes/calendar-sheet',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
namedImport: 'TuiMonth',
|
|
55
|
+
field: 'weeksRowsCount',
|
|
56
|
+
message: 'weeksRowsCount has been removed in 3.0. If you need this utils check out this pipe https://github.com/Tinkoff/taiga-ui/tree/main/projects/core/pipes/calendar-sheet',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
namedImport: 'TuiYear',
|
|
60
|
+
field: 'getYearStartDaysOffset',
|
|
61
|
+
message: 'getYearStartDaysOffset has been removed in 3.0. If you need this utils check out this pipe https://github.com/Tinkoff/taiga-ui/tree/main/projects/core/pipes/calendar-sheet',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
namedImport: 'TuiYear',
|
|
65
|
+
field: 'weeksRowsCount',
|
|
66
|
+
message: 'weeksRowsCount has been removed in 3.0. If you need this utils check out this pipe https://github.com/Tinkoff/taiga-ui/tree/main/projects/core/pipes/calendar-sheet',
|
|
67
|
+
},
|
|
68
|
+
].forEach(({ namedImport, field, message }) => {
|
|
69
|
+
migrateProperty({
|
|
70
|
+
namedImport,
|
|
71
|
+
moduleSpecifier: '@taiga-ui/cdk',
|
|
72
|
+
from: field,
|
|
73
|
+
callback: node => insertTodoBeforeNode(node, message),
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
exports.dateTimeMigrations = dateTimeMigrations;
|
|
78
|
+
function migrateProperty({ namedImport, moduleSpecifier, from, callback, }) {
|
|
79
|
+
const references = get_named_import_references_1.getNamedImportReferences(namedImport, moduleSpecifier);
|
|
80
|
+
references.forEach(ref => {
|
|
81
|
+
if (ref.wasForgotten()) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const parent = ref.getParent();
|
|
85
|
+
if (!parent) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (ng_morph_1.Node.isNewExpression(parent)) {
|
|
89
|
+
const accessExpression = parent.getFirstAncestorByKind(ng_morph_1.SyntaxKind.PropertyAccessExpression);
|
|
90
|
+
const searched = accessExpression === null || accessExpression === void 0 ? void 0 : accessExpression.getChildrenOfKind(ng_morph_1.SyntaxKind.Identifier).find(identifier => identifier.getText() === from);
|
|
91
|
+
if (searched && accessExpression) {
|
|
92
|
+
callback(accessExpression);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (ng_morph_1.Node.isPropertyAccessExpression(parent)) {
|
|
97
|
+
const searched = parent
|
|
98
|
+
.getChildrenOfKind(ng_morph_1.SyntaxKind.Identifier)
|
|
99
|
+
.find(identifier => identifier.getText() === from);
|
|
100
|
+
if (searched && !parent.wasForgotten()) {
|
|
101
|
+
callback(parent);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
replaceIdentifier(parent, from, callback);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function replaceIdentifier(node, from, callback) {
|
|
109
|
+
const declaration = node.getFirstAncestorByKind(ng_morph_1.SyntaxKind.VariableDeclaration) ||
|
|
110
|
+
node.getFirstAncestorByKind(ng_morph_1.SyntaxKind.PropertyDeclaration);
|
|
111
|
+
const identifier = declaration === null || declaration === void 0 ? void 0 : declaration.getFirstDescendantByKind(ng_morph_1.SyntaxKind.Identifier);
|
|
112
|
+
if (identifier) {
|
|
113
|
+
replaceIdentifierReferences(identifier, from, callback);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function replaceIdentifierReferences(identifier, from, callback) {
|
|
117
|
+
identifier.findReferencesAsNodes().forEach(ref => {
|
|
118
|
+
let parent = ref.getParent();
|
|
119
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.getText()) === `this.${identifier.getText()}` ||
|
|
120
|
+
(parent === null || parent === void 0 ? void 0 : parent.getText()) === identifier.getText()) {
|
|
121
|
+
replaceIdentifier(parent, from, callback);
|
|
122
|
+
}
|
|
123
|
+
if (parent === null || parent === void 0 ? void 0 : parent.getText().startsWith('this')) {
|
|
124
|
+
parent = parent === null || parent === void 0 ? void 0 : parent.getParent();
|
|
125
|
+
}
|
|
126
|
+
if (ng_morph_1.Node.isPropertyAccessExpression(parent)) {
|
|
127
|
+
const searched = parent
|
|
128
|
+
.getChildrenOfKind(ng_morph_1.SyntaxKind.Identifier)
|
|
129
|
+
.find(identifier => identifier.getText() === from);
|
|
130
|
+
if (searched) {
|
|
131
|
+
callback(parent);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
function changeNormalizeArgs(node) {
|
|
137
|
+
const args = node.getArguments();
|
|
138
|
+
if (args.length > 2) {
|
|
139
|
+
node.removeArgument(2);
|
|
140
|
+
node.removeArgument(1);
|
|
141
|
+
node.addArgument('"DMY"');
|
|
142
|
+
}
|
|
143
|
+
else if (args.length === 1) {
|
|
144
|
+
node.addArgument('"DMY"');
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function insertTodoBeforeNode(node, message) {
|
|
148
|
+
const identifier = node.getFirstDescendantByKind(ng_morph_1.SyntaxKind.Identifier);
|
|
149
|
+
if (identifier) {
|
|
150
|
+
insert_todo_1.insertTodo(identifier, message);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ng_morph_1 = require("ng-morph");
|
|
4
|
+
const get_component_templates_1 = require("../../utils/templates/get-component-templates");
|
|
5
|
+
const elements_1 = require("../../utils/templates/elements");
|
|
6
|
+
const template_resource_1 = require("../../utils/templates/template-resource");
|
|
7
|
+
exports.DEPRECATED_PROGRESS_PIPES_REG = /\s*\|\s*tuiProgressColorSegments(Async\s*\|\s*async)?/gi;
|
|
8
|
+
const PROPERTY_FOR_DEPRECATED_PIPES = '[color]';
|
|
9
|
+
function migrateProgress(fileSystem) {
|
|
10
|
+
const templateResources = get_component_templates_1.getComponentTemplates('**/**');
|
|
11
|
+
for (const templateResource of templateResources) {
|
|
12
|
+
replaceProgressColorSegmentsPipe(templateResource, fileSystem);
|
|
13
|
+
}
|
|
14
|
+
fileSystem.commitEdits();
|
|
15
|
+
ng_morph_1.saveActiveProject();
|
|
16
|
+
ng_morph_1.setActiveProject(ng_morph_1.createProject(fileSystem.tree, '/', '**/**'));
|
|
17
|
+
}
|
|
18
|
+
exports.migrateProgress = migrateProgress;
|
|
19
|
+
function replaceProgressColorSegmentsPipe(templateResource, fileSystem) {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
const template = template_resource_1.getTemplateFromTemplateResource(templateResource, fileSystem);
|
|
22
|
+
const templateOffset = template_resource_1.getTemplateOffset(templateResource);
|
|
23
|
+
const path = fileSystem.resolve(template_resource_1.getPathFromTemplateResource(templateResource));
|
|
24
|
+
const recorder = fileSystem.edit(path);
|
|
25
|
+
const progressElements = elements_1.findElementsWithAttribute(template, PROPERTY_FOR_DEPRECATED_PIPES).filter(isProgressWithDeprecatedPipe);
|
|
26
|
+
for (const progressEl of progressElements) {
|
|
27
|
+
const oldValue = ((_a = progressEl.attrs.find(attr => attr.name === PROPERTY_FOR_DEPRECATED_PIPES)) === null || _a === void 0 ? void 0 : _a.value) || '';
|
|
28
|
+
const newValue = oldValue.replace(exports.DEPRECATED_PROGRESS_PIPES_REG, '');
|
|
29
|
+
const attrLocations = (_b = progressEl.sourceCodeLocation) === null || _b === void 0 ? void 0 : _b.attrs;
|
|
30
|
+
if (attrLocations) {
|
|
31
|
+
const { startOffset, endOffset } = attrLocations[PROPERTY_FOR_DEPRECATED_PIPES];
|
|
32
|
+
recorder.remove(templateOffset + startOffset, endOffset - startOffset);
|
|
33
|
+
recorder.insertRight(templateOffset + startOffset, `[tuiProgressColorSegments]="${newValue}"`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function isProgressWithDeprecatedPipe(element) {
|
|
38
|
+
return (element.tagName === 'progress' &&
|
|
39
|
+
element.attrs.some(attr => attr.name === PROPERTY_FOR_DEPRECATED_PIPES &&
|
|
40
|
+
attr.value.match(exports.DEPRECATED_PROGRESS_PIPES_REG)));
|
|
41
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function migrateSliders(
|
|
1
|
+
import { DevkitFileSystem } from 'ng-morph/project/classes/devkit-file-system';
|
|
2
|
+
export declare function migrateSliders(fileSystem: DevkitFileSystem): void;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const migrate_input_slider_1 = require("./migrate-input-slider");
|
|
4
4
|
const migrate_input_range_1 = require("./migrate-input-range");
|
|
5
|
-
function migrateSliders(
|
|
6
|
-
migrate_input_slider_1.migrateInputSlider(
|
|
7
|
-
migrate_input_range_1.migrateInputRange(
|
|
5
|
+
function migrateSliders(fileSystem) {
|
|
6
|
+
migrate_input_slider_1.migrateInputSlider(fileSystem);
|
|
7
|
+
migrate_input_range_1.migrateInputRange(fileSystem);
|
|
8
8
|
}
|
|
9
9
|
exports.migrateSliders = migrateSliders;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function migrateInputRange(
|
|
1
|
+
import { DevkitFileSystem } from 'ng-morph/project/classes/devkit-file-system';
|
|
2
|
+
export declare function migrateInputRange(fileSystem: DevkitFileSystem): void;
|
|
@@ -1,60 +1,65 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const devkit_file_system_1 = require("ng-morph/project/classes/devkit-file-system");
|
|
4
3
|
const get_component_templates_1 = require("../../../utils/templates/get-component-templates");
|
|
5
4
|
const ng_component_input_manipulations_1 = require("../../../utils/templates/ng-component-input-manipulations");
|
|
6
5
|
const ng_morph_1 = require("ng-morph");
|
|
7
6
|
const ng_component_1 = require("../../../utils/angular/ng-component");
|
|
8
7
|
const add_unique_import_1 = require("../../../utils/add-unique-import");
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const MIN_LABELS_MIGRATION_METHOD_NAME = 'tuiMigrationInputRangeMinLabel';
|
|
9
|
+
const MAX_LABELS_MIGRATION_METHOD_NAME = 'tuiMigrationInputRangeMaxLabel';
|
|
10
|
+
function migrateInputRange(fileSystem) {
|
|
11
11
|
const templateResources = get_component_templates_1.getComponentTemplates('**/**');
|
|
12
|
+
const COMPONENTS_WITH_MIN_LABELS = new Set();
|
|
13
|
+
const COMPONENTS_WITH_MAX_LABELS = new Set();
|
|
12
14
|
for (const templateResource of templateResources) {
|
|
13
|
-
replaceMinLabel(templateResource, fileSystem);
|
|
14
|
-
replaceMaxLabel(templateResource, fileSystem);
|
|
15
|
+
replaceMinLabel(templateResource, fileSystem, COMPONENTS_WITH_MIN_LABELS);
|
|
16
|
+
replaceMaxLabel(templateResource, fileSystem, COMPONENTS_WITH_MAX_LABELS);
|
|
17
|
+
}
|
|
18
|
+
save(fileSystem);
|
|
19
|
+
for (const componentPath of COMPONENTS_WITH_MIN_LABELS) {
|
|
20
|
+
addMinMaxLabelMethod(componentPath, MIN_LABELS_MIGRATION_METHOD_NAME, [
|
|
21
|
+
'const currentValue = context.$implicit;',
|
|
22
|
+
'const minValue = 0; // TODO: (Taiga UI migration) replace with the MIN value of the input-range',
|
|
23
|
+
'const minLabelText = "Min"; // TODO: (Taiga UI migration) replace with the required label',
|
|
24
|
+
'if (currentValue === minValue) return minLabelText;',
|
|
25
|
+
'return String(currentValue);',
|
|
26
|
+
]);
|
|
27
|
+
}
|
|
28
|
+
for (const componentPath of COMPONENTS_WITH_MAX_LABELS) {
|
|
29
|
+
addMinMaxLabelMethod(componentPath, MAX_LABELS_MIGRATION_METHOD_NAME, [
|
|
30
|
+
'const currentValue = context.$implicit;',
|
|
31
|
+
'const maxValue = 100; // TODO: (Taiga UI migration) replace with the MAX value of the input',
|
|
32
|
+
'const maxLabelText = "Max"; // TODO: (Taiga UI migration) replace with the required label',
|
|
33
|
+
'if (currentValue === maxValue) return maxLabelText;',
|
|
34
|
+
'return String(currentValue);',
|
|
35
|
+
]);
|
|
15
36
|
}
|
|
16
37
|
}
|
|
17
38
|
exports.migrateInputRange = migrateInputRange;
|
|
18
|
-
function replaceMinLabel(templateResource, fileSystem) {
|
|
19
|
-
const MIGRATION_VARIABLE_NAME = 'tuiMigrationInputRangeMinLabel';
|
|
39
|
+
function replaceMinLabel(templateResource, fileSystem, modifiedComponentStorage) {
|
|
20
40
|
const wasModified = ng_component_input_manipulations_1.replaceInputProperty({
|
|
21
41
|
templateResource,
|
|
22
42
|
fileSystem,
|
|
23
43
|
componentSelector: 'tui-input-range',
|
|
24
44
|
from: 'minLabel',
|
|
25
45
|
to: '[leftValueContent]',
|
|
26
|
-
newValue:
|
|
46
|
+
newValue: MIN_LABELS_MIGRATION_METHOD_NAME,
|
|
27
47
|
});
|
|
28
|
-
save(fileSystem);
|
|
29
48
|
if (wasModified) {
|
|
30
|
-
|
|
31
|
-
'const currentValue = context.$implicit;',
|
|
32
|
-
'const minValue = 0; // TODO replace with the MIN value of the input-range',
|
|
33
|
-
'const minLabelText = "Min"; // TODO replace with the required label',
|
|
34
|
-
'if (currentValue === minValue) return minLabelText;',
|
|
35
|
-
'return String(currentValue);',
|
|
36
|
-
]);
|
|
49
|
+
modifiedComponentStorage.add(templateResource.componentPath);
|
|
37
50
|
}
|
|
38
51
|
}
|
|
39
|
-
function replaceMaxLabel(templateResource, fileSystem) {
|
|
40
|
-
const MIGRATION_VARIABLE_NAME = 'tuiMigrationInputRangeMaxLabel';
|
|
52
|
+
function replaceMaxLabel(templateResource, fileSystem, modifiedComponentStorage) {
|
|
41
53
|
const wasModified = ng_component_input_manipulations_1.replaceInputProperty({
|
|
42
54
|
templateResource,
|
|
43
55
|
fileSystem,
|
|
44
56
|
componentSelector: 'tui-input-range',
|
|
45
57
|
from: 'maxLabel',
|
|
46
58
|
to: '[rightValueContent]',
|
|
47
|
-
newValue:
|
|
59
|
+
newValue: MAX_LABELS_MIGRATION_METHOD_NAME,
|
|
48
60
|
});
|
|
49
|
-
save(fileSystem);
|
|
50
61
|
if (wasModified) {
|
|
51
|
-
|
|
52
|
-
'const currentValue = context.$implicit;',
|
|
53
|
-
'const maxValue = 100; // TODO replace with the MAX value of the input',
|
|
54
|
-
'const maxLabelText = "Max"; // TODO replace with the required label',
|
|
55
|
-
'if (currentValue === maxValue) return maxLabelText;',
|
|
56
|
-
'return String(currentValue);',
|
|
57
|
-
]);
|
|
62
|
+
modifiedComponentStorage.add(templateResource.componentPath);
|
|
58
63
|
}
|
|
59
64
|
}
|
|
60
65
|
function addMinMaxLabelMethod(componentPath, methodName, methodCode) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function migrateInputSlider(
|
|
1
|
+
import { DevkitFileSystem } from 'ng-morph/project/classes/devkit-file-system';
|
|
2
|
+
export declare function migrateInputSlider(fileSystem: DevkitFileSystem): void;
|