@carbon/utilities 0.6.0-rc.0 → 0.7.0-rc.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/es/documentLang/documentLang.js +1 -0
- package/es/documentLang/index.js +1 -0
- package/es/index.js +1 -1
- package/lib/documentLang/documentLang.js +1 -0
- package/lib/documentLang/index.js +1 -0
- package/lib/index.js +1 -1
- package/package.json +4 -3
- package/types/documentLang/documentLang.d.ts +25 -0
- package/types/documentLang/index.d.ts +7 -0
- package/types/index.d.ts +3 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t=typeof document<"u";let o=t?document.documentElement.lang:"",i=!1,n=[],r=!1;function s(){t&&(i||(i=!0,queueMicrotask(()=>{i=!1;const e=document.documentElement.lang;if(e!==o){o=e;for(const u of n)u(e)}})))}function c(){if(!t||r)return;r=!0,new MutationObserver(s).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"]})}function a(){return t&&(document.documentElement.lang||window.navigator.language)||""}function l(e){return t?(r||c(),n.push(e),()=>{n=n.filter(u=>u!==e),n.length===0&&(r=!1)}):()=>{}}export{a as getDocumentLang,l as subscribeDocumentLangChange};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./documentLang";
|
package/es/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./dateTimeFormat";export*from"./overflowHandler";
|
|
1
|
+
export*from"./dateTimeFormat";export*from"./overflowHandler";export*from"@internationalized/number";export*from"./documentLang";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var s=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var g=(e,t)=>{for(var i in t)s(e,i,{get:t[i],enumerable:!0})},m=(e,t,i,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of d(t))!b.call(e,n)&&n!==i&&s(e,n,{get:()=>t[n],enumerable:!(a=f(t,n))||a.enumerable});return e};var v=e=>m(s({},"__esModule",{value:!0}),e);var L={};g(L,{getDocumentLang:()=>w,subscribeDocumentLangChange:()=>E});module.exports=v(L);const r=typeof document<"u";let l=r?document.documentElement.lang:"",c=!1,u=[],o=!1;function p(){r&&(c||(c=!0,queueMicrotask(()=>{c=!1;const e=document.documentElement.lang;if(e!==l){l=e;for(const t of u)t(e)}})))}function h(){if(!r||o)return;o=!0,new MutationObserver(p).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"]})}function w(){return r&&(document.documentElement.lang||window.navigator.language)||""}function E(e){return r?(o||h(),u.push(e),()=>{u=u.filter(t=>t!==e),u.length===0&&(o=!1)}):()=>{}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var p=(r,o,f,x)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of c(o))!d.call(r,e)&&e!==f&&a(r,e,{get:()=>o[e],enumerable:!(x=b(o,e))||x.enumerable});return r},t=(r,o,f)=>(p(r,o,"default"),f&&p(f,o,"default"));var g=r=>p(a({},"__esModule",{value:!0}),r);var m={};module.exports=g(m);t(m,require("./documentLang"),module.exports);
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var n=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var f=(t,e,p,x)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of a(e))!b.call(t,m)&&m!==p&&n(t,m,{get:()=>e[m],enumerable:!(x=i(e,m))||x.enumerable});return t},o=(t,e,p)=>(f(t,e,"default"),p&&f(p,e,"default"));var d=t=>f(n({},"__esModule",{value:!0}),t);var r={};module.exports=d(r);o(r,require("./dateTimeFormat"),module.exports);o(r,require("./overflowHandler"),module.exports);o(r,require("@internationalized/number"),module.exports);o(r,require("./documentLang"),module.exports);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/utilities",
|
|
3
3
|
"description": "Utilities and helpers to drive consistency across software products using the Carbon Design System",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.0-rc.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "es/index.js",
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
"typescript-config-carbon": "^0.5.0"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@ibm/telemetry-js": "^1.6.1"
|
|
47
|
+
"@ibm/telemetry-js": "^1.6.1",
|
|
48
|
+
"@internationalized/number": "^3.6.1"
|
|
48
49
|
},
|
|
49
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "fcae2645f1b5a1a01b5629926df471ec1945d1e6"
|
|
50
51
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2025
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
type Subscriber = (lang: string) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves the current document language. Falls back to the browser's
|
|
10
|
+
* `navigator.language` if the `<html>` lang attribute is empty.
|
|
11
|
+
*
|
|
12
|
+
* @returns {string} The current document language code.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getDocumentLang(): string;
|
|
15
|
+
/**
|
|
16
|
+
* Subscribes to changes on the `<html>` element's `lang` attribute.
|
|
17
|
+
* Uses a shared MutationObserver under the hood to watch for attribute
|
|
18
|
+
* mutations.
|
|
19
|
+
*
|
|
20
|
+
* @param {Subscriber} callback - Invoked with the new language code whenever
|
|
21
|
+
* it changes.
|
|
22
|
+
* @returns {() => void} A function that, when called, removes this subscription
|
|
23
|
+
*/
|
|
24
|
+
export declare function subscribeDocumentLangChange(callback: Subscriber): () => void;
|
|
25
|
+
export {};
|