progressive-share-button 1.0.0-alpha.8 → 1.0.0-alpha.9

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/CHANGELOG.md CHANGED
@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.0.0-alpha.9] - 2021-03-01
9
+
10
+ ### Added
11
+
12
+ - Added typescript types for the `ProgressiveShareButton` class and default function.
13
+
14
+ ### Changed
15
+
16
+ - Changed: (breaking change) the import statement no longer initialized the web component on import. On some builds using typescript, the button would not be initialized without using the imported function. Now, after import, you must call the init function to initialize the web component, like `ProgressButton.init()`.
17
+ - Changed: (breaking change) the `ProgressiveShareButtonElement` class is now exported as `ProgressiveShareButtonClass`.
18
+
19
+ ### Fixed
20
+
21
+ - Fixed: The demo page has some incorrect class names in the example code. These have been corrected.
22
+
23
+
8
24
  ## [1.0.0-alpha.8] - 2023-02-27
9
25
 
10
26
  ### Changed
package/README.md CHANGED
@@ -43,6 +43,8 @@ main.js, if installed with npm
43
43
  ```javascript
44
44
  // Import the component, which is the default export, so no curly braces are needed.
45
45
  import ProgressiveShareButton from 'progressive-share-button';
46
+ // Initialize the component
47
+ ProgressiveShareButton.init();
46
48
  ```
47
49
 
48
50
  ### Customizing the component name
@@ -51,9 +53,9 @@ If you want to customize the component name, you can import the element class di
51
53
 
52
54
 
53
55
  ```javascript
54
- import { ProgressiveShareButtonElement } from 'progressive-share-button';
56
+ import { ProgressiveShareButtonClass } from 'progressive-share-button';
55
57
  // Initialize the component
56
- customElements.define('my-share-button', ProgressiveShareButtonElement);
58
+ customElements.define('my-share-button', ProgressiveShareButtonClass);
57
59
 
58
60
  ```
59
61
 
@@ -229,7 +231,7 @@ There are two custom event emitted by the component: `progressive-share-success`
229
231
  // example of listening for the custom events
230
232
  document.addEventListener('progressive-share-success', (e) => {
231
233
  // e.detail contains the share data that was shared
232
- console.log('The progressive-share event was heard.', e.detail);
234
+ console.log('The progressive-share-success event was heard.', e.detail);
233
235
  });
