@langchain/macaw-components 1.0.0-beta.0 → 1.0.0-beta.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.
@@ -13,12 +13,25 @@ var formatMetricCurrency = (value, { locale = DEFAULT_LOCALE, currency = "USD",
13
13
  maximumFractionDigits: 2,
14
14
  ...options
15
15
  }).format(value);
16
+ var hasDateTimeComponents = (options) => [
17
+ "weekday",
18
+ "era",
19
+ "year",
20
+ "month",
21
+ "day",
22
+ "dayPeriod",
23
+ "hour",
24
+ "minute",
25
+ "second",
26
+ "fractionalSecondDigits",
27
+ "timeZoneName"
28
+ ].some((key) => options[key] !== void 0);
16
29
  var formatMetricDate = (value, { locale = DEFAULT_LOCALE, ...options } = {}) => new Intl.DateTimeFormat(locale, {
17
- dateStyle: "medium",
30
+ dateStyle: hasDateTimeComponents(options) ? void 0 : "medium",
18
31
  ...options
19
32
  }).format(value);
20
33
  var formatMetricTime = (value, { locale = DEFAULT_LOCALE, ...options } = {}) => new Intl.DateTimeFormat(locale, {
21
- timeStyle: "short",
34
+ timeStyle: hasDateTimeComponents(options) ? void 0 : "short",
22
35
  ...options
23
36
  }).format(value);
