@travelopia/web-components 0.0.1 → 0.0.3

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.
@@ -0,0 +1,2 @@
1
+ (()=>{"use strict";class e extends HTMLElement{constructor(){var e;super(),null===(e=document.querySelector("body"))||void 0===e||e.appendChild(this)}connectedCallback(){this.addEventListener("click",this.handleClick.bind(this))}open(){this.setAttribute("open","yes")}close(){this.removeAttribute("open")}handleClick(e){e.target===this&&"yes"===this.getAttribute("overlay-click-close")&&(e.preventDefault(),e.stopPropagation(),this.close())}}class t extends HTMLElement{connectedCallback(){const e=this.querySelector("button");null==e||e.addEventListener("click",this.closeModal.bind(this))}closeModal(){const e=this.closest("tp-modal");null==e||e.close()}}customElements.define("tp-modal",e),customElements.define("tp-modal-close",t)})();
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dist/modal/index.js","mappings":"mBAGO,MAAMA,UAAuBC,YAInC,WAAAC,G,MACCC,QACgC,QAAhC,EAAAC,SAASC,cAAe,eAAQ,SAAEC,YAAaC,KAChD,CAKA,iBAAAC,GACCD,KAAKE,iBAAkB,QAASF,KAAKG,YAAYC,KAAMJ,MACxD,CAKA,IAAAK,GACCL,KAAKM,aAAc,OAAQ,MAC5B,CAKA,KAAAC,GACCP,KAAKQ,gBAAiB,OACvB,CAOA,WAAAL,CAAaM,GACPA,EAAEC,SAAWV,MAAQ,QAAUA,KAAKW,aAAc,yBACtDF,EAAEG,iBACFH,EAAEI,kBACFb,KAAKO,QAEP,ECpCM,MAAMO,UAA4BpB,YAIxC,iBAAAO,GACC,MAAMc,EAAmCf,KAAKF,cAAe,UAC7DiB,SAAAA,EAAQb,iBAAkB,QAASF,KAAKgB,WAAWZ,KAAMJ,MAC1D,CAKA,UAAAgB,GACC,MAAMC,EAA+BjB,KAAKkB,QAAS,YACnDD,SAAAA,EAAOV,OACR,ECTDY,eAAeC,OAAQ,WAAY3B,GACnC0B,eAAeC,OAAQ,iBAAkBN,E","sources":["webpack://web-components/./src/modal/tp-modal.ts","webpack://web-components/./src/modal/tp-modal-close.ts","webpack://web-components/./src/modal/index.ts"],"sourcesContent":["/**\n * TP Modal.\n */\nexport class TPModalElement extends HTMLElement {\n\t/**\n\t * Constructor.\n\t */\n\tconstructor() {\n\t\tsuper();\n\t\tdocument.querySelector( 'body' )?.appendChild( this );\n\t}\n\n\t/**\n\t * Connected callback.\n\t */\n\tconnectedCallback(): void {\n\t\tthis.addEventListener( 'click', this.handleClick.bind( this ) );\n\t}\n\n\t/**\n\t * Open the modal.\n\t */\n\topen(): void {\n\t\tthis.setAttribute( 'open', 'yes' );\n\t}\n\n\t/**\n\t * Close the modal.\n\t */\n\tclose(): void {\n\t\tthis.removeAttribute( 'open' );\n\t}\n\n\t/**\n\t * Handle when the component is clicked.\n\t *\n\t * @param {Event} e Event.\n\t */\n\thandleClick( e: Event ): void {\n\t\tif ( e.target === this && 'yes' === this.getAttribute( 'overlay-click-close' ) ) {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t\tthis.close();\n\t\t}\n\t}\n}\n","/**\n * Internal dependencies.\n */\nimport { TPModalElement } from './tp-modal';\n\n/**\n * TP Modal Close.\n */\nexport class TPModalCloseElement extends HTMLElement {\n\t/**\n\t * Connected callback.\n\t */\n\tconnectedCallback(): void {\n\t\tconst button: HTMLButtonElement | null = this.querySelector( 'button' );\n\t\tbutton?.addEventListener( 'click', this.closeModal.bind( this ) );\n\t}\n\n\t/**\n\t * Close the modal.\n\t */\n\tcloseModal(): void {\n\t\tconst modal: TPModalElement | null = this.closest( 'tp-modal' );\n\t\tmodal?.close();\n\t}\n}\n","/**\n * Styles.\n */\nimport './style.scss';\n\n/**\n * Components.\n */\nimport { TPModalElement } from './tp-modal';\nimport { TPModalCloseElement } from './tp-modal-close';\n\n/**\n * Register Components.\n */\ncustomElements.define( 'tp-modal', TPModalElement );\ncustomElements.define( 'tp-modal-close', TPModalCloseElement );\n"],"names":["TPModalElement","HTMLElement","constructor","super","document","querySelector","appendChild","this","connectedCallback","addEventListener","handleClick","bind","open","setAttribute","close","removeAttribute","e","target","getAttribute","preventDefault","stopPropagation","TPModalCloseElement","button","closeModal","modal","closest","customElements","define"],"sourceRoot":""}
@@ -0,0 +1 @@
1
+ tp-modal{display:none;background-color:rgba(0,0,0,.5);backdrop-filter:blur(2px);position:fixed;height:100%;width:100%;left:0;top:0;z-index:99;max-width:100%;overflow-y:auto;padding:20px;box-sizing:border-box}tp-modal[open]{display:flex}tp-modal-close{position:absolute;top:20px;right:20px}tp-modal-content{display:block;min-width:0;margin:auto;padding:20px;background-color:#fff;max-width:80ch}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travelopia/web-components",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Accessible web components for the modern web",
5
5
  "scripts": {
6
6
  "build": "webpack --config ./webpack.config.js --mode production --env=production",
@@ -30,5 +30,9 @@
30
30
  "webpack": "^5.89.0",
31
31
  "webpack-cli": "^5.1.4",
32
32
  "webpack-notifier": "^1.15.0"
33
+ },
34
+ "exports": {
35
+ "./*": "./dist/*",
36
+ "./package.json": "./package.json"
33
37
  }
34
38
  }
