From b9e2d58d2b4107d50ffcb4754dd72accb8856d17 Mon Sep 17 00:00:00 2001 From: Andrew Gliga Date: Fri, 24 Jan 2025 08:11:37 -0800 Subject: [PATCH] chore: removed deprecations --- .changeset/tidy-rockets-wonder.md | 5 + src/common/menu-utils/index.ts | 5 +- .../transformers/menu-separator/index.js | 45 --- .../test/__snapshots__/test.server.js.snap | 31 -- .../menu-separator/test/test.server.js | 34 -- .../ebay-fake-menu-button/component.ts | 1 - .../examples/separator.marko | 2 +- .../ebay-fake-menu-button/marko-tag.json | 7 - src/components/ebay-fake-menu/component.ts | 1 - .../ebay-fake-menu/examples/separator.marko | 2 +- src/components/ebay-fake-menu/marko-tag.json | 7 - .../test/__snapshots__/test.server.js.snap | 5 - .../ebay-lightbox-dialog/component.ts | 100 ------ .../examples/default.marko | 2 - .../ebay-lightbox-dialog/examples/focus.marko | 2 - .../examples/scrolling.marko | 2 - .../examples/with-footer.marko | 2 - .../examples/with-prev-button.marko | 2 - .../ebay-lightbox-dialog/index.marko | 32 -- .../lightbox-dialog.stories.ts | 36 -- .../test/__snapshots__/test.server.js.snap | 69 +--- .../ebay-lightbox-dialog/test/test.browser.js | 204 ------------ .../ebay-menu-button/marko-tag.json | 7 - .../ebay-menu/examples/separator.marko | 2 +- src/components/ebay-menu/marko-tag.json | 7 - .../ebay-progress-stepper/index.marko | 9 - .../test/__snapshots__/test.server.js.snap | 314 +++--------------- .../ebay-progress-stepper/test/test.server.js | 4 - 28 files changed, 57 insertions(+), 882 deletions(-) create mode 100644 .changeset/tidy-rockets-wonder.md delete mode 100644 src/common/transformers/menu-separator/index.js delete mode 100644 src/common/transformers/menu-separator/test/__snapshots__/test.server.js.snap delete mode 100644 src/common/transformers/menu-separator/test/test.server.js delete mode 100644 src/components/ebay-lightbox-dialog/component.ts diff --git a/.changeset/tidy-rockets-wonder.md b/.changeset/tidy-rockets-wonder.md new file mode 100644 index 000000000..897739fd3 --- /dev/null +++ b/.changeset/tidy-rockets-wonder.md @@ -0,0 +1,5 @@ +--- +"@ebay/ebayui-core": major +--- + +chore: removed deprecated code diff --git a/src/common/menu-utils/index.ts b/src/common/menu-utils/index.ts index 133dd4e4e..f0979cf54 100644 --- a/src/common/menu-utils/index.ts +++ b/src/common/menu-utils/index.ts @@ -10,7 +10,6 @@ export interface MenuItem extends Omit { export interface BaseMenuInput { items?: Marko.AttrTag; type?: string; - separator?: Marko.AttrTag<{}>; } export interface MenuState { @@ -55,8 +54,8 @@ export class MenuUtils< } getInputState(input: Input) { - /* - ebay-menu uses separators and we need to exclude these + /* + ebay-menu uses separators and we need to exclude these from items to pass correct indexes to state Any other component that doesn't have separator should pass through */ diff --git a/src/common/transformers/menu-separator/index.js b/src/common/transformers/menu-separator/index.js deleted file mode 100644 index 1549736a6..000000000 --- a/src/common/transformers/menu-separator/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @param {Object} el - * @param {Object} context - */ -function transformMarko4(el, context) { - const walker = context.createWalker({ - enter(node) { - if (node.tagName === "@separator") { - node.setTagName("@item"); - node.setAttributeValue( - "separator", - context.builder.literalTrue(), - ); - } - }, - }); - walker.walk(el); - return el; -} - -const replaceSeparatorVisitor = { - MarkoTag(tag, { t }) { - if (tag.get("name").isStringLiteral({ value: "@separator" })) { - tag.replaceWith( - t.markoTag( - t.stringLiteral("@item"), - [t.markoAttribute("separator", t.booleanLiteral(true))], - t.markoTagBody(), - ), - ); - } - }, -}; - -function transformMarko5(path, t) { - path.traverse(replaceSeparatorVisitor, { t }); -} - -module.exports = function transform(a, b) { - if (a.hub) { - return transformMarko5(a, b); - } - - return transformMarko4(a, b); -}; diff --git a/src/common/transformers/menu-separator/test/__snapshots__/test.server.js.snap b/src/common/transformers/menu-separator/test/__snapshots__/test.server.js.snap deleted file mode 100644 index af846f8a3..000000000 --- a/src/common/transformers/menu-separator/test/__snapshots__/test.server.js.snap +++ /dev/null @@ -1,31 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`when the ebay-menu-separator tag is transformed > transforms the ebay-menu-separator 1`] = ` -""use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _index = require("marko/src/runtime/html/index.js"); -var _attrTag = require("marko/src/runtime/helpers/attr-tag.js"); -var _index2 = _interopRequireDefault(require("./index.marko")); -var _renderTag = _interopRequireDefault(require("marko/src/runtime/helpers/render-tag.js")); -var _component2 = _interopRequireDefault(require("./component.ts")); -var _renderer = _interopRequireDefault(require("marko/src/runtime/components/renderer.js")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -const _marko_componentType = "src/components/ebay-menu/index.marko", - _marko_template = (0, _index.t)(_marko_componentType); -var _default = exports.default = _marko_template; -const _marko_component2 = _component2.default; -_marko_template._ = (0, _renderer.default)(function (input, out, _componentDef, _component, state, $global) { - (0, _renderTag.default)(_index2.default, (0, _attrTag.i)(() => { - (0, _attrTag.r)("items", { - "separator": true - }); - }), out, _componentDef, "0"); -}, { - t: _marko_componentType, - d: true -}, _marko_component2);" -`; diff --git a/src/common/transformers/menu-separator/test/test.server.js b/src/common/transformers/menu-separator/test/test.server.js deleted file mode 100644 index 7b459807c..000000000 --- a/src/common/transformers/menu-separator/test/test.server.js +++ /dev/null @@ -1,34 +0,0 @@ -import { beforeEach, describe, it, expect } from "vitest"; - -import * as testUtils from "../../../test-utils/server"; -import transformer from "../"; - -describe("when the ebay-menu-separator tag is transformed", () => { - let outputTemplate; - let code; - - beforeEach(() => { - const templatePath = `src/components/ebay-menu/index.marko`; - if (testUtils.isMarko5) { - code = testUtils.runTransformer( - transformer, - "<@separator/>", - templatePath, - ).code; - } else { - outputTemplate = testUtils.getTransformedTemplate( - transformer, - "@separator", - templatePath, - ); - } - }); - - it("transforms the ebay-menu-separator", async () => { - if (code) { - expect(code).toMatchSnapshot(); - } else { - expect(outputTemplate).to.deep.equal("<@item separator=true/>"); - } - }); -}); diff --git a/src/components/ebay-fake-menu-button/component.ts b/src/components/ebay-fake-menu-button/component.ts index 0c651f5f9..9386b0018 100644 --- a/src/components/ebay-fake-menu-button/component.ts +++ b/src/components/ebay-fake-menu-button/component.ts @@ -27,7 +27,6 @@ interface FakeMenuButtonInput extends Omit { reverse?: boolean; "fix-width"?: boolean; items?: Marko.AttrTag; - separator?: Marko.AttrTag<{}>; "collapse-on-select"?: boolean; "on-expand"?: (event: MenuEvent) => void; "on-collapse"?: (event: MenuEvent) => void; diff --git a/src/components/ebay-fake-menu-button/examples/separator.marko b/src/components/ebay-fake-menu-button/examples/separator.marko index c002c7f10..70c341f0a 100644 --- a/src/components/ebay-fake-menu-button/examples/separator.marko +++ b/src/components/ebay-fake-menu-button/examples/separator.marko @@ -1,7 +1,7 @@ <@item href="#">item 1 <@item href="#">item 2 - <@separator/> + <@item separator/> <@item href="#">item 3 <@item href="#">item 4 <@item href="#">item 5 diff --git a/src/components/ebay-fake-menu-button/marko-tag.json b/src/components/ebay-fake-menu-button/marko-tag.json index 460e555bb..9d64b717d 100644 --- a/src/components/ebay-fake-menu-button/marko-tag.json +++ b/src/components/ebay-fake-menu-button/marko-tag.json @@ -1,6 +1,5 @@ { "template": "./index.marko", - "transformer": "../../common/transformers/menu-separator", "@*": { "targetProperty": null, "type": "expression" @@ -49,11 +48,5 @@ "@class": "string", "@style": "string" }, - "@separator []": { - "@html-attributes": "expression", - "@class": "string", - "@style": "string", - "@separator": "boolean" - }, "description": "[view documentation](https://ebay.github.io/ebayui-core/?path=/story/buttons-ebay-fake-menu-button)" } diff --git a/src/components/ebay-fake-menu/component.ts b/src/components/ebay-fake-menu/component.ts index 202cb1c0a..7d54dca00 100644 --- a/src/components/ebay-fake-menu/component.ts +++ b/src/components/ebay-fake-menu/component.ts @@ -25,7 +25,6 @@ interface FakeMenuInput extends BaseMenuInput, Omit { items?: Marko.AttrTag; - separator?: Marko.AttrTag; "class-prefix"?: string; reverse?: boolean; "fix-width"?: boolean; diff --git a/src/components/ebay-fake-menu/examples/separator.marko b/src/components/ebay-fake-menu/examples/separator.marko index 1b0393173..a98613e1e 100644 --- a/src/components/ebay-fake-menu/examples/separator.marko +++ b/src/components/ebay-fake-menu/examples/separator.marko @@ -1,7 +1,7 @@ <@item href="#">item 1 that has very long text <@item href="#">item 2 - <@separator/> + <@item separator/> <@item href="#">item 3 <@item href="#">item 4 <@item href="#">item 5 diff --git a/src/components/ebay-fake-menu/marko-tag.json b/src/components/ebay-fake-menu/marko-tag.json index 06c60325f..e171c270b 100644 --- a/src/components/ebay-fake-menu/marko-tag.json +++ b/src/components/ebay-fake-menu/marko-tag.json @@ -4,7 +4,6 @@ "type": "expression" }, "template": "./index.marko", - "transformer": "../../common/transformers/menu-separator", "@html-attributes": "expression", "@class": "string", "@style": "string", @@ -27,11 +26,5 @@ "@badge-aria-label": "string", "@separator": "boolean" }, - "@separator []": { - "@html-attributes": "expression", - "@class": "string", - "@style": "string", - "@separator": "boolean" - }, "description": "[view documentation](https://ebay.github.io/ebayui-core/?path=/story/building-blocks-ebay-fake-menu)" } diff --git a/src/components/ebay-infotip/test/__snapshots__/test.server.js.snap b/src/components/ebay-infotip/test/__snapshots__/test.server.js.snap index 7af77bc2c..fb0779292 100644 --- a/src/components/ebay-infotip/test/__snapshots__/test.server.js.snap +++ b/src/components/ebay-infotip/test/__snapshots__/test.server.js.snap @@ -338,11 +338,6 @@ exports[`infotip modal > renders default 1`] = `  -   diff --git a/src/components/ebay-lightbox-dialog/component.ts b/src/components/ebay-lightbox-dialog/component.ts deleted file mode 100644 index dec70e7e9..000000000 --- a/src/components/ebay-lightbox-dialog/component.ts +++ /dev/null @@ -1,100 +0,0 @@ -import type DialogBase from "../components/ebay-dialog-base/component"; -import type { Input, State } from "./index.marko"; -class LightboxDialog extends Marko.Component { - declare touches: { - identifier: number; - pageY: number; - }[]; - - setExpandedState(isExpanded: boolean) { - if (isExpanded !== this.state.expanded) { - this.state.expanded = isExpanded; - if (isExpanded) { - this.emit("expanded"); - } else { - this.emit("collapsed"); - } - } - } - - handleExpand() { - this.setExpandedState(!this.state.expanded); - } - - handleScroll() { - this.setExpandedState(true); - } - - handleTouchStart(event: TouchEvent) { - const touches = event.changedTouches; - this.touches = []; - // Sometimes there can be multiple touches on an object. - // This saves the current touches when the user begins to tap on the handle - for (let i = 0; i < touches.length; i++) { - const { identifier, pageY } = touches[i]; - this.touches.push({ - identifier, - pageY, - }); - } - } - - handleTouchMove(event: TouchEvent) { - // This will verify that a given touch moved about 30px up/down from the handle - // If so, then it will either expand or collapse the drawer. - // It uses all the saved touch start events - if (this.touches.length) { - for (let i = 0; i < event.changedTouches.length; i++) { - const current = event.changedTouches[i]; - const compare = this.touches.findIndex( - (item) => item.identifier === current.identifier, - ); - const diff = current.pageY - this.touches[compare].pageY; - - if (diff > 30) { - // Drag down, collpase - if (this.state.expanded) { - this.setExpandedState(false); - } else { - this.getComponent("dialog").state.open = - false; - } - this.handleTouchEnd(event); - } else if (diff < -30) { - this.setExpandedState(true); - this.handleTouchEnd(event); - } - } - } - } - - handleTouchEnd(event: TouchEvent) { - // Remove all matching touches from the list when the touch is over. - // This is done this way in case a finger is lifted up before another finger - for (let i = 0; i < event.changedTouches.length; i++) { - const current = event.changedTouches[i]; - const idx = this.touches.findIndex( - (item) => item.identifier === current.identifier, - ); - if (idx > -1) { - this.touches.splice(idx, 1); - } - } - } - - onCreate() { - this.state = { - expanded: false, - }; - } - - onMount() { - this.touches = []; - } - - onInput(input: Input) { - this.state = { expanded: input.expanded || false }; - } -} - -export default LightboxDialog; diff --git a/src/components/ebay-lightbox-dialog/examples/default.marko b/src/components/ebay-lightbox-dialog/examples/default.marko index 0df0aeace..29c70c7f5 100644 --- a/src/components/ebay-lightbox-dialog/examples/default.marko +++ b/src/components/ebay-lightbox-dialog/examples/default.marko @@ -35,8 +35,6 @@ class { open=state.open on-close("closeDialog") on-open("emit", "open") - on-expanded("emit", "expanded") - on-collapsed("emit", "collapsed") ...dialogBaseInput > diff --git a/src/components/ebay-lightbox-dialog/examples/focus.marko b/src/components/ebay-lightbox-dialog/examples/focus.marko index 62b259da4..be6b204ab 100644 --- a/src/components/ebay-lightbox-dialog/examples/focus.marko +++ b/src/components/ebay-lightbox-dialog/examples/focus.marko @@ -4,8 +4,6 @@ open=state.open on-close('closeDialog') on-open("emit", "open") - on-expanded("emit", "expanded") - on-collapsed("emit", "collapsed") ...input > <@header>Heading diff --git a/src/components/ebay-lightbox-dialog/examples/scrolling.marko b/src/components/ebay-lightbox-dialog/examples/scrolling.marko index db078f617..19acdb3e9 100644 --- a/src/components/ebay-lightbox-dialog/examples/scrolling.marko +++ b/src/components/ebay-lightbox-dialog/examples/scrolling.marko @@ -22,8 +22,6 @@ class { open=state.open on-close("closeDialog") on-open("emit", "open") - on-expanded("emit", "expanded") - on-collapsed("emit", "collapsed") ...input > <@header>Heading diff --git a/src/components/ebay-lightbox-dialog/examples/with-footer.marko b/src/components/ebay-lightbox-dialog/examples/with-footer.marko index ec23df903..00d64afb3 100644 --- a/src/components/ebay-lightbox-dialog/examples/with-footer.marko +++ b/src/components/ebay-lightbox-dialog/examples/with-footer.marko @@ -3,8 +3,6 @@ open=state.open on-close("closeDialog") on-open("emit", "open") - on-expanded("emit", "expanded") - on-collapsed("emit", "collapsed") ...input > <@header>Heading diff --git a/src/components/ebay-lightbox-dialog/examples/with-prev-button.marko b/src/components/ebay-lightbox-dialog/examples/with-prev-button.marko index 13d0d4f17..dd1ca9bd2 100644 --- a/src/components/ebay-lightbox-dialog/examples/with-prev-button.marko +++ b/src/components/ebay-lightbox-dialog/examples/with-prev-button.marko @@ -4,8 +4,6 @@ on-close("closeDialog") on-open("emit", "open") on-prevButtonClick("emit", "prev-button-click") - on-expanded("emit", "expanded") - on-collapsed("emit", "collapsed") ...input > <@header>Heading diff --git a/src/components/ebay-lightbox-dialog/index.marko b/src/components/ebay-lightbox-dialog/index.marko index 6411399b0..775094dd4 100644 --- a/src/components/ebay-lightbox-dialog/index.marko +++ b/src/components/ebay-lightbox-dialog/index.marko @@ -1,18 +1,12 @@ static const validSizes = ["wide", "narrow", "fullscreen", "large"] as const; -import type { AttrString } from "marko/tags-html"; import type { WithNormalizedProps } from "../../global"; import type { Input as DialogBaseInput } from "../components/ebay-dialog-base/component"; export interface LightboxDialogInput extends Omit { variant?: "_mini"; - expanded?: boolean; - "a11y-maximize-text"?: AttrString; - "a11y-minimize-text"?: AttrString; "banner-img-src"?: string; size?: (typeof validSizes)[number]; "banner-img-position"?: Marko.CSS.Properties["backgroundPosition"]; - "on-expanded"?: () => void; - "on-collapsed"?: () => void; "on-open"?: DialogBaseInput["on-open"]; "on-close"?: DialogBaseInput["on-close"]; "on-prevButtonClick"?: DialogBaseInput["on-prevButtonClick"]; @@ -20,16 +14,10 @@ export interface LightboxDialogInput extends Omit {} -export interface State { - expanded: boolean; -} - $ const { class: inputClass, variant, buttonPosition = "right", - a11yMaximizeText = "Maximize Lightbox Dialog", - a11yMinimizeText = "Minimize Lightbox Dialog", bannerImgSrc, bannerImgPosition, size, @@ -38,7 +26,6 @@ $ const { } = input; $ var isMini = variant === "_mini"; -$ var handleLabel = state.expanded ? a11yMinimizeText : a11yMaximizeText; - <@top> - - -  -  -" -`; - -exports[`renders in progress progress-stepper 1`] = ` -" -  -  - Shipment progress -  -  -  -  -  -  -  -  -  -  -  - complete -  -  -  -  -  - 

 - Started - 

 - 

 - July 3rd - 

 -  -  -  -  -  -  -  - complete -  -  -  -  -  - 

 - Shipped - 

 - 

 - July 4th - 

 -  -  -  -  -  -  -  - current -   @@ -1424,16 +1198,16 @@ exports[`renders in progress progress-stepper 1`] = ` class="progress-stepper__icon" >      upcoming  @@ -1594,16 +1368,16 @@ exports[`renders vertical progress-stepper 1`] = ` class="progress-stepper__icon" >   current  @@ -1635,16 +1409,16 @@ exports[`renders vertical progress-stepper 1`] = ` class="progress-stepper__icon" >      upcoming  diff --git a/src/components/ebay-progress-stepper/test/test.server.js b/src/components/ebay-progress-stepper/test/test.server.js index b1b7927d8..74841f83d 100644 --- a/src/components/ebay-progress-stepper/test/test.server.js +++ b/src/components/ebay-progress-stepper/test/test.server.js @@ -32,10 +32,6 @@ it("renders blocked progress-stepper", async () => { await htmlSnap(Blocked); }); -it("renders in old progress progress-stepper (remove next version)", async () => { - await htmlSnap(InProgress, { defaultState: "current" }); -}); - it("renders default without pragraph", async () => { await htmlSnap(InProgress, { autoParagraph: false,