24
37
  var formatMetricDuration = (value, { locale = DEFAULT_LOCALE, unit, ...options }) => new Intl.NumberFormat(locale, {
@@ -1 +1 @@
1
- {"version":3,"file":"formatters.js","names":[],"sources":["../../../src/components/MetricChart/formatters.ts"],"sourcesContent":["const DEFAULT_LOCALE = 'en-US';\n\ninterface MetricLocaleOptions {\n locale?: string;\n}\n\nexport type MetricNumberFormatOptions = Omit<\n Intl.NumberFormatOptions,\n 'currency' | 'style' | 'unit'\n> &\n MetricLocaleOptions;\n\nexport type MetricCurrencyFormatOptions = Omit<\n Intl.NumberFormatOptions,\n 'currency' | 'style' | 'unit'\n> &\n MetricLocaleOptions & {\n currency?: string;\n };\n\nexport type MetricDateTimeFormatOptions = Intl.DateTimeFormatOptions &\n MetricLocaleOptions;\n\nexport type MetricDurationUnit =\n | 'millisecond'\n | 'second'\n | 'minute'\n | 'hour'\n | 'day';\n\nexport type MetricDurationFormatOptions = Omit<\n Intl.NumberFormatOptions,\n 'currency' | 'style' | 'unit'\n> &\n MetricLocaleOptions & {\n unit: MetricDurationUnit;\n };\n\nexport const formatMetricNumber = (\n value: number,\n { locale = DEFAULT_LOCALE, ...options }: MetricNumberFormatOptions = {}\n) =>\n new Intl.NumberFormat(locale, {\n notation: 'compact',\n maximumFractionDigits: 1,\n ...options,\n }).format(value);\n\nexport const formatMetricCurrency = (\n value: number,\n {\n locale = DEFAULT_LOCALE,\n currency = 'USD',\n ...options\n }: MetricCurrencyFormatOptions = {}\n) =>\n new Intl.NumberFormat(locale, {\n style: 'currency',\n currency,\n notation: 'compact',\n minimumFractionDigits: 0,\n maximumFractionDigits: 2,\n ...options,\n }).format(value);\n\nexport const formatMetricDate = (\n value: Date | number,\n { locale = DEFAULT_LOCALE, ...options }: MetricDateTimeFormatOptions = {}\n) =>\n new Intl.DateTimeFormat(locale, {\n dateStyle: 'medium',\n ...options,\n }).format(value);\n\nexport const formatMetricTime = (\n value: Date | number,\n { locale = DEFAULT_LOCALE, ...options }: MetricDateTimeFormatOptions = {}\n) =>\n new Intl.DateTimeFormat(locale, {\n timeStyle: 'short',\n ...options,\n }).format(value);\n\nexport const formatMetricDuration = (\n value: number,\n { locale = DEFAULT_LOCALE, unit, ...options }: MetricDurationFormatOptions\n) =>\n new Intl.NumberFormat(locale, {\n style: 'unit',\n unit,\n unitDisplay: 'short',\n maximumFractionDigits: 1,\n ...options,\n }).format(value);\n"],"mappings":";AAAA,IAAM,iBAAiB;AAsCvB,IAAa,sBACX,OACA,EAAE,SAAS,gBAAgB,GAAG,YAAuC,CAAC,MAEtE,IAAI,KAAK,aAAa,QAAQ;CAC5B,UAAU;CACV,uBAAuB;CACvB,GAAG;AACL,CAAC,CAAC,CAAC,OAAO,KAAK;AAEjB,IAAa,wBACX,OACA,EACE,SAAS,gBACT,WAAW,OACX,GAAG,YAC4B,CAAC,MAElC,IAAI,KAAK,aAAa,QAAQ;CAC5B,OAAO;CACP;CACA,UAAU;CACV,uBAAuB;CACvB,uBAAuB;CACvB,GAAG;AACL,CAAC,CAAC,CAAC,OAAO,KAAK;AAEjB,IAAa,oBACX,OACA,EAAE,SAAS,gBAAgB,GAAG,YAAyC,CAAC,MAExE,IAAI,KAAK,eAAe,QAAQ;CAC9B,WAAW;CACX,GAAG;AACL,CAAC,CAAC,CAAC,OAAO,KAAK;AAEjB,IAAa,oBACX,OACA,EAAE,SAAS,gBAAgB,GAAG,YAAyC,CAAC,MAExE,IAAI,KAAK,eAAe,QAAQ;CAC9B,WAAW;CACX,GAAG;AACL,CAAC,CAAC,CAAC,OAAO,KAAK;AAEjB,IAAa,wBACX,OACA,EAAE,SAAS,gBAAgB,MAAM,GAAG,cAEpC,IAAI,KAAK,aAAa,QAAQ;CAC5B,OAAO;CACP;CACA,aAAa;CACb,uBAAuB;CACvB,GAAG;AACL,CAAC,CAAC,CAAC,OAAO,KAAK"}
1
+ {"version":3,"file":"formatters.js","names":[],"sources":["../../../src/components/MetricChart/formatters.ts"],"sourcesContent":["const DEFAULT_LOCALE = 'en-US';\n\ninterface MetricLocaleOptions {\n locale?: string;\n}\n\nexport type MetricNumberFormatOptions = Omit<\n Intl.NumberFormatOptions,\n 'currency' | 'style' | 'unit'\n> &\n MetricLocaleOptions;\n\nexport type MetricCurrencyFormatOptions = Omit<\n Intl.NumberFormatOptions,\n 'currency' | 'style' | 'unit'\n> &\n MetricLocaleOptions & {\n currency?: string;\n };\n\nexport type MetricDateTimeFormatOptions = Intl.DateTimeFormatOptions &\n MetricLocaleOptions;\n\nexport type MetricDurationUnit =\n | 'millisecond'\n | 'second'\n | 'minute'\n | 'hour'\n | 'day';\n\nexport type MetricDurationFormatOptions = Omit<\n Intl.NumberFormatOptions,\n 'currency' | 'style' | 'unit'\n> &\n MetricLocaleOptions & {\n unit: MetricDurationUnit;\n };\n\nexport const formatMetricNumber = (\n value: number,\n { locale = DEFAULT_LOCALE, ...options }: MetricNumberFormatOptions = {}\n) =>\n new Intl.NumberFormat(locale, {\n notation: 'compact',\n maximumFractionDigits: 1,\n ...options,\n }).format(value);\n\nexport const formatMetricCurrency = (\n value: number,\n {\n locale = DEFAULT_LOCALE,\n currency = 'USD',\n ...options\n }: MetricCurrencyFormatOptions = {}\n) =>\n new Intl.NumberFormat(locale, {\n style: 'currency',\n currency,\n notation: 'compact',\n minimumFractionDigits: 0,\n maximumFractionDigits: 2,\n ...options,\n }).format(value);\n\nconst hasDateTimeComponents = (options: Intl.DateTimeFormatOptions) =>\n (\n [\n 'weekday',\n 'era',\n 'year',\n 'month',\n 'day',\n 'dayPeriod',\n 'hour',\n 'minute',\n 'second',\n 'fractionalSecondDigits',\n 'timeZoneName',\n ] as const\n ).some((key) => options[key] !== undefined);\n\nexport const formatMetricDate = (\n value: Date | number,\n { locale = DEFAULT_LOCALE, ...options }: MetricDateTimeFormatOptions = {}\n) =>\n new Intl.DateTimeFormat(locale, {\n dateStyle: hasDateTimeComponents(options) ? undefined : 'medium',\n ...options,\n }).format(value);\n\nexport const formatMetricTime = (\n value: Date | number,\n { locale = DEFAULT_LOCALE, ...options }: MetricDateTimeFormatOptions = {}\n) =>\n new Intl.DateTimeFormat(locale, {\n timeStyle: hasDateTimeComponents(options) ? undefined : 'short',\n ...options,\n }).format(value);\n\nexport const formatMetricDuration = (\n value: number,\n { locale = DEFAULT_LOCALE, unit, ...options }: MetricDurationFormatOptions\n) =>\n new Intl.NumberFormat(locale, {\n style: 'unit',\n unit,\n unitDisplay: 'short',\n maximumFractionDigits: 1,\n ...options,\n }).format(value);\n"],"mappings":";AAAA,IAAM,iBAAiB;AAsCvB,IAAa,sBACX,OACA,EAAE,SAAS,gBAAgB,GAAG,YAAuC,CAAC,MAEtE,IAAI,KAAK,aAAa,QAAQ;CAC5B,UAAU;CACV,uBAAuB;CACvB,GAAG;AACL,CAAC,CAAC,CAAC,OAAO,KAAK;AAEjB,IAAa,wBACX,OACA,EACE,SAAS,gBACT,WAAW,OACX,GAAG,YAC4B,CAAC,MAElC,IAAI,KAAK,aAAa,QAAQ;CAC5B,OAAO;CACP;CACA,UAAU;CACV,uBAAuB;CACvB,uBAAuB;CACvB,GAAG;AACL,CAAC,CAAC,CAAC,OAAO,KAAK;AAEjB,IAAM,yBAAyB,YAE3B;CACE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CACD,MAAM,QAAQ,QAAQ,SAAS,KAAA,CAAS;AAE5C,IAAa,oBACX,OACA,EAAE,SAAS,gBAAgB,GAAG,YAAyC,CAAC,MAExE,IAAI,KAAK,eAAe,QAAQ;CAC9B,WAAW,sBAAsB,OAAO,IAAI,KAAA,IAAY;CACxD,GAAG;AACL,CAAC,CAAC,CAAC,OAAO,KAAK;AAEjB,IAAa,oBACX,OACA,EAAE,SAAS,gBAAgB,GAAG,YAAyC,CAAC,MAExE,IAAI,KAAK,eAAe,QAAQ;CAC9B,WAAW,sBAAsB,OAAO,IAAI,KAAA,IAAY;CACxD,GAAG;AACL,CAAC,CAAC,CAAC,OAAO,KAAK;AAEjB,IAAa,wBACX,OACA,EAAE,SAAS,gBAAgB,MAAM,GAAG,cAEpC,IAAI,KAAK,aAAa,QAAQ;CAC5B,OAAO;CACP;CACA,aAAa;CACb,uBAAuB;CACvB,GAAG;AACL,CAAC,CAAC,CAAC,OAAO,KAAK"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/macaw-components",
3
- "version": "1.0.0-beta.0",
3
+ "version": "1.0.0-beta.1",
4
4
  "description": "React components and usage guidance for the Macaw Design System.",
5
5
  "homepage": "https://github.com/langchain-ai/macaw-design-system#readme",
6
6
  "bugs": {
@@ -586,7 +586,7 @@
586
586
  "tailwindcss-animate": "^1.0.7",
587
587
  "use-debounce": "^9.0.4",
588
588
  "yaml": "^2.8.3",
589
- "@langchain/macaw-tokens": "1.0.0-beta.0"
589
+ "@langchain/macaw-tokens": "1.0.0-beta.1"
590
590
  },
591
591
  "peerDependencies": {
592
592
  "react": ">=18.2.0 <20",