package/.browserslistrc DELETED
@@ -1 +0,0 @@
1
- since 2019
package/.editorconfig DELETED
@@ -1,18 +0,0 @@
1
- # WordPress Coding Standards
2
- # https://make.wordpress.org/core/handbook/coding-standards/
3
-
4
- root = true
5
-
6
- [*]
7
- charset = utf-8
8
- end_of_line = lf
9
- insert_final_newline = true
10
- trim_trailing_whitespace = true
11
- indent_style = tab
12
-
13
- [{.jshintrc,*.json,*.yml,*.neon}]
14
- indent_style = space
15
- indent_size = 2
16
-
17
- [*.txt]
18
- end_of_line = crlf
package/.eslintignore DELETED
@@ -1,3 +0,0 @@
1
- node_modules
2
- dist
3
- vendor
package/.eslintrc.json DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "extends": [ "plugin:@wordpress/eslint-plugin/recommended-with-formatting" ],
3
- "overrides": [
4
- {
5
- "files": ["*.ts"],
6
- "rules": {
7
- "no-undef": "off",
8
- "no-unused-vars": "off",
9
- "import/no-unresolved": "off",
10
- "import/no-extraneous-dependencies": "off"
11
- }
12
- }
13
- ]
14
- }
package/.gitignore DELETED
@@ -1,24 +0,0 @@
1
- # --- Windows and Mac files
2
- [Tt]humbs.db
3
- .DS_Store
4
-
5
- # --- Packages
6
- node_modules
7
- vendor
8
-
9
- # --- Root
10
- /*
11
- !.browserslistrc
12
- !.editorconfig
13
- !.eslintignore
14
- !.eslintrc.json
15
- !.gitignore
16
- !LICENSE
17
- !package.json
18
- !package-lock.json
19
- !README.md
20
- !tsconfig.json
21
- !webpack.config.js
22
-
23
- # --- Components
24
- !src
package/tsconfig.json DELETED
@@ -1,22 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "strict": true,
4
- "noImplicitAny": true,
5
- "noUnusedLocals": true,
6
- "noUnusedParameters": true,
7
- "strictNullChecks": true,
8
- "strictFunctionTypes": true,
9
- "strictBindCallApply": true,
10
- "strictPropertyInitialization": true,
11
- "noImplicitThis": true,
12
- "alwaysStrict": true,
13
- "noImplicitReturns": true,
14
- "module": "es6",
15
- "target": "es6",
16
- "jsx": "react-jsx",
17
- "allowJs": true,
18
- "moduleResolution": "node",
19
- "sourceMap": true,
20
- "allowSyntheticDefaultImports": true
21
- }
22
- }
package/webpack.config.js DELETED
@@ -1,88 +0,0 @@
1
- // External dependencies.
2
- const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' );
3
- const WebpackNotifierPlugin = require( 'webpack-notifier' );
4
- const TerserPlugin = require( 'terser-webpack-plugin' );
5
-
6
- // Config.
7
- module.exports = ( env ) => {
8
- // Build configuration.
9
- const buildConfig = {
10
- entry: {
11
- modal: './src/modal/index.ts',
12
- },
13
- module: {
14
- rules: [
15
- {
16
- test: /\.tsx?$/,
17
- use: 'ts-loader',
18
- exclude: /node_modules/,
19
- },
20
- {
21
- test: /\.(sa|sc|c)ss$/,
22
- use: [
23
- MiniCssExtractPlugin.loader,
24
- {
25
- loader: 'css-loader',
26
- options: {
27
- url: false,
28
- sourceMap: false,
29
- },
30
- },
31
- {
32
- loader: 'postcss-loader',
33
- },
34
- {
35
- loader: 'sass-loader',
36
- options: {
37
- sassOptions: {
38
- outputStyle: 'compressed',
39
- },
40
- },
41
- },
42
- ],
43
- },
44
- ],
45
- },
46
- resolve: {
47
- extensions: [ '*', '.js', '.ts', '.tsx' ],
48
- },
49
- output: {
50
- path: __dirname,
51
- filename: `dist/[name]/index.js`,
52
- publicPath: '/',
53
- },
54
- optimization: {
55
- removeEmptyChunks: true,
56
- minimize: true,
57
- minimizer: [ new TerserPlugin( {
58
- parallel: true,
59
- terserOptions: {
60
- format: {
61
- comments: false,
62
- },
63
- },
64
- extractComments: false,
65
- } ) ],
66
- },
67
- plugins: [
68
- new MiniCssExtractPlugin( {
69
- filename: `dist/[name]/style.css`,
70
- } ),
71
- ],
72
- performance: {
73
- hints: false,
74
- },
75
- devtool: 'source-map',
76
- };
77
-
78
- // Development environment.
79
- if ( 'development' in env ) {
80
- buildConfig.plugins.push( new WebpackNotifierPlugin( {
81
- title: 'Build',
82
- alwaysNotify: true,
83
- } ) );
84
- }
85
-
86
- // Return config.
87
- return [ buildConfig ];
88
- };