Skip to content

Commit 3b6f529

Browse files
committed
feat: migrate over the customElements.define-related replacement + component dependency updates from #1579
1 parent 43d1878 commit 3b6f529

File tree

61 files changed

+270
-394
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+270
-394
lines changed

docs-site/src/components/bolt-select/bolt-select.standalone.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
// Initially inspired by https://github.com/adidas/choicesjs-stencil/blob/master/src/components/choicesjs-stencil/choicesjs-stencil.tsx
22

3-
import { props, define } from '@bolt/core/utils';
3+
import { props } from '@bolt/core/utils';
4+
import { customElement, html } from '@bolt/element';
45
import Choices from 'choices.js';
5-
import {
6-
withLitHtml,
7-
html,
8-
// render,
9-
} from '@bolt/core/renderers/renderer-lit-html';
6+
import { withLitHtml } from '@bolt/core/renderers/renderer-lit-html';
107
import { filterObject, isDefined, createSelectOptionData } from './utils';
118

129
import styles from './bolt-select.scss';
1310

14-
@define
15-
class BoltSelect extends withLitHtml() {
16-
static is = 'bolt-select';
17-
11+
@customElement('bolt-select')
12+
class BoltSelect extends withLitHtml {
1813
static props = {
1914
type: props.string, // single | multiple | text
2015
value: props.string,

docs-site/src/components/docs-search/docs-search.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import { props, define } from '@bolt/core/utils';
2-
import { withLitHtml, html } from '@bolt/core/renderers/renderer-lit-html';
3-
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
1+
import { props } from '@bolt/core/utils';
2+
import { customElement, unsafeHTML, html } from '@bolt/element';
3+
import { withLitHtml } from '@bolt/core/renderers/renderer-lit-html';
44
import docsearch from 'docsearch.js/dist/npm/src/lib/main.js';
55
import qs from 'querystring';
66

7-
@define
8-
class BoltDocsSearch extends withLitHtml() {
9-
static is = 'bds-docs-search';
10-
7+
@customElement('bds-docs-search')
8+
class BoltDocsSearch extends withLitHtml {
119
static props = {
1210
apiKey: props.string,
1311
indexName: props.string,

docs-site/src/components/radio-switch/change-case.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { props, define } from '@bolt/core/utils';
2-
import { html, withLitHtml } from '@bolt/core/renderers/renderer-lit-html';
1+
import { props } from '@bolt/core/utils';
2+
import { customElement, html } from '@bolt/element';
3+
import { withLitHtml } from '@bolt/core/renderers/renderer-lit-html';
34
const changeCase = require('change-case');
45

5-
@define
6-
class BoltChangeCase extends withLitHtml() {
7-
static is = 'bolt-change-case';
8-
6+
@customElement('bolt-change-case')
7+
class BoltChangeCase extends withLitHtml {
98
static props = {
109
mode: props.string,
1110
};

docs-site/src/components/radio-switch/radio-switch.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import { props, define, hasNativeShadowDomSupport } from '@bolt/core/utils';
2-
import { html, withLitHtml } from '@bolt/core/renderers/renderer-lit-html';
1+
import { html, customElement } from '@bolt/element';
2+
import { withLitHtml } from '@bolt/core/renderers/renderer-lit-html';
33
import classNames from 'classnames/bind';
44
import styles from './radio-switch.scss';
55
// let cx = classNames.bind(styles);
66

7-
@define
8-
class BoltRadioSwitch extends withLitHtml() {
9-
static is = 'bolt-radio-switch';
10-
7+
@customElement('bolt-radio-switch')
8+
class BoltRadioSwitch extends withLitHtml {
119
// static props = {
1210
// schema: props.object,
1311
// formData: props.object,

docs-site/src/components/schema-form/component-explorer.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import qs from 'querystring';
2-
import { define, props, defineContext, withContext } from '@bolt/core/utils';
2+
import { props, defineContext, withContext } from '@bolt/core/utils';
33
import { prepSchema } from './utils';
44
import isEqual from 'react-fast-compare';
5-
import { withLitHtml, html } from '@bolt/core/renderers/renderer-lit-html';
6-
import { styleMap } from 'lit-html/directives/style-map.js';
5+
import { withLitHtml, } from '@bolt/core/renderers/renderer-lit-html';
76
import { guard } from 'lit-html/directives/guard';
8-
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
7+
import { styleMap, html, unsafeHTML, customElement } from '@bolt/element';
98

109
// define which specific props to provide to children that subscribe
1110
export const ComponentExplorerContext = defineContext({
@@ -18,10 +17,9 @@ export const ComponentExplorerContext = defineContext({
1817
import styles from './component-explorer.scss';
1918
import globalStyles from '@bolt/global/styles/index.scss';
2019

21-
@define
22-
export default class ComponentExplorer extends withContext(withLitHtml()) {
23-
static is = 'bolt-component-explorer';
2420

21+
@customElement('bolt-component-explorer')
22+
export default class ComponentExplorer extends withContext(withLitHtml) {
2523
static props = {
2624
schemaUuid: props.string,
2725
schema: props.object,

docs-site/src/components/schema-form/schema-form.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import { h, withPreact } from '@bolt/core/renderers';
44
import isEqual from 'react-fast-compare';
55
import { ComponentExplorerContext } from './component-explorer';
66

7-
@define
8-
export default class SchemaForm extends withContext(withPreact()) {
9-
static is = 'bolt-schema-form';
7+
import { customElement } from '@bolt/element';
108

9+
@customElement('bolt-schema-form')
10+
export default class SchemaForm extends withContext(withPreact) {
1111
static props = {
1212
schema: props.object,
1313
formData: props.object,

packages/base-element/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ export {
99
findParentTag,
1010
} from './src/lib/utils';
1111

12+
export { convertInitialTags } from './src/lib/decorators';
1213
export { customElement, unsafeCSS } from 'lit-element';
1314
export { render, html } from 'lit-html';
1415
export { ifDefined } from 'lit-html/directives/if-defined';
16+
export { classMap } from 'lit-html/directives/class-map.js';
1517
export { styleMap } from 'lit-html/directives/style-map.js';
18+
export { unsafeHTML } from 'lit-html/directives/unsafe-html';

packages/base-element/src/BoltElement.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* eslint-disable no-unused-expressions */
2-
import { LitElement } from 'lit-element';
32
import { supportsAdoptingStyleSheets } from 'lit-element/lib/css-tag.js';
43
import { Slotify } from './Slotify.js';
54
import {
@@ -11,7 +10,7 @@ import {
1110
@renderAndRenderedEvents()
1211
@lazyStyles()
1312
@conditionalShadowDom()
14-
class BoltElement extends Slotify(LitElement) {
13+
class BoltElement extends Slotify {
1514
// patch to https://github.com/Polymer/lit-element/blob/master/src/lit-element.ts#L208
1615
// as a temp workaround to constructible stylesheets not working when
1716
// rendering inside + outside an iframe. Filing a bug with lit-element shortly!

packages/components/bolt-accordion/src/AccordionItem/index.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
import { withContext, define, props, css } from '@bolt/core/utils';
2-
import { withLitHtml, html } from '@bolt/core/renderers/renderer-lit-html';
3-
1+
import { html, customElement } from '@bolt/element';
2+
import { withContext, props, css } from '@bolt/core/utils';
3+
import { withLitHtml } from '@bolt/core/renderers/renderer-lit-html';
44
import styles from './accordion-item.scss';
55
import { AccordionItemTrigger } from './AccordionItemTrigger';
66
import { AccordionItemContent } from './AccordionItemContent';
77
import { AccordionContext } from '../accordion';
88

9-
@define
10-
class AccordionItem extends withContext(withLitHtml()) {
11-
static is = 'bolt-accordion-item';
12-
9+
@customElement('bolt-accordion-item')
10+
class AccordionItem extends withContext(withLitHtml) {
1311
static props = {
1412
open: props.boolean,
1513
contentSpacing: props.string,

packages/components/bolt-accordion/src/accordion.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
import {
2-
defineContext,
3-
withContext,
4-
define,
5-
props,
6-
css,
7-
} from '@bolt/core/utils';
8-
import { withLitHtml, html } from '@bolt/core/renderers/renderer-lit-html';
9-
1+
import { html, customElement } from '@bolt/element';
2+
import { defineContext, withContext, props, css } from '@bolt/core/utils';
3+
import { withLitHtml } from '@bolt/core/renderers/renderer-lit-html';
104
import styles from './accordion.scss';
115
import schema from '../accordion.schema.yml';
12-
136
import { Accordion } from './_accordion-handorgel';
147

158
// define which specific props to provide to children that subscribe
@@ -20,10 +13,8 @@ export const AccordionContext = defineContext({
2013
iconValign: schema.properties.icon_valign.default,
2114
});
2215

23-
@define
24-
class BoltAccordion extends withContext(withLitHtml()) {
25-
static is = 'bolt-accordion';
26-
16+
@customElement('bolt-accordion')
17+
class BoltAccordion extends withContext(withLitHtml) {
2718
static props = {
2819
single: props.boolean,
2920
noSeparator: props.boolean,

0 commit comments

Comments
 (0)