234
236
  document.addEventListener('progressive-share-fail', (e) => {
235
237
  // e.detail contains the error message
@@ -1,6 +1,13 @@
1
- class ProgressiveShareButtonElement extends HTMLElement {
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
7
+ class ProgressiveShareButtonClass extends HTMLElement {
2
8
  constructor() {
3
9
  super();
10
+ __publicField(this, "iconSize");
4
11
  this.attachShadow({ mode: "open" });
5
12
  this.iconSize = () => {
6
13
  const size = this.getAttribute("icon-size") ?? "";
@@ -46,7 +53,9 @@ class ProgressiveShareButtonElement extends HTMLElement {
46
53
  this.addEventListener("click", this.share);
47
54
  }
48
55
  } else {
49
- console.warn("ProgressiveShareButton disabled due to lack of Web Share API support on this browser.");
56
+ console.warn(
57
+ "ProgressiveShareButton disabled due to lack of Web Share API support on this browser."
58
+ );
50
59
  }
51
60
  }
52
61
  share() {
@@ -109,7 +118,7 @@ class ProgressiveShareButtonElement extends HTMLElement {
109
118
  }
110
119
  }
111
120
  }
112
- function ProgressiveShareButton() {
121
+ function init() {
113
122
  if (typeof navigator.share === "function") {
114
123
  console.log(
115
124
  "ProgressiveShareButton support initialized. <progressive-share-success /> element now available"
@@ -121,10 +130,13 @@ function ProgressiveShareButton() {
121
130
  }
122
131
  customElements.define(
123
132
  "progressive-share-button",
124
- ProgressiveShareButtonElement
133
+ ProgressiveShareButtonClass
125
134
  );
126
135
  return true;
127
136
  }
137
+ const main = {
138
+ init
139
+ };
128
140
  const iosShareIcon = '<svg xmlns="http://www.w3.org/2000/svg" part="shareIcon" viewBox="0 0 84.53 108.43" class="icon"><title>Share icon</title><desc>Square with upward arrow</desc><path d="m76.21,33.15h-23.38v5.28h23.38c1.72,0,3.04,1.32,3.04,2.91v58.77c0,1.58-1.32,2.91-3.04,2.91H8.32c-1.72,0-3.04-1.32-3.04-2.9v-58.64c0-1.58,1.32-2.91,3.04-2.91h20.74v-5.28H8.32c-4.62,0-8.32,3.7-8.32,8.19v58.77c0,4.49,3.7,8.19,8.32,8.19h67.88c4.62,0,8.32-3.7,8.32-8.19v-58.77c0-4.62-3.7-8.32-8.32-8.32h0Z"/><path d="m39.62,8.58v69.21h5.28V8.58l13.6,10.04,3.17-4.23L42.26,0l-19.41,14.4,3.17,4.23,13.6-10.04Z"/></svg>';
129
141
  const androidShareIcon = '<svg id="b" xmlns="http://www.w3.org/2000/svg" part="shareIcon" viewBox="0 0 18.19 21.46" class="icon"><title>Share icon</title><desc>Circle with smaller circles radiating out</desc><g id="c"><path d="m15.1,15.29c-.89,0-1.7.38-2.28.98l-6.98-3.84c.24-.43.38-.94.38-1.49s-.14-1.03-.38-1.49l7.22-4.03c.55.48,1.25.77,2.04.77,1.7,0,3.1-1.39,3.1-3.1s-1.39-3.1-3.1-3.1-3.1,1.39-3.1,3.1c0,.67.22,1.27.58,1.78l-7.18,4.01c-.58-.62-1.39-1.03-2.3-1.03-1.7,0-3.1,1.39-3.1,3.1s1.39,3.1,3.1,3.1c.91,0,1.73-.41,2.3-1.03l6.98,3.84c-.26.46-.41.96-.41,1.51,0,1.7,1.39,3.1,3.1,3.1s3.1-1.39,3.1-3.1-1.37-3.07-3.07-3.07h0Zm0-14.54c1.32,0,2.38,1.08,2.38,2.38s-1.08,2.38-2.38,2.38-2.38-1.08-2.38-2.38,1.06-2.38,2.38-2.38ZM3.1,13.32c-1.32,0-2.38-1.08-2.38-2.38s1.08-2.38,2.38-2.38,2.38,1.08,2.38,2.38-1.06,2.38-2.38,2.38Zm12,7.44c-1.32,0-2.38-1.08-2.38-2.38s1.08-2.38,2.38-2.38,2.38,1.08,2.38,2.38-1.08,2.38-2.38,2.38Z"/></g></svg>';
130
142
  const winShareIcon = '<svg id="b" xmlns="http://www.w3.org/2000/svg" part="shareIcon" viewBox="0 0 112.98 100.64" class="icon" ><title>Share icon</title><desc>Square with arrow coming out to the right</desc><g id="c"><path d="m80.68,16.3l22.7,22.65-22.7,22.64v-11.44h-6.78c-18.27,0-33.35,6.91-43.25,13.14,2.34-12.07,7.94-21.2,16.75-27.16,10.12-6.84,22.02-7.83,26.67-7.94l6.6-.15v-11.73M73.93,0v21.43c-12.15.29-51.56,5.17-51.27,56.46,0,0,21.02-20.94,51.27-20.98v20.98l39.05-38.98L73.93,0ZM0,28.24v72.39h86.95v-20.98l-6.6,6.61v7.26H8.12V28.24H0Z"/></g></svg>';
@@ -172,11 +184,7 @@ function _getBoolean(stringValue) {
172
184
  return JSON.parse(stringValue);
173
185
  }
174
186
  }
175
- const main = (() => {
176
- ProgressiveShareButton();
177
- })();
178
187
  export {
179
- ProgressiveShareButton,
180
- ProgressiveShareButtonElement,
188
+ ProgressiveShareButtonClass,
181
189
  main as default
182
190
  };
@@ -1,10 +1,17 @@
1
1
  (function(global, factory) {
2
2
  typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["progressive-share-button"] = {}));
3
3
  })(this, function(exports2) {
4
- "use strict";
5
- class ProgressiveShareButtonElement extends HTMLElement {
4
+ "use strict";var __defProp = Object.defineProperty;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __publicField = (obj, key, value) => {
7
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
8
+ return value;
9
+ };
10
+
11
+ class ProgressiveShareButtonClass extends HTMLElement {
6
12
  constructor() {
7
13
  super();
14
+ __publicField(this, "iconSize");
8
15
  this.attachShadow({ mode: "open" });
9
16
  this.iconSize = () => {
10
17
  const size = this.getAttribute("icon-size") ?? "";
@@ -50,7 +57,9 @@
50
57
  this.addEventListener("click", this.share);
51
58
  }
52
59
  } else {
53
- console.warn("ProgressiveShareButton disabled due to lack of Web Share API support on this browser.");
60
+ console.warn(
61
+ "ProgressiveShareButton disabled due to lack of Web Share API support on this browser."
62
+ );
54
63
  }
55
64
  }
56
65
  share() {
@@ -113,7 +122,7 @@
113
122
  }
114
123
  }
115
124
  }
116
- function ProgressiveShareButton() {
125
+ function init() {
117
126
  if (typeof navigator.share === "function") {
118
127
  console.log(
119
128
  "ProgressiveShareButton support initialized. <progressive-share-success /> element now available"
@@ -125,10 +134,13 @@
125
134
  }
126
135
  customElements.define(
127
136
  "progressive-share-button",
128
- ProgressiveShareButtonElement
137
+ ProgressiveShareButtonClass
129
138
  );
130
139
  return true;
131
140
  }
141
+ const main = {
142
+ init
143
+ };
132
144
  const iosShareIcon = '<svg xmlns="http://www.w3.org/2000/svg" part="shareIcon" viewBox="0 0 84.53 108.43" class="icon"><title>Share icon</title><desc>Square with upward arrow</desc><path d="m76.21,33.15h-23.38v5.28h23.38c1.72,0,3.04,1.32,3.04,2.91v58.77c0,1.58-1.32,2.91-3.04,2.91H8.32c-1.72,0-3.04-1.32-3.04-2.9v-58.64c0-1.58,1.32-2.91,3.04-2.91h20.74v-5.28H8.32c-4.62,0-8.32,3.7-8.32,8.19v58.77c0,4.49,3.7,8.19,8.32,8.19h67.88c4.62,0,8.32-3.7,8.32-8.19v-58.77c0-4.62-3.7-8.32-8.32-8.32h0Z"/><path d="m39.62,8.58v69.21h5.28V8.58l13.6,10.04,3.17-4.23L42.26,0l-19.41,14.4,3.17,4.23,13.6-10.04Z"/></svg>';
133
145
  const androidShareIcon = '<svg id="b" xmlns="http://www.w3.org/2000/svg" part="shareIcon" viewBox="0 0 18.19 21.46" class="icon"><title>Share icon</title><desc>Circle with smaller circles radiating out</desc><g id="c"><path d="m15.1,15.29c-.89,0-1.7.38-2.28.98l-6.98-3.84c.24-.43.38-.94.38-1.49s-.14-1.03-.38-1.49l7.22-4.03c.55.48,1.25.77,2.04.77,1.7,0,3.1-1.39,3.1-3.1s-1.39-3.1-3.1-3.1-3.1,1.39-3.1,3.1c0,.67.22,1.27.58,1.78l-7.18,4.01c-.58-.62-1.39-1.03-2.3-1.03-1.7,0-3.1,1.39-3.1,3.1s1.39,3.1,3.1,3.1c.91,0,1.73-.41,2.3-1.03l6.98,3.84c-.26.46-.41.96-.41,1.51,0,1.7,1.39,3.1,3.1,3.1s3.1-1.39,3.1-3.1-1.37-3.07-3.07-3.07h0Zm0-14.54c1.32,0,2.38,1.08,2.38,2.38s-1.08,2.38-2.38,2.38-2.38-1.08-2.38-2.38,1.06-2.38,2.38-2.38ZM3.1,13.32c-1.32,0-2.38-1.08-2.38-2.38s1.08-2.38,2.38-2.38,2.38,1.08,2.38,2.38-1.06,2.38-2.38,2.38Zm12,7.44c-1.32,0-2.38-1.08-2.38-2.38s1.08-2.38,2.38-2.38,2.38,1.08,2.38,2.38-1.08,2.38-2.38,2.38Z"/></g></svg>';
134
146
  const winShareIcon = '<svg id="b" xmlns="http://www.w3.org/2000/svg" part="shareIcon" viewBox="0 0 112.98 100.64" class="icon" ><title>Share icon</title><desc>Square with arrow coming out to the right</desc><g id="c"><path d="m80.68,16.3l22.7,22.65-22.7,22.64v-11.44h-6.78c-18.27,0-33.35,6.91-43.25,13.14,2.34-12.07,7.94-21.2,16.75-27.16,10.12-6.84,22.02-7.83,26.67-7.94l6.6-.15v-11.73M73.93,0v21.43c-12.15.29-51.56,5.17-51.27,56.46,0,0,21.02-20.94,51.27-20.98v20.98l39.05-38.98L73.93,0ZM0,28.24v72.39h86.95v-20.98l-6.6,6.61v7.26H8.12V28.24H0Z"/></g></svg>';
@@ -176,11 +188,7 @@
176
188
  return JSON.parse(stringValue);
177
189
  }
178
190
  }
179
- const main = (() => {
180
- ProgressiveShareButton();
181
- })();
182
- exports2.ProgressiveShareButton = ProgressiveShareButton;
183
- exports2.ProgressiveShareButtonElement = ProgressiveShareButtonElement;
191
+ exports2.ProgressiveShareButtonClass = ProgressiveShareButtonClass;
184
192
  exports2.default = main;
185
193
  Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
186
194
  });
package/package.json CHANGED
@@ -1,38 +1,40 @@
1
1
  {
2
- "name": "progressive-share-button",
3
- "version": "1.0.0-alpha.8",
4
- "description": "A web componet that creates a OS-native share button.",
5
- "files": [
6
- "dist"
7
- ],
8
- "main": "./dist/progressive-share-button.umd.js",
9
- "repository": {
10
- "type": "git",
11
- "url": "https://github.com/johnfmorton/progressive-share-button"
12
- },
13
- "module": "./es/progressive-share-button.es.js",
14
- "exports": {
15
- ".": {
16
- "import": "./dist/progressive-share-button.es.js",
17
- "require": "./dist/progressive-share-button.umd.js"
2
+ "name": "progressive-share-button",
3
+ "version": "1.0.0-alpha.9",
4
+ "description": "A web componet that creates a OS-native share button.",
5
+ "files": [
6
+ "dist"
7
+ ],
8
+ "main": "./dist/progressive-share-button.umd.js",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/johnfmorton/progressive-share-button"
12
+ },
13
+ "module": "./es/progressive-share-button.es.js",
14
+ "unpkg": "./dist/progressive-share-button.umd.js",
15
+ "types": "./@types/progressive-share-button.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "import": "./dist/progressive-share-button.es.js",
19
+ "require": "./dist/progressive-share-button.umd.js"
20
+ }
21
+ },
22
+ "scripts": {
23
+ "dev": "vite --host 0.0.0.0 --port 8888",
24
+ "build": "vite build",
25
+ "preview": "vite preview",
26
+ "test": "echo \"Error: no test specified\" && exit 1"
27
+ },
28
+ "keywords": [
29
+ "share",
30
+ "button",
31
+ "progressive",
32
+ "web-components",
33
+ "web-share-api"
34
+ ],
35
+ "author": "John F. Morton <john@johnfmorton.com> (https://supergeekery.com)",
36
+ "license": "MIT",
37
+ "devDependencies": {
38
+ "vite": "^4.1.3"
18
39
  }
19
- },
20
- "scripts": {
21
- "dev": "vite --host 0.0.0.0 --port 8888",
22
- "build": "vite build",
23
- "preview": "vite preview",
24
- "test": "echo \"Error: no test specified\" && exit 1"
25
- },
26
- "keywords": [
27
- "share",
28
- "button",
29
- "progressive",
30
- "web-components",
31
- "web-share-api"
32
- ],
33
- "author": "John F. Morton <john@johnfmorton.com> (https://supergeekery.com)",
34
- "license": "MIT",
35
- "devDependencies": {
36
- "vite": "^4.1.3"
37
- }
38
40
  }