dry-ux 1.75.0 → 1.77.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.
@@ -60,6 +60,11 @@ export declare const toHashCode: (input: string) => number;
60
60
  * @param value The value of the parameter.
61
61
  */
62
62
  export declare const insertUrlParam: (key: any, value: any) => void;
63
+ /**
64
+ * Deletes a URL parameter.
65
+ * @param key
66
+ */
67
+ export declare const deleteUrlParam: (key: any) => void;
63
68
  /**
64
69
  * Inserts multiple URL parameters.
65
70
  * @param params An object containing key-value pairs of parameters.
@@ -129,4 +134,5 @@ export declare const useDimensions: (ref?: React.MutableRefObject<HTMLElement>)
129
134
  export declare const useSearchParams: <T>() => {
130
135
  params: T;
131
136
  setParam: <TKey extends keyof T, TValue extends T[TKey]>(key: TKey, value: TValue) => void;
137
+ clearParams: <TKey extends keyof T>(...keys: TKey[]) => void;
132
138
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useSearchParams = exports.useDimensions = exports.usePubSub = exports.useIsVisible = exports.tryParseJson = exports.Deferred = exports.getUrlParams = exports.insertUrlParams = exports.insertUrlParam = exports.toHashCode = exports.StorageUtils = exports.fnWithAuthCheck = exports.formatDollar = exports.useCountdown = exports.importStyleSheet = exports.importScript = exports.preventDefault = void 0;
3
+ exports.useSearchParams = exports.useDimensions = exports.usePubSub = exports.useIsVisible = exports.tryParseJson = exports.Deferred = exports.getUrlParams = exports.insertUrlParams = exports.deleteUrlParam = exports.insertUrlParam = exports.toHashCode = exports.StorageUtils = exports.fnWithAuthCheck = exports.formatDollar = exports.useCountdown = exports.importStyleSheet = exports.importScript = exports.preventDefault = void 0;
4
4
  const React = require("react");
5
5
  /**
6
6
  * Returns a function that will call the given handler and prevent the default event behavior.
@@ -167,6 +167,24 @@ const insertUrlParam = (key, value) => {
167
167
  }
168
168
  };
169
169
  exports.insertUrlParam = insertUrlParam;
170
+ /**
171
+ * Deletes a URL parameter.
172
+ * @param key
173
+ */
174
+ const deleteUrlParam = (key) => {
175
+ if (history.pushState) {
176
+ let searchParams = new URLSearchParams(window.location.search);
177
+ searchParams.delete(key);
178
+ let newUrl = window.location.protocol +
179
+ "//" +
180
+ window.location.host +
181
+ window.location.pathname +
182
+ "?" +
183
+ searchParams.toString();
184
+ window.history.pushState({ path: newUrl }, "", newUrl);
185
+ }
186
+ };
187
+ exports.deleteUrlParam = deleteUrlParam;
170
188
  /**
171
189
  * Inserts multiple URL parameters.
172
190
  * @param params An object containing key-value pairs of parameters.
@@ -314,9 +332,17 @@ const useSearchParams = () => {
314
332
  (0, exports.insertUrlParam)(key, value);
315
333
  setParams((0, exports.getUrlParams)());
316
334
  }, []);
335
+ /**
336
+ * Clears one or more URL parameters and updates the state.
337
+ */
338
+ const clearParams = React.useCallback((...keys) => {
339
+ keys.forEach(key => (0, exports.deleteUrlParam)(key));
340
+ setParams((0, exports.getUrlParams)());
341
+ }, []);
317
342
  return {
318
343
  params,
319
344
  setParam,
345
+ clearParams,
320
346
  };
321
347
  };
322
348
  exports.useSearchParams = useSearchParams;
@@ -1,9 +1,37 @@
1
1
  import * as React from "react";
2
- /**
3
- * Renders a formatted dollar amount with a dollar sign and parentheses if the amount is negative.
4
- */
5
- export declare const Money: React.FC<{
2
+ type MoneyProps = {
3
+ /**
4
+ * Numeric amount to display. Negative values are wrapped in parentheses and styled using negativeColor/negativeStyles.
5
+ */
6
6
  amount: number;
7
+ /**
8
+ * Whether to include decimal places in the formatted output. When true, the helper will format with standard cents precision.
9
+ * Defaults to false.
10
+ */
7
11
  decimal_places?: boolean;
12
+ /**
13
+ * Currency symbol prefix to display before the formatted amount. Defaults to "$".
14
+ */
8
15
  currency?: string;
9
- }>;
16
+ /**
17
+ * Fallback text color applied when the amount is negative (unless overridden via negativeStyles). Defaults to Bootstrap danger-like red.
18
+ */
19
+ negativeColor?: string;
20
+ /**
21
+ * Base styles applied to the <span>. These are merged last and can override sign-specific styles.
22
+ */
23
+ styles?: React.CSSProperties;
24
+ /**
25
+ * Additional styles merged when amount is negative (after negativeColor). Overridden by properties in styles if conflicts occur.
26
+ */
27
+ negativeStyles?: React.CSSProperties;
28
+ /**
29
+ * Additional styles merged when amount is zero or positive. Overridden by properties in styles if conflicts occur.
30
+ */
31
+ positiveStyles?: React.CSSProperties;
32
+ };
33
+ /**
34
+ * Renders a formatted dollar amount with a currency symbol and parentheses if the amount is negative.
35
+ */
36
+ export declare const Money: React.FC<MoneyProps>;
37
+ export {};
@@ -4,10 +4,10 @@ exports.Money = void 0;
4
4
  const React = require("react");
5
5
  const utilities_1 = require("../helpers/utilities");
6
6
  /**
7
- * Renders a formatted dollar amount with a dollar sign and parentheses if the amount is negative.
7
+ * Renders a formatted dollar amount with a currency symbol and parentheses if the amount is negative.
8
8
  */
9
- exports.Money = React.memo(({ amount, decimal_places = false, currency = "$" }) => {
9
+ exports.Money = React.memo(({ amount, decimal_places = false, currency = "$", negativeColor = "#d9534f", styles = {}, negativeStyles = {}, positiveStyles = {}, }) => {
10
10
  const isNegative = amount < 0;
11
11
  const converted = `${currency}${(0, utilities_1.formatDollar)(Math.abs(amount), decimal_places)}`;
12
- return (React.createElement("span", { style: Object.assign({}, (isNegative && { color: "#d9534f" })) }, isNegative ? `(${converted})` : converted));
12
+ return (React.createElement("span", { style: Object.assign(Object.assign({}, (isNegative ? Object.assign({ color: negativeColor }, negativeStyles) : positiveStyles)), styles) }, isNegative ? `(${converted})` : converted));
13
13
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dry-ux",
3
- "version": "1.75.0",
3
+ "version": "1.77.0",
4
4
  "description": "",
5
5
  "main": "dist/index",
6
6
  "scripts": {