powr-sdk-web 6.1.0 → 6.2.1

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.
@@ -7,6 +7,7 @@ exports.POWR_TOKEN_KEYS = exports.POWR_TOKENS = exports.POWR_SCHEMES = exports.P
7
7
  exports.findPreset = findPreset;
8
8
  exports.normalizeDensity = normalizeDensity;
9
9
  exports.normalizeScheme = normalizeScheme;
10
+ exports.powrThemeStorageKey = powrThemeStorageKey;
10
11
  exports.powrVar = powrVar;
11
12
  exports.resolvePowrTokens = resolvePowrTokens;
12
13
  exports.themeForScheme = themeForScheme;
@@ -24,20 +25,20 @@ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol
24
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; } }
25
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; }
26
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); }
27
- /**
28
- * Powr theme token contract.
29
- *
30
- * Ten CSS variables every Powr web app and every SDK component share.
31
- * The SDK ships structure only (light / dark scheme, density). Colours that
32
- * make a product look like itself come from the product via `theme` and
33
- * `presets`.
34
- *
35
- * Components read `var(--powr-<name>, <today's hex>)` inline — no CSS file,
36
- * no Tailwind colour classes, so a bump changes nothing until a product
37
- * mounts `PowrThemeProvider`.
38
- *
39
- * Vocabulary: `scheme` = light / dark / system. `mode` is reserved for the
40
- * 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.
41
42
  */
42
43
 
43
44
  /** token key → CSS variable (without the `--powr-` prefix). */
@@ -90,6 +91,11 @@ var POWR_DENSITIES = exports.POWR_DENSITIES = Object.freeze({
90
91
  comfortable: 1,
91
92
  compact: 0.875
92
93
  });
94
+
95
+ /** localStorage key for the cached selectors. Pure — safe in a server component (head script). */
96
+ function powrThemeStorageKey(projectId) {
97
+ return "powr-theme:".concat(projectId || "default");
98
+ }
93
99
  var DEFAULT_POWR_SCHEME = exports.DEFAULT_POWR_SCHEME = "light";
94
100
  var DEFAULT_POWR_DENSITY = exports.DEFAULT_POWR_DENSITY = "comfortable";
95
101
  var BASE_BY_SCHEME = {
@@ -97,9 +103,9 @@ var BASE_BY_SCHEME = {
97
103
  dark: DARK_POWR_TOKENS
98
104
  };
99
105
 
100
- /**
101
- * `powrVar("primary", "#2563eb")` → `var(--powr-primary, #2563eb)`.
102
- * 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.
103
109
  */
104
110
  function powrVar(key, fallback) {
105
111
  var name = POWR_TOKENS[key] || key;
@@ -124,9 +130,9 @@ function pickKnown(tokens) {
124
130
  return out;
125
131
  }
126
132
 
127
- /**
128
- * Product `theme` may be flat (light only) or `{ light, dark }`.
129
- * 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.
130
136
  */
131
137
  function themeForScheme(theme, scheme) {
132
138
  if (!theme || _typeof(theme) !== "object") return {};
@@ -150,13 +156,13 @@ function normalizeDensity(density) {
150
156
  return Object.prototype.hasOwnProperty.call(POWR_DENSITIES, density) ? density : DEFAULT_POWR_DENSITY;
151
157
  }
152
158
 
153
- /**
154
- * Pure resolver. Order: structural base (light/dark) ← product theme[scheme]
155
- * ← chosen preset (`tokens` / `dark`) ← density.
156
- *
157
- * `scheme` must already be `light` or `dark` (resolve `system` first).
158
- * Also used by the head init script (card 3) so the server and the client
159
- * 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.
160
166
  */
161
167
  function resolvePowrTokens() {
162
168
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
@@ -180,9 +186,9 @@ function resolvePowrTokens() {
180
186
  };
181
187
  }
182
188
 
183
- /**
184
- * `{ bg: "#fff" }` → `{ "--powr-bg": "#fff", "--powr-density": "1" }`.
185
- * 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`.
186
192
  */
187
193
  function tokensToCssVars(tokens, densityScale) {
188
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,
@@ -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;
@@ -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.1.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
- }
1
+ {
2
+ "name": "powr-sdk-web",
3
+ "version": "6.2.1",
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
+ }