powr-sdk-web 6.2.1 → 6.4.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/dist/activities/PowrActivityList.js +3 -3
- package/dist/activities/index.js +3 -3
- package/dist/admin/PowrBaseAdminFull.js +4 -4
- package/dist/admin/coreSectionLoaders.js +3 -3
- package/dist/admin/optionalSectionLoaders.js +8 -8
- package/dist/calendar/index.js +2 -2
- package/dist/impersonate/index.js +468 -0
- package/dist/impersonate/storage.js +43 -0
- package/dist/index.js +62 -0
- package/dist/session/index.js +20 -18
- package/dist/shell/PowrBaseAppWrapper.js +56 -15
- package/dist/shell/parts.js +12 -1
- package/dist/shell/styles.js +3 -3
- package/dist/sso/api.js +11 -11
- package/dist/sso/index.js +16 -16
- package/dist/sso/openPowrLogin.js +18 -18
- package/dist/theme/PowrThemeProvider.js +23 -23
- package/dist/theme/PowrThemeSettings.js +19 -19
- package/dist/theme/host.js +16 -16
- package/dist/theme/initScript.js +16 -16
- package/dist/theme/tokens.js +30 -30
- package/dist/thread/components/AttachModal.js +2 -2
- package/dist/thread/components/ThreadComposer.js +3 -3
- package/dist/thread/components/ThreadItem.js +3 -3
- package/dist/thread/components/ThreadList.js +3 -3
- package/dist/thread/index.js +4 -4
- package/dist/thread/utils/linkify.js +4 -4
- package/dist/track/index.js +94 -0
- package/dist/utils/phone.js +3 -3
- package/dist/utils/useMediaQuery.js +3 -3
- package/package.json +67 -67
package/dist/theme/initScript.js
CHANGED
|
@@ -13,22 +13,22 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
13
13
|
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
14
14
|
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
15
15
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
16
|
-
/**
|
|
17
|
-
* No-flash head script.
|
|
18
|
-
*
|
|
19
|
-
* `PowrThemeProvider` applies vars in an effect, so a cached dark user sees one
|
|
20
|
-
* light frame on hard reload. This returns a tiny inline script that reads the
|
|
21
|
-
* same localStorage cache and paints `<html>` before React runs.
|
|
22
|
-
*
|
|
23
|
-
* No logic is duplicated: the css-var table for every scheme × preset × density
|
|
24
|
-
* is precomputed here with `resolvePowrTokens` and embedded. The script only
|
|
25
|
-
* looks up.
|
|
26
|
-
*
|
|
27
|
-
* Next (app router) root layout:
|
|
28
|
-
* <head><script dangerouslySetInnerHTML={{ __html: powrThemeInitScript({ projectId, theme, presets }) }} /></head>
|
|
29
|
-
*
|
|
30
|
-
* @param {object} opts - The same `theme` / `presets` / `projectId` you give the provider.
|
|
31
|
-
* @returns {string} JavaScript source.
|
|
16
|
+
/**
|
|
17
|
+
* No-flash head script.
|
|
18
|
+
*
|
|
19
|
+
* `PowrThemeProvider` applies vars in an effect, so a cached dark user sees one
|
|
20
|
+
* light frame on hard reload. This returns a tiny inline script that reads the
|
|
21
|
+
* same localStorage cache and paints `<html>` before React runs.
|
|
22
|
+
*
|
|
23
|
+
* No logic is duplicated: the css-var table for every scheme × preset × density
|
|
24
|
+
* is precomputed here with `resolvePowrTokens` and embedded. The script only
|
|
25
|
+
* looks up.
|
|
26
|
+
*
|
|
27
|
+
* Next (app router) root layout:
|
|
28
|
+
* <head><script dangerouslySetInnerHTML={{ __html: powrThemeInitScript({ projectId, theme, presets }) }} /></head>
|
|
29
|
+
*
|
|
30
|
+
* @param {object} opts - The same `theme` / `presets` / `projectId` you give the provider.
|
|
31
|
+
* @returns {string} JavaScript source.
|
|
32
32
|
*/
|
|
33
33
|
function powrThemeInitScript() {
|
|
34
34
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
package/dist/theme/tokens.js
CHANGED
|
@@ -25,20 +25,20 @@ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol
|
|
|
25
25
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
26
26
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
27
27
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
28
|
-
/**
|
|
29
|
-
* Powr theme token contract.
|
|
30
|
-
*
|
|
31
|
-
* Ten CSS variables every Powr web app and every SDK component share.
|
|
32
|
-
* The SDK ships structure only (light / dark scheme, density). Colours that
|
|
33
|
-
* make a product look like itself come from the product via `theme` and
|
|
34
|
-
* `presets`.
|
|
35
|
-
*
|
|
36
|
-
* Components read `var(--powr-<name>, <today's hex>)` inline — no CSS file,
|
|
37
|
-
* no Tailwind colour classes, so a bump changes nothing until a product
|
|
38
|
-
* mounts `PowrThemeProvider`.
|
|
39
|
-
*
|
|
40
|
-
* Vocabulary: `scheme` = light / dark / system. `mode` is reserved for the
|
|
41
|
-
* layout shape (`sidebar` / `topbar` …) that `PowrBaseAppWrapper` owns.
|
|
28
|
+
/**
|
|
29
|
+
* Powr theme token contract.
|
|
30
|
+
*
|
|
31
|
+
* Ten CSS variables every Powr web app and every SDK component share.
|
|
32
|
+
* The SDK ships structure only (light / dark scheme, density). Colours that
|
|
33
|
+
* make a product look like itself come from the product via `theme` and
|
|
34
|
+
* `presets`.
|
|
35
|
+
*
|
|
36
|
+
* Components read `var(--powr-<name>, <today's hex>)` inline — no CSS file,
|
|
37
|
+
* no Tailwind colour classes, so a bump changes nothing until a product
|
|
38
|
+
* mounts `PowrThemeProvider`.
|
|
39
|
+
*
|
|
40
|
+
* Vocabulary: `scheme` = light / dark / system. `mode` is reserved for the
|
|
41
|
+
* layout shape (`sidebar` / `topbar` …) that `PowrBaseAppWrapper` owns.
|
|
42
42
|
*/
|
|
43
43
|
|
|
44
44
|
/** token key → CSS variable (without the `--powr-` prefix). */
|
|
@@ -103,9 +103,9 @@ var BASE_BY_SCHEME = {
|
|
|
103
103
|
dark: DARK_POWR_TOKENS
|
|
104
104
|
};
|
|
105
105
|
|
|
106
|
-
/**
|
|
107
|
-
* `powrVar("primary", "#2563eb")` → `var(--powr-primary, #2563eb)`.
|
|
108
|
-
* Components use this so the fallback stays today's value.
|
|
106
|
+
/**
|
|
107
|
+
* `powrVar("primary", "#2563eb")` → `var(--powr-primary, #2563eb)`.
|
|
108
|
+
* Components use this so the fallback stays today's value.
|
|
109
109
|
*/
|
|
110
110
|
function powrVar(key, fallback) {
|
|
111
111
|
var name = POWR_TOKENS[key] || key;
|
|
@@ -130,9 +130,9 @@ function pickKnown(tokens) {
|
|
|
130
130
|
return out;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
/**
|
|
134
|
-
* Product `theme` may be flat (light only) or `{ light, dark }`.
|
|
135
|
-
* Returns the token overrides for one resolved scheme.
|
|
133
|
+
/**
|
|
134
|
+
* Product `theme` may be flat (light only) or `{ light, dark }`.
|
|
135
|
+
* Returns the token overrides for one resolved scheme.
|
|
136
136
|
*/
|
|
137
137
|
function themeForScheme(theme, scheme) {
|
|
138
138
|
if (!theme || _typeof(theme) !== "object") return {};
|
|
@@ -156,13 +156,13 @@ function normalizeDensity(density) {
|
|
|
156
156
|
return Object.prototype.hasOwnProperty.call(POWR_DENSITIES, density) ? density : DEFAULT_POWR_DENSITY;
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
/**
|
|
160
|
-
* Pure resolver. Order: structural base (light/dark) ← product theme[scheme]
|
|
161
|
-
* ← chosen preset (`tokens` / `dark`) ← density.
|
|
162
|
-
*
|
|
163
|
-
* `scheme` must already be `light` or `dark` (resolve `system` first).
|
|
164
|
-
* Also used by the head init script (card 3) so the server and the client
|
|
165
|
-
* compute the same variables.
|
|
159
|
+
/**
|
|
160
|
+
* Pure resolver. Order: structural base (light/dark) ← product theme[scheme]
|
|
161
|
+
* ← chosen preset (`tokens` / `dark`) ← density.
|
|
162
|
+
*
|
|
163
|
+
* `scheme` must already be `light` or `dark` (resolve `system` first).
|
|
164
|
+
* Also used by the head init script (card 3) so the server and the client
|
|
165
|
+
* compute the same variables.
|
|
166
166
|
*/
|
|
167
167
|
function resolvePowrTokens() {
|
|
168
168
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
@@ -186,9 +186,9 @@ function resolvePowrTokens() {
|
|
|
186
186
|
};
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
/**
|
|
190
|
-
* `{ bg: "#fff" }` → `{ "--powr-bg": "#fff", "--powr-density": "1" }`.
|
|
191
|
-
* Safe to spread into a React `style` or to write on `document.documentElement`.
|
|
189
|
+
/**
|
|
190
|
+
* `{ bg: "#fff" }` → `{ "--powr-bg": "#fff", "--powr-density": "1" }`.
|
|
191
|
+
* Safe to spread into a React `style` or to write on `document.documentElement`.
|
|
192
192
|
*/
|
|
193
193
|
function tokensToCssVars(tokens, densityScale) {
|
|
194
194
|
var out = {};
|
|
@@ -8,8 +8,8 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _uploader = _interopRequireDefault(require("../../uploader"));
|
|
10
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
11
|
-
/**
|
|
12
|
-
* Shared attach modal used by thread (comments + chat). Uses PowrBaseUploader.
|
|
11
|
+
/**
|
|
12
|
+
* Shared attach modal used by thread (comments + chat). Uses PowrBaseUploader.
|
|
13
13
|
*/
|
|
14
14
|
var AttachModal = function AttachModal(_ref) {
|
|
15
15
|
var open = _ref.open,
|
|
@@ -7,9 +7,9 @@ exports["default"] = void 0;
|
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
10
|
-
/**
|
|
11
|
-
* Composer: textarea, optional attach button, send button.
|
|
12
|
-
* variant 'message' = rectangular send button; 'comment' = pill style with play button.
|
|
10
|
+
/**
|
|
11
|
+
* Composer: textarea, optional attach button, send button.
|
|
12
|
+
* variant 'message' = rectangular send button; 'comment' = pill style with play button.
|
|
13
13
|
*/
|
|
14
14
|
var ThreadComposer = function ThreadComposer(_ref) {
|
|
15
15
|
var value = _ref.value,
|
|
@@ -16,9 +16,9 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
16
16
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
17
17
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
18
18
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
19
|
-
/**
|
|
20
|
-
* Renders a single thread item. variant: 'message' = chat bubble (isOwn right), 'comment' = comment card.
|
|
21
|
-
* item: { id, content, senderName, timestamp, isOwn, files?, formattedTime? }
|
|
19
|
+
/**
|
|
20
|
+
* Renders a single thread item. variant: 'message' = chat bubble (isOwn right), 'comment' = comment card.
|
|
21
|
+
* item: { id, content, senderName, timestamp, isOwn, files?, formattedTime? }
|
|
22
22
|
*/
|
|
23
23
|
var ThreadItem = function ThreadItem(_ref) {
|
|
24
24
|
var item = _ref.item,
|
|
@@ -14,9 +14,9 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
14
14
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
15
15
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
16
16
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
17
|
-
/**
|
|
18
|
-
* items: array of { id, content, senderName, timestamp, isOwn, files?, formattedTime? }
|
|
19
|
-
* dateGroups: optional array of { date, items } when groupByDate is true
|
|
17
|
+
/**
|
|
18
|
+
* items: array of { id, content, senderName, timestamp, isOwn, files?, formattedTime? }
|
|
19
|
+
* dateGroups: optional array of { date, items } when groupByDate is true
|
|
20
20
|
*/
|
|
21
21
|
var ThreadList = function ThreadList(_ref) {
|
|
22
22
|
var items = _ref.items,
|
package/dist/thread/index.js
CHANGED
|
@@ -23,10 +23,10 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
23
23
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
24
24
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
25
25
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
26
|
-
/**
|
|
27
|
-
* Shared thread UI for chat messages and comments.
|
|
28
|
-
* items: array of { id, content, senderName, timestamp, isOwn, files?, formattedTime? }
|
|
29
|
-
* dateGroups: when groupByDate true, array of { date, items }
|
|
26
|
+
/**
|
|
27
|
+
* Shared thread UI for chat messages and comments.
|
|
28
|
+
* items: array of { id, content, senderName, timestamp, isOwn, files?, formattedTime? }
|
|
29
|
+
* dateGroups: when groupByDate true, array of { date, items }
|
|
30
30
|
*/
|
|
31
31
|
var PowrBaseThread = function PowrBaseThread(_ref) {
|
|
32
32
|
var _ref$items = _ref.items,
|
|
@@ -9,10 +9,10 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default":
|
|
|
9
9
|
// Match http(s) URLs; simple pattern for display
|
|
10
10
|
var URL_REGEX = /(https?:\/\/[^\s<]+)/g;
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
* Splits text and returns React nodes with URLs as clickable links.
|
|
14
|
-
* @param {string} text - Plain text that may contain URLs
|
|
15
|
-
* @returns {Array} Array of React elements (strings and <a> tags)
|
|
12
|
+
/**
|
|
13
|
+
* Splits text and returns React nodes with URLs as clickable links.
|
|
14
|
+
* @param {string} text - Plain text that may contain URLs
|
|
15
|
+
* @returns {Array} Array of React elements (strings and <a> tags)
|
|
16
16
|
*/
|
|
17
17
|
function linkify(text) {
|
|
18
18
|
if (!text || typeof text !== 'string') return null;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PowrBaseTracker = PowrBaseTracker;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _auth = require("../utils/auth");
|
|
9
|
+
var _config = require("../config");
|
|
10
|
+
var _session = require("../session");
|
|
11
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
12
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
16
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
17
|
+
var SESSION_KEY = "powr-track-session";
|
|
18
|
+
function sessionId() {
|
|
19
|
+
var existing = window.sessionStorage.getItem(SESSION_KEY);
|
|
20
|
+
if (existing && /^[A-Za-z0-9_-]{8,64}$/.test(existing)) return existing;
|
|
21
|
+
var next = "s".concat(Math.random().toString(36).slice(2)).concat(Date.now().toString(36)).replace(/[^A-Za-z0-9_-]/g, "").slice(0, 64);
|
|
22
|
+
window.sessionStorage.setItem(SESSION_KEY, next);
|
|
23
|
+
return next;
|
|
24
|
+
}
|
|
25
|
+
function watchPath(onChange) {
|
|
26
|
+
if (!window.history.__powrTrack) {
|
|
27
|
+
window.history.__powrTrack = true;
|
|
28
|
+
["pushState", "replaceState"].forEach(function (method) {
|
|
29
|
+
var original = window.history[method];
|
|
30
|
+
window.history[method] = function powrTrackHistory() {
|
|
31
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
32
|
+
args[_key] = arguments[_key];
|
|
33
|
+
}
|
|
34
|
+
var result = original.apply(this, args);
|
|
35
|
+
window.dispatchEvent(new Event("powr-path"));
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
window.addEventListener("popstate", function () {
|
|
40
|
+
window.dispatchEvent(new Event("powr-path"));
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
window.addEventListener("powr-path", onChange);
|
|
44
|
+
return function () {
|
|
45
|
+
return window.removeEventListener("powr-path", onChange);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* One signed-in page view per path. Renders nothing.
|
|
51
|
+
* Posts to the Powr host. A storage `NEXT_PUBLIC_POWR_URL` does not redirect this call.
|
|
52
|
+
* The host stores Login As as the admin, from the JWT.
|
|
53
|
+
*/
|
|
54
|
+
function PowrBaseTracker(_ref) {
|
|
55
|
+
var apiUrl = _ref.apiUrl,
|
|
56
|
+
projectId = _ref.projectId;
|
|
57
|
+
var session = (0, _session.usePowrSession)();
|
|
58
|
+
var token = (session === null || session === void 0 ? void 0 : session.token) || "";
|
|
59
|
+
var lastPage = (0, _react.useRef)("");
|
|
60
|
+
(0, _react.useEffect)(function () {
|
|
61
|
+
if (!token || typeof window === "undefined") return undefined;
|
|
62
|
+
var stopped = false;
|
|
63
|
+
lastPage.current = "";
|
|
64
|
+
var send = function send() {
|
|
65
|
+
if (stopped) return;
|
|
66
|
+
var page = window.location.pathname || "/";
|
|
67
|
+
if (!page.startsWith("/") || page === lastPage.current) return;
|
|
68
|
+
var referrer = lastPage.current || window.document.referrer || "";
|
|
69
|
+
lastPage.current = page;
|
|
70
|
+
var host = apiUrl || _config.DEFAULT_POWR_API_URL;
|
|
71
|
+
(0, _auth.apiCall)(host, "/track", projectId, {
|
|
72
|
+
method: "POST",
|
|
73
|
+
headers: {
|
|
74
|
+
Authorization: "Bearer ".concat(token)
|
|
75
|
+
},
|
|
76
|
+
body: _objectSpread({
|
|
77
|
+
page: page,
|
|
78
|
+
session: sessionId()
|
|
79
|
+
}, referrer ? {
|
|
80
|
+
referrer: referrer
|
|
81
|
+
} : {})
|
|
82
|
+
})["catch"](function () {});
|
|
83
|
+
};
|
|
84
|
+
send();
|
|
85
|
+
var unlisten = watchPath(function () {
|
|
86
|
+
send();
|
|
87
|
+
});
|
|
88
|
+
return function () {
|
|
89
|
+
stopped = true;
|
|
90
|
+
unlisten();
|
|
91
|
+
};
|
|
92
|
+
}, [token, apiUrl, projectId]);
|
|
93
|
+
return null;
|
|
94
|
+
}
|
package/dist/utils/phone.js
CHANGED
|
@@ -71,9 +71,9 @@ function normalizePhone(input) {
|
|
|
71
71
|
return parsed ? parsed.format('E.164') : '';
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
/**
|
|
75
|
-
* Normalize phone for storage. Salvages digit runs when input has trailing junk.
|
|
76
|
-
* Returns null when invalid — never returns raw input.
|
|
74
|
+
/**
|
|
75
|
+
* Normalize phone for storage. Salvages digit runs when input has trailing junk.
|
|
76
|
+
* Returns null when invalid — never returns raw input.
|
|
77
77
|
*/
|
|
78
78
|
function coercePhoneForStorage(input) {
|
|
79
79
|
var defaultCountry = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_COUNTRY;
|
|
@@ -11,9 +11,9 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
11
11
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
12
12
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
13
13
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
14
|
-
/**
|
|
15
|
-
* `window.matchMedia` as a hook. SSR-safe: returns `fallback` until mounted,
|
|
16
|
-
* so server and first client render agree (no hydration mismatch).
|
|
14
|
+
/**
|
|
15
|
+
* `window.matchMedia` as a hook. SSR-safe: returns `fallback` until mounted,
|
|
16
|
+
* so server and first client render agree (no hydration mismatch).
|
|
17
17
|
*/
|
|
18
18
|
function useMediaQuery(query) {
|
|
19
19
|
var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
package/package.json
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "powr-sdk-web",
|
|
3
|
-
"version": "6.
|
|
4
|
-
"main": "dist/index.js",
|
|
5
|
-
"files": [
|
|
6
|
-
"dist"
|
|
7
|
-
],
|
|
8
|
-
"scripts": {
|
|
9
|
-
"build": "babel src -d dist --copy-files",
|
|
10
|
-
"prepublishOnly": "npm run build"
|
|
11
|
-
},
|
|
12
|
-
"keywords": [
|
|
13
|
-
"react",
|
|
14
|
-
"component",
|
|
15
|
-
"npm",
|
|
16
|
-
"file-upload",
|
|
17
|
-
"powrbase",
|
|
18
|
-
"comments"
|
|
19
|
-
],
|
|
20
|
-
"author": "Lawazia Tech",
|
|
21
|
-
"license": "MIT",
|
|
22
|
-
"repository": {
|
|
23
|
-
"type": "git",
|
|
24
|
-
"url": "git+https://github.com/lawaziatech/powr-sdk-web.git"
|
|
25
|
-
},
|
|
26
|
-
"peerDependencies": {
|
|
27
|
-
"@monaco-editor/react": "*",
|
|
28
|
-
"filepond": "*",
|
|
29
|
-
"lucide-react": "*",
|
|
30
|
-
"react": "*",
|
|
31
|
-
"react-dom": "*",
|
|
32
|
-
"react-hot-toast": "*",
|
|
33
|
-
"react-toastify": "*"
|
|
34
|
-
},
|
|
35
|
-
"peerDependenciesMeta": {
|
|
36
|
-
"@monaco-editor/react": {
|
|
37
|
-
"optional": true
|
|
38
|
-
},
|
|
39
|
-
"filepond": {
|
|
40
|
-
"optional": true
|
|
41
|
-
},
|
|
42
|
-
"lucide-react": {
|
|
43
|
-
"optional": true
|
|
44
|
-
},
|
|
45
|
-
"react-hot-toast": {
|
|
46
|
-
"optional": true
|
|
47
|
-
},
|
|
48
|
-
"react-toastify": {
|
|
49
|
-
"optional": true
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
"dependencies": {
|
|
53
|
-
"axios": "^1.7.7",
|
|
54
|
-
"filepond": "*",
|
|
55
|
-
"firebase": "^12.2.1",
|
|
56
|
-
"libphonenumber-js": "^1.12.9",
|
|
57
|
-
"prop-types": "^15.8.1",
|
|
58
|
-
"react-filepond": "^7.1.2",
|
|
59
|
-
"react-hook-form": "^7.58.0"
|
|
60
|
-
},
|
|
61
|
-
"devDependencies": {
|
|
62
|
-
"@babel/cli": "^7.24.1",
|
|
63
|
-
"@babel/core": "^7.24.4",
|
|
64
|
-
"@babel/preset-env": "^7.24.4",
|
|
65
|
-
"@babel/preset-react": "^7.24.1"
|
|
66
|
-
}
|
|
67
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "powr-sdk-web",
|
|
3
|
+
"version": "6.4.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "babel src -d dist --copy-files",
|
|
10
|
+
"prepublishOnly": "npm run build"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"react",
|
|
14
|
+
"component",
|
|
15
|
+
"npm",
|
|
16
|
+
"file-upload",
|
|
17
|
+
"powrbase",
|
|
18
|
+
"comments"
|
|
19
|
+
],
|
|
20
|
+
"author": "Lawazia Tech",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/lawaziatech/powr-sdk-web.git"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@monaco-editor/react": "*",
|
|
28
|
+
"filepond": "*",
|
|
29
|
+
"lucide-react": "*",
|
|
30
|
+
"react": "*",
|
|
31
|
+
"react-dom": "*",
|
|
32
|
+
"react-hot-toast": "*",
|
|
33
|
+
"react-toastify": "*"
|
|
34
|
+
},
|
|
35
|
+
"peerDependenciesMeta": {
|
|
36
|
+
"@monaco-editor/react": {
|
|
37
|
+
"optional": true
|
|
38
|
+
},
|
|
39
|
+
"filepond": {
|
|
40
|
+
"optional": true
|
|
41
|
+
},
|
|
42
|
+
"lucide-react": {
|
|
43
|
+
"optional": true
|
|
44
|
+
},
|
|
45
|
+
"react-hot-toast": {
|
|
46
|
+
"optional": true
|
|
47
|
+
},
|
|
48
|
+
"react-toastify": {
|
|
49
|
+
"optional": true
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"axios": "^1.7.7",
|
|
54
|
+
"filepond": "*",
|
|
55
|
+
"firebase": "^12.2.1",
|
|
56
|
+
"libphonenumber-js": "^1.12.9",
|
|
57
|
+
"prop-types": "^15.8.1",
|
|
58
|
+
"react-filepond": "^7.1.2",
|
|
59
|
+
"react-hook-form": "^7.58.0"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@babel/cli": "^7.24.1",
|
|
63
|
+
"@babel/core": "^7.24.4",
|
|
64
|
+
"@babel/preset-env": "^7.24.4",
|
|
65
|
+
"@babel/preset-react": "^7.24.1"
|
|
66
|
+
}
|
|
67
|
+
}
|