### Full End-to-End Example Source: https://context7.com/ibsheet/loader/llms.txt A comprehensive example demonstrating loader configuration, event listener attachment, sheet creation, and cleanup. ```APIDOC ## Full End-to-End Example Complete example showing configuration, loading, sheet creation, event handling, and cleanup. ```js import loader from '@ibsheet/loader' // 1. Configure the loader loader.config({ debug: false, autoload: true, retry: { maxCount: 30, intervalTime: 300 }, registry: [ { name: 'ibsheet', baseUrl: 'https://cdn.example.com/ibsheet/8', theme: 'default', locales: ['ko'], corefile: 'ibsheet.js', plugins: ['excel', 'common'], license: 'YOUR-LICENSE-KEY', }, { name: 'ibchart', baseUrl: 'https://cdn.example.com/ibchart/1', }, ], ready() { console.log('[loader] DOM ready') }, }) // 2. Attach lifecycle event listeners loader .on('load', (e) => console.log('[load]', e.target.alias)) .on('loaded', (e) => console.log('[loaded]', e.target.alias)) .on('load-failed', (e) => console.error('[load-failed]', e.error)) .on('load-complete', () => console.log('[load-complete]')) // 3. Create a sheet (autoload triggers load if needed) loader .createSheet({ el: 'gridContainer', options: { Cfg: { SearchMode: 2, MergeSheet: 4, StyleSel: 1 }, Def: { Row: { Height: 28 } }, Cols: [ { Header: 'ID', Type: 'Int', Width: 60 }, { Header: 'Name', Type: 'Text', Width: 160 }, { Header: 'Value',Type: 'Float', Width: 100 }, ], }, data: { Row: [ { ID: 1, Name: 'Alpha', Value: 3.14 }, { ID: 2, Name: 'Beta', Value: 2.71 }, ], }, sync: true, }) .then((sheet) => { console.log('Sheet ready — id:', sheet.id, '| length:', sheet.length) // 4. Access IBSheet static API const IBS = loader.getIBSheetStatic() console.log('IBSheet global:', IBS) // 5. Cleanup after 10 seconds setTimeout(() => { loader.removeSheet(sheet.id) loader.unload('ibsheet') }, 10_000) }) .catch((err) => { console.error('createSheet error:', err) }) ``` ``` -------------------------------- ### Full End-to-End IBSheet Loader Example Source: https://context7.com/ibsheet/loader/llms.txt This example demonstrates configuring the loader, attaching lifecycle event listeners, creating a sheet with options and data, accessing the IBSheet static API, and performing cleanup. ```javascript import loader from '@ibsheet/loader' // 1. Configure the loader loader.config({ debug: false, autoload: true, retry: { maxCount: 30, intervalTime: 300 }, registry: [ { name: 'ibsheet', baseUrl: 'https://cdn.example.com/ibsheet/8', theme: 'default', locales: ['ko'], corefile: 'ibsheet.js', plugins: ['excel', 'common'], license: 'YOUR-LICENSE-KEY', }, { name: 'ibchart', baseUrl: 'https://cdn.example.com/ibchart/1', }, ], ready() { console.log('[loader] DOM ready') }, }) // 2. Attach lifecycle event listeners loader .on('load', (e) => console.log('[load]', e.target.alias)) .on('loaded', (e) => console.log('[loaded]', e.target.alias)) .on('load-failed', (e) => console.error('[load-failed]', e.error)) .on('load-complete', () => console.log('[load-complete]')) // 3. Create a sheet (autoload triggers load if needed) loader .createSheet({ el: 'gridContainer', options: { Cfg: { SearchMode: 2, MergeSheet: 4, StyleSel: 1 }, Def: { Row: { Height: 28 } }, Cols: [ { Header: 'ID', Type: 'Int', Width: 60 }, { Header: 'Name', Type: 'Text', Width: 160 }, { Header: 'Value',Type: 'Float', Width: 100 }, ], }, data: { Row: [ { ID: 1, Name: 'Alpha', Value: 3.14 }, { ID: 2, Name: 'Beta', Value: 2.71 }, ], }, sync: true, }) .then((sheet) => { console.log('Sheet ready — id:', sheet.id, '| length:', sheet.length) // 4. Access IBSheet static API const IBS = loader.getIBSheetStatic() console.log('IBSheet global:', IBS) // 5. Cleanup after 10 seconds setTimeout(() => { loader.removeSheet(sheet.id) loader.unload('ibsheet') }, 10_000) }) .catch((err) => { console.error('createSheet error:', err) }) ``` -------------------------------- ### Install IBSheet Loader via npm Source: https://github.com/ibsheet/loader/blob/master/README.md Use npm to install the IBSheet loader package. This is the standard method for Node.js projects. ```sh npm install @ibsheet/loader ``` -------------------------------- ### Run webpack-dev-server Source: https://github.com/ibsheet/loader/blob/master/README.md Starts the webpack development server for local development. Access the application at `localhost:3033`. ```sh yarn serve ``` -------------------------------- ### Install IBSheet Loader Source: https://context7.com/ibsheet/loader/llms.txt Install the IBSheet Loader package using npm or yarn. For browser usage, include the UMD bundle via a script tag. ```bash # npm npm install @ibsheet/loader # yarn yarn add @ibsheet/loader # Browser (UMD) # ``` -------------------------------- ### Install IBSheet Loader via yarn Source: https://github.com/ibsheet/loader/blob/master/README.md Use yarn to add the IBSheet loader package to your project. This is an alternative package manager. ```sh yarn add @ibsheet/loader ``` -------------------------------- ### Load IBSheet Module in Browser (ES3, ES5) Source: https://github.com/ibsheet/loader/blob/master/README.md Example of loading an IBSheet module using the loader in older browser environments (ES3, ES5). Access the loader via the global `window.IBSheetLoader` object. ```js var loader = window.IBSheetLoader loader.load({ name: 'ibsheet', baseUrl: '/ibsheet' }).createSheet(options) ``` -------------------------------- ### Load IBSheet Module in Node.js (CommonJS) Source: https://github.com/ibsheet/loader/blob/master/README.md Example of loading an IBSheet module using the loader in a Node.js environment using CommonJS modules. Import the loader using `require`. ```js var loader = require('@ibsheet/loader') loader.load({ name: 'ibsheet', baseUrl: '/ibsheet' }).createSheet(options) ``` -------------------------------- ### Load IBSheet Module in ESModule (ES6, TypeScript) Source: https://github.com/ibsheet/loader/blob/master/README.md Example of loading an IBSheet module using the loader in modern JavaScript environments (ES6, TypeScript). Import the loader using ES module syntax. ```js import loader from '@ibsheet/loader' // or import { IBSheetLoader as loader } from '@ibsheet/loader' loader.load({ name: 'ibsheet', baseUrl: '/ibsheet' }).createSheet(options) ``` -------------------------------- ### Get IBSheet Static Object with loader.getIBSheetStatic Source: https://context7.com/ibsheet/loader/llms.txt Returns the IBSheet global static object (`window.IBSheet` by default) once it has been loaded, or `undefined` if not yet available. Use after `loader.sheetReady()` has resolved. ```javascript import loader from '@ibsheet/loader' loader.sheetReady().then(() => { const IBSheet = loader.getIBSheetStatic() // Access IBSheet static methods console.log(IBSheet) // IBSheet global object }) ``` -------------------------------- ### Create IBChart Instance Source: https://context7.com/ibsheet/loader/llms.txt Loads IBChart (if not already loaded) and creates a new chart instance. Requires `id` and either `el` or `cont` (container element id). The chart configuration is passed via `options` / `config`. Returns `Promise`. Handles creation success or failure via Promises. ```javascript import loader from '@ibsheet/loader' loader.config({ registry: [ { name: 'ibchart', baseUrl: '/assets/ibchart', }, ], }) loader .createChart({ id: 'myChart', el: 'chartContainer', // or cont: 'chartContainer' options: { chart: { type: 'bar' }, title: { text: 'Monthly Sales' }, series: [{ data: [100, 200, 150, 300] }], }, }) .then((chart) => { console.log('Chart created, id:', chart.getId()) }) .catch((err) => { console.error('Chart creation failed:', err) }) ``` -------------------------------- ### Generate Documentation Source: https://github.com/ibsheet/loader/blob/master/README.md Generates project documentation using TypeDoc. ```sh yarn doc ``` -------------------------------- ### loader.createChart Source: https://context7.com/ibsheet/loader/llms.txt Loads IBChart (if not already loaded) and creates a new chart instance. Requires `id` and either `el` or `cont` (container element id). The chart configuration is passed via `options` / `config`. Returns `Promise`. ```APIDOC ## `loader.createChart(options)` Loads IBChart (if not already loaded) and creates a new chart instance. Requires `id` and either `el` or `cont` (container element id). The chart configuration is passed via `options` / `config`. Returns `Promise`. ### Usage Example: ```js import loader from '@ibsheet/loader' loader.config({ registry: [ { name: 'ibchart', baseUrl: '/assets/ibchart', }, ], }) loader .createChart({ id: 'myChart', el: 'chartContainer', // or cont: 'chartContainer' options: { chart: { type: 'bar' }, title: { text: 'Monthly Sales' }, series: [{ data: [100, 200, 150, 300] }], }, }) .then((chart) => { console.log('Chart created, id:', chart.getId()) }) .catch((err) => { console.error('Chart creation failed:', err) }) ``` ``` -------------------------------- ### Create IBMap Instance Source: https://context7.com/ibsheet/loader/llms.txt Loads IBMap (if not already loaded) and creates a new map instance. Requires `el` / `elem` (container element id) and `options` / `cfg` (map configuration object). Returns `Promise`. Handles creation success or failure via Promises. ```javascript import loader from '@ibsheet/loader' loader.config({ registry: [ { name: 'ibmap', baseUrl: '/assets/ibmap', }, ], }) loader .createMap({ el: 'mapContainer', // or elem: 'mapContainer' options: { // or cfg: { ... } center: [37.5665, 126.9780], zoom: 10, }, }) .then((map) => { console.log('Map created') }) .catch((err) => { console.error('Map creation failed:', err) }) ``` -------------------------------- ### Initialize IBSheetLoader Source: https://github.com/ibsheet/loader/blob/master/public/index.html Initializes the IBSheetLoader and sets up event listeners for 'loaded' events. This is typically done once at the beginning of the application. ```javascript const loader = window.IBSheetLoader; ``` -------------------------------- ### Create IBMap Instance Source: https://github.com/ibsheet/loader/blob/master/public/index.html Creates an IBMap instance. Requires IBMap to be loaded. Configuration options for the map, legend, and lines are provided. ```javascript // I BChart 생성 function doCreateMap() { if (!window.IBMapCharts) { log('mapLog', '✗ IBMap not loaded yet'); return; } log('mapLog', 'Creating map...'); var cfg = { "map": { "scale": 1.1, "shadow": false, "select": {"style": {"backgroundColor": "#437FEA"}}, "tooltip": {"style": {"border": {"color": "#aaa"}}}, "hover": {"style": {"backgroundColor": "#75A5FA"}}, "dataLabel": {"enable": false}, "style": {"backgroundColor": "#FFF", "border": {"width": 0.4, "color": "#437FEA"}} }, "legend": { "enable": true, "type": "symbol", "align": "left", "verticalAlign": "bottom", "orient": "vertical", "title": "A항공 운행 노선", "range": ["diamond", "square", "cross"], "color": ["red", "#6482AD", "rgb(180, 180, 80)"], "domain": ["김포국제공항", "김해국제공항", "제주국제공항"] }, "line": {"onclick": function(ev){ this.line.remove(ev.data.id); }}, "style": {"backgroundColor": "#EDEDED"} } // mapInstance = loader.createMap( loader.createMap({ el: document.getElementById('mapContainer'), // el: 'mapContainer', options: cfg }).then(map => { console.log('Map created (from promise) :', map); mapInstance = map; console.log('mapInstance :', mapInstance); if (mapInstance) { // mapInstance fetch("https://demo.ibsheet.com/ibsheet/v8/samples/customer-sample/assets/ibmap/map/new-kr/korea.json").then(res=>res.json()).then(data=>{ mapInstance.map._loadMap(data, function(data){ var points = [{ "id": "p-001", "symbol": { "label" : " ``` -------------------------------- ### Publish Documentation Source: https://github.com/ibsheet/loader/blob/master/README.md Publishes the generated project documentation. ```sh yarn doc:publish ``` -------------------------------- ### Create IBChart Instance Source: https://github.com/ibsheet/loader/blob/master/public/index.html Creates an IBChart instance. Ensure IBChart is loaded before calling this function. The function returns a promise that resolves with the chart instance. ```javascript function Chart() { if (!window.IBChart) { log('chartLog', '✗ IBChart not loaded yet'); return; } log('chartLog', 'Creating chart...'); // chartInstance = loader.createChart( loader.createChart({ id: 'myChart', // cont: document.getElementById('chartContainer'), // cont: 'chartContainer', el: 'chartContainer', options: { width: '100%', height: '400px', } }/*{ id: 'myChart', cont: 'chartContainer', options: { chart: { type: 'column' }, title: { text: 'Sample Chart' }, xAxis: { categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May'] }, yAxis: { title: { text: 'Values' } }, series: [{ name: 'Sales', data: [29.9, 71.5, 106.4, 129.2, 144.0] }] } }*/ ).then(chart => { console.log('Chart created (from promise) :', chart); chartInstance = chart; console.log('chartInstance :', chartInstance); // console.log('myChart :', myChart); if (chartInstance) { var chartInit = { "colors": ["#448EF6", "#75C2F6", "#65DAF7", "#A7EFE9"], "chart": {"type": "bar"}, "subtitle": {"text": "통계청 항목별 월평균 가구지출(2022)", "align": "left", "style": {"color": "#242424"}}, "xAxis": {"categories": ["주거비", "주거관리비", "교통비", "통신비"], "gridLineWidth": 1, "lineWidth": 0}, "yAxis": {"title": {"text": "단위(만원)", "align": "high", "style": {"color": "#575757", "fontSize": "10px"}}, "tickInterval": 3, "gridLineWidth": 0}, "plotOptions": {"series": {"dataLabels": {"enabled": true, "allowOverlap": true}, "shadow": false, "pointWidth": 15, "pointPadding": 0.3, "groupPadding": 0.1}}, "legend": {"layout": "vertical", "align": "right", "verticalAlign": "top", "x": -60, "y": 30, "floating": true, "borderWidth": 0, "backgroundColor": "#FFFFFF", "shadow": true}, "tooltip": {"valueSuffix": "만원"} }; chartInstance.setOptions(chartInit); // myChart.setOptions(chartInit); var data = { "series": [ { "name": "서울", "data": [13, 15, 22, 15] }, { "name": "부산", "data": [8, 15, 29, 16] }, { "name": "대구", "data": [7, 20, 29, 17] }, { "name": "인천", "data": [7, 15, 31, 20] } ] }; chartInstance.loadSearchData(data, {append: true}); // myChart.loadSearchData(data, {append: true}); log('chartLog', '✓ Chart created successfully'); } }).catch(err => { log('chartLog', '✗ Error creating chart: ' + err.message); }); } ``` -------------------------------- ### Event Listeners Source: https://context7.com/ibsheet/loader/llms.txt Demonstrates how to attach event listeners for various loader events using `loader.on()`, `loader.once()`, and `loader.bind()`. ```APIDOC ## Event System — `loader.on()`, `loader.once()`, `loader.bind()` `IBSheetLoaderStatic` extends `CustomEventEmitter` (a Node.js `EventEmitter` subclass). All events receive a `LoaderEvent` object with `{ type, target, data?, error? }`. Multiple event names can be bound in a single `bind()` call using space-separated strings. ```js import loader from '@ibsheet/loader' // Individual event listeners loader.on('load', (evt) => console.log('Loading:', evt.target.alias)) loader.on('loaded', (evt) => console.log('Loaded:', evt.target.alias)) loader.on('load-failed', (evt) => console.error('Failed:', evt.target.alias, evt.error)) loader.on('load-complete', (evt) => console.log('All loads done')) loader.on('unload', (evt) => console.log('Unloading:', evt.target.alias)) loader.on('unloaded', (evt) => console.log('Unloaded:', evt.target.alias)) loader.on('unload-complete',(evt) => console.log('All unloads done')) loader.on('create-sheet', (evt) => console.log('Creating sheet:', evt.data)) loader.on('created-sheet', (evt) => console.log('Sheet ready:', evt.target.id)) loader.on('create-sheet-failed', (evt) => console.error('Sheet error:', evt.error)) loader.on('removed-sheet', (evt) => console.log('Sheet removed:', evt.data.id)) // One-time listener loader.once('loaded', (evt) => console.log('First load done')) // Bind multiple events at once with space-separated string loader.bind('create-chart created-chart', (evt) => { console.log('Chart event:', evt.type) }) // Remove a listener const handler = (evt) => console.log(evt) loader.on('loaded', handler) loader.off('loaded', handler) // or loader.removeListener('loaded', handler) ``` ``` -------------------------------- ### loader.load(arg?, alsoDefaultLib?) Source: https://context7.com/ibsheet/loader/llms.txt Dynamically injects one or more registered library assets into the DOM. The `arg` parameter can be a registry alias string, an array of aliases, or a raw `RegistryItemData` object for inline registration. If `arg` is omitted, the default library (ibsheet) is loaded. Returns `this` for chaining. ```APIDOC ## loader.load(arg?, alsoDefaultLib?) ### Description Dynamically injects one or more registered library assets into the DOM. `arg` can be a registry alias string, an array of aliases, or a raw `RegistryItemData` object for inline registration. If `arg` is omitted, the default library (ibsheet) is loaded. Returns `this` for chaining. ### Parameters #### arg - **arg** (string | array | object) - Optional - Can be a registered alias string, an array of alias strings, or a `RegistryItemData` object for inline registration. If omitted, the default library (ibsheet) is loaded. - `RegistryItemData` object properties: - **name** (string) - Required - The alias for the library. - **baseUrl** (string) - Optional - Base URL for assets. - **theme** (string) - Optional - Theme to load (e.g., 'default'). - **locales** (array) - Optional - Array of locale codes to load (e.g., ['ko']). - **corefile** (string) - Optional - The main JavaScript file name. - **plugins** (array) - Optional - Array of plugin names to load. - **license** (string) - Optional - Inline license key. #### alsoDefaultLib - **alsoDefaultLib** (boolean) - Optional - If true, also loads the default library along with the specified `arg`. ### Returns - `this` - Returns the loader instance for chaining. ### Example ```javascript import loader from '@ibsheet/loader' loader.config({ registry: [ { name: 'ibsheet', baseUrl: 'https://cdn.example.com/ibsheet/8', theme: 'default', locales: ['ko'], }, ], }) // Load by registered alias loader.load('ibsheet') // Load inline (no prior registry call needed) loader.load({ name: 'ibsheet', baseUrl: '/assets/ibsheet', theme: 'dark', locales: ['en'], plugins: ['excel'], }) // Load multiple aliases loader.load(['ibsheet', 'ibchart']) // Chain into createSheet — autoload handles the load automatically loader .load('ibsheet') .on('load-complete', () => { console.log('All queued loads finished') }) ``` ``` -------------------------------- ### loader.createMap Source: https://context7.com/ibsheet/loader/llms.txt Loads IBMap (if not already loaded) and creates a new map instance. Requires `el` / `elem` (container element id) and `options` / `cfg` (map configuration object). Returns `Promise`. ```APIDOC ## `loader.createMap(options)` Loads IBMap (if not already loaded) and creates a new map instance. Requires `el` / `elem` (container element id) and `options` / `cfg` (map configuration object). Returns `Promise`. ### Usage Example: ```js import loader from '@ibsheet/loader' loader.config({ registry: [ { name: 'ibmap', baseUrl: '/assets/ibmap', }, ], }) loader .createMap({ el: 'mapContainer', // or elem: 'mapContainer' options: { // or cfg: { ... } center: [37.5665, 126.9780], zoom: 10, }, }) .then((map) => { console.log('Map created') }) .catch((err) => { console.error('Map creation failed:', err) }) ``` ``` -------------------------------- ### Build Project Source: https://github.com/ibsheet/loader/blob/master/README.md Executes the build process for the project, typically compiling assets for production. ```sh yarn build ``` -------------------------------- ### Create IBSheet Instance Source: https://github.com/ibsheet/loader/blob/master/public/index.html Create an IBSheet instance with specified ID, container element, and configuration options, including column definitions and initial data. Handles success and error callbacks. ```javascript loader.createSheet({ id: 'sheet', el: 'sheetContainer', options: { Cfg: { SearchMode: 2, HeaderMerge: 3 }, Cols: [ { Header: 'ID', Name: 'id', Type: 'Text', Width: 80 }, { Header: 'Name', Name: 'name', Type: 'Text', Width: 150 }, { Header: 'Age', Name: 'age', Type: 'Int', Width: 80 } ] }, data: [ { id: '1', name: 'John', age: 25 }, { id: '2', name: 'Jane', age: 30 }, { id: '3', name: 'Bob', age: 35 } ] }).then(sheet => { sheetInstance = sheet; log('sheetLog', '✓ Sheet created successfully'); }).catch(err => { log('sheetLog', '✗ Error creating sheet: ' + err.message); }); ``` -------------------------------- ### loader.list() and loader.info(alias) Source: https://context7.com/ibsheet/loader/llms.txt `list()` returns a summary array of all registered items with their `alias` and `loaded` status. `info(alias)` returns a formatted JSON string of the raw data for a given alias. ```APIDOC ## `loader.list()` and `loader.info(alias)` ### Description `list()` returns a summary array of all registered items with their `alias` and `loaded` status. `info(alias)` returns a formatted JSON string of the raw data for a given alias. ### Methods - **list()**: Returns a summary array of all registered items. - **info(alias)**: Returns a formatted JSON string of the raw data for a given alias. ### Parameters #### Path Parameters for `info` - **alias** (string) - Required - The alias of the registry item to get information for. ``` -------------------------------- ### List Registered Items with loader.list and loader.info Source: https://context7.com/ibsheet/loader/llms.txt `list()` returns a summary array of all registered items with their `alias` and `loaded` status. `info(alias)` returns a formatted JSON string of the raw data for a given alias. ```javascript import loader from '@ibsheet/loader' loader.config({ registry: [ { name: 'ibsheet', baseUrl: '/assets/ibsheet' }, { name: 'ibchart', baseUrl: '/assets/ibchart' }, ], }) // List all registered items const items = loader.list() // [ { alias: 'ibsheet', loaded: false }, { alias: 'ibchart', loaded: false } ] console.log(items) // Get detailed info for a specific item console.log(loader.info('ibsheet')) // { // "id": "...", // "urls": ["/assets/ibsheet/css/default/main.css", "/assets/ibsheet/locale/ko.js", ...], // "name": "ibsheet", // "version": null, // "alias": "ibsheet", // "loaded": false // } ``` -------------------------------- ### loader.config(options) Source: https://context7.com/ibsheet/loader/llms.txt Initializes or updates loader-level settings. This method accepts an options object to configure debugging, automatic loading, retry policies, global variable names, registry items, presets, and a ready callback. ```APIDOC ## loader.config(options) ### Description Initializes or updates loader-level settings before any load calls are made. Accepts `debug`, `autoload`, `retry`, `globals`, `registry`, `preset`, and a `ready` callback. Calling `config()` is optional but recommended when you need to pre-register libraries, override global variable names, or set retry behavior. ### Parameters #### Options Object - **debug** (boolean) - Optional - Enable verbose console logging. - **autoload** (boolean) - Optional - Automatically load the default (ibsheet) library when createSheet() is called. - **retry** (object) - Optional - Retry policy for load validation polling. - **maxCount** (number) - Optional - poll up to maxCount times. - **intervalTime** (number) - Optional - poll every intervalTime ms. - **globals** (object) - Optional - Override the window global variable names for each product. - **ibsheet** (string) - Optional - Default: 'IBSheet'. - **ibchart** (string) - Optional - Default: 'IBChart'. - **ibmap** (string) - Optional - Default: 'IBMapCharts'. - **registry** (array) - Optional - Pre-register libraries with asset configurations. - Each item in the array is a `RegistryItemData` object: - **name** (string) - Required - The alias for the library. - **baseUrl** (string) - Optional - Base URL for assets. - **theme** (string) - Optional - Theme to load (e.g., 'default'). - **locales** (array) - Optional - Array of locale codes to load (e.g., ['ko']). - **corefile** (string) - Optional - The main JavaScript file name. - **plugins** (array) - Optional - Array of plugin names to load. - **license** (string) - Optional - Inline license key. - **preset** (string) - Optional - Name of a preset configuration to apply. - **ready** (function) - Optional - Callback function fired once the DOM is ready. ### Example ```javascript import loader from '@ibsheet/loader' loader.config({ debug: false, autoload: true, retry: { maxCount: 20, intervalTime: 200, }, globals: { ibsheet: 'IBSheet', ibchart: 'IBChart', ibmap: 'IBMapCharts', }, registry: [ { name: 'ibsheet', baseUrl: '/ibsheet', theme: 'default', locales: ['ko'], corefile: 'ibsheet.js', plugins: ['excel', 'common'], license: 'xxxx-xxxx-xxxx-xxxx', }, ], ready() { console.log('Loader is ready') }, }) ``` ``` -------------------------------- ### Handle IBChart Creation Events Source: https://github.com/ibsheet/loader/blob/master/public/index.html Sets up event listeners for IBChart creation lifecycle. This includes handling the 'create-chart' initiation, successful 'created-chart' event, and 'create-chart-failed' errors. ```javascript loader.once('create-chart', evt => { console.log('loader once create-chart event'); console.log(evt); console.log(evt.target); }) ``` ```javascript loader.once('created-chart', evt => { console.log('loader once created-chart event'); console.log(evt); console.log('created chartId:', evt.target.getId()) }) ``` ```javascript loader.once('create-chart-failed', evt => { console.log('loader once create-chart-failed event'); console.log(evt); }) ``` -------------------------------- ### Handle IBMap Loader Events Source: https://github.com/ibsheet/loader/blob/master/public/index.html Set up event listeners for IBMap lifecycle events like 'create-map', 'created-map', 'remove-map', and 'removed-map'. This allows for reacting to map creation and removal. ```javascript loader.once('create-map', evt => { console.log('loader once create-map event'); console.log(evt); // const { data } = evt // console.log('create chartId:', data.id) }) ``` ```javascript loader.once('created-map', evt => { console.log('loader once created-map event'); console.log(evt); // const chart = evt.target // console.log('created chartId:', chart.id) }) ``` ```javascript loader.once('create-map-failed', evt => { console.log('loader once create-map-failed event'); console.log(evt); // const { data, error } = evt // console.error('\[CREATE_MAP_ERROR\]', data.id, error) }) ``` ```javascript loader.once('remove-map', evt => { console.log('loader once remove-map event'); console.log(evt); // const map = evt.target // console.log('remove mapId:', map.id) }) ``` ```javascript loader.once('removed-map', evt => { console.log('loader once removed-map event'); console.log(evt); // const { data } = evt // console.log('removed mapId:', data.id) }) ``` ```javascript loader.once('remove-map-failed', evt => { console.log('loader once remove-map-failed event'); console.log(evt); // const { data, error } = evt // console.error('\[REMOVE_MAP_ERROR\]', data.id, error) }) ``` -------------------------------- ### Configuring IBSheet Loader Settings Source: https://context7.com/ibsheet/loader/llms.txt Initialize or update loader settings using `loader.config()`. This is recommended for pre-registering libraries, overriding global variable names, or setting retry behavior. Options include debug, autoload, retry policy, global variable overrides, registry configuration, and a ready callback. ```javascript import loader from '@ibsheet/loader' loader.config({ // Enable verbose console logging debug: false, // Automatically load the default (ibsheet) library when createSheet() is called autoload: true, // Retry policy for load validation polling retry: { maxCount: 20, // poll up to 20 times intervalTime: 200, // every 200ms }, // Override the window global variable names for each product globals: { ibsheet: 'IBSheet', // default ibchart: 'IBChart', ibmap: 'IBMapCharts', }, // Pre-register IBSheet with full asset configuration registry: [ { name: 'ibsheet', baseUrl: '/ibsheet', theme: 'default', // loads css/default/main.css locales: ['ko'], // loads locale/ko.js corefile: 'ibsheet.js', // main JS file plugins: ['excel', 'common'], // loads plugins/ibsheet-excel.js, plugins/ibsheet-common.js license: 'xxxx-xxxx-xxxx-xxxx', // inline license key }, ], // Fired once the DOM is ready ready() { console.log('Loader is ready') }, }) ``` -------------------------------- ### Dynamically Loading Library Assets Source: https://context7.com/ibsheet/loader/llms.txt Use `loader.load()` to inject library assets into the DOM. You can load by registered alias, an array of aliases, or a raw `RegistryItemData` object for inline registration. If `arg` is omitted, the default library (ibsheet) is loaded. The method returns `this` for chaining. ```javascript import loader from '@ibsheet/loader' loader.config({ registry: [ { name: 'ibsheet', baseUrl: 'https://cdn.example.com/ibsheet/8', theme: 'default', locales: ['ko'], }, ], }) // Load by registered alias loader.load('ibsheet') // Load inline (no prior registry call needed) loader.load({ name: 'ibsheet', baseUrl: '/assets/ibsheet', theme: 'dark', locales: ['en'], plugins: ['excel'], }) // Load multiple aliases loader.load(['ibsheet', 'ibchart']) // Chain into createSheet — autoload handles the load automatically loader .load('ibsheet') .on('load-complete', () => { console.log('All queued loads finished') }) ``` -------------------------------- ### loader.sheetReady(callback?) Source: https://context7.com/ibsheet/loader/llms.txt Waits for IBSheet to finish loading, then resolves with the IBSheet global static object. If IBSheet is already loaded, resolves immediately. Optionally accepts a callback invoked with the static object. Useful as a guard before calling IBSheet APIs directly. ```APIDOC ## `loader.sheetReady(callback?)` ### Description Waits for IBSheet to finish loading, then resolves with the IBSheet global static object. If IBSheet is already loaded, resolves immediately. Optionally accepts a callback invoked with the static object. Useful as a guard before calling IBSheet APIs directly. ### Parameters #### Path Parameters - **callback** (function) - Optional - A callback function invoked with the IBSheet static object. ``` -------------------------------- ### Load IBChart with Dependencies Source: https://github.com/ibsheet/loader/blob/master/public/index.html Load the IBChart component, specifying its name, base URL, and an array of dependent URLs, including Highcharts core and modules. Also includes license information. ```javascript loader .once('loaded', evt => { console.log('loader ibchart loaded'); console.log(evt); const target = evt.target console.log(target); if (target.alias === 'ibchart') { IBChart = loader.getIBChartStatic() console.log('IBChart Static :'); console.log(IBChart); } // if (target.alias === 'ibsheet') { // IBSheet = loader.getIBSheetStatic() // console.log('IBSheet Static :'); // console.log(IBSheet); // } }) .load({ name: 'ibchart', baseUrl: '/chart', dependentUrls: [ // '/highcharts/highcharts.js', // '/highcharts/highcharts-more.js', // '/highcharts/modules/solid-gauge.js', // '/highcharts/modules/heatmap.js', 'https://code.highcharts.com/highcharts.js', 'https://code.highcharts.com/highcharts-more.js', 'https://code.highcharts.com/modules/solid-gauge.js' ], // license: '/ibleaders.js' license: '5678', }) ``` -------------------------------- ### Importing the IBSheet Loader Instance Source: https://context7.com/ibsheet/loader/llms.txt Import the pre-built singleton IBSheetLoader instance based on your module system (ESModule, CommonJS, or Browser global). ```javascript // ESModule / TypeScript import loader from '@ibsheet/loader' // or named export: import { IBSheetLoader as loader } from '@ibsheet/loader' // CommonJS const loader = require('@ibsheet/loader') // Browser global (UMD) — window.IBSheetLoader is set automatically const loader = window.IBSheetLoader console.log(loader.version) // e.g. "1.3.4" ``` -------------------------------- ### loader.createSheet Source: https://context7.com/ibsheet/loader/llms.txt Loads IBSheet (if not already loaded) and instantiates a new sheet on the page. Returns a `Promise`. The `id` property is auto-generated if omitted; `el` / `elementId` refer to the target container element's DOM id. The `options` / `config` key accepts the full IBSheet options object (`Cfg`, `Def`, `Cols`, etc.). ```APIDOC ## `loader.createSheet(options)` Loads IBSheet (if not already loaded) and instantiates a new sheet on the page. Returns a `Promise`. The `id` property is auto-generated if omitted; `el` / `elementId` refer to the target container element's DOM id. The `options` / `config` key accepts the full IBSheet options object (`Cfg`, `Def`, `Cols`, etc.). ### Usage Examples: ```js import loader from '@ibsheet/loader' loader.config({ registry: [ { name: 'ibsheet', baseUrl: '/assets/ibsheet', theme: 'default', locales: ['ko'], }, ], }) // Minimal usage — id and el are optional loader .createSheet({ el: 'sheetDiv', // id of target
options: { Cfg: { SearchMode: 2, MergeSheet: 4 }, Def: { Row: { Height: 24 } }, Cols: [ { Header: 'Name', Width: 120 }, { Header: 'Score', Width: 80, Type: 'Int' }, ], }, data: { Row: [ { Name: 'Alice', Score: 95 }, { Name: 'Bob', Score: 87 }, ], }, }) .then((sheet) => { console.log('Sheet created, id:', sheet.id) }) .catch((err) => { console.error('Sheet creation failed:', err) }) // Using an HTMLElement reference directly const el = document.getElementById('myGrid') loader.createSheet({ element: el, options: { Cfg: { SearchMode: 2 } } }) .then((sheet) => console.log('Sheet id:', sheet.id)) ``` ``` -------------------------------- ### Load IBSheet with Options Source: https://github.com/ibsheet/loader/blob/master/public/index.html Load the IBSheet component using the loader. This includes specifying the base URL, locales, plugins, and license. It also handles the 'loaded' event to confirm successful loading. ```javascript loader .once('loaded', evt => { // log('sheetLog', '✓ IBSheet loaded successfully'); console.log('loader ibsheet loaded'); console.log(evt); const target = evt.target console.log(target); console.log('ibsheet loaded!') if (target.alias === 'ibsheet') { IBSheet = loader.getIBSheetStatic() console.log('IBSheet Static :'); console.log(IBSheet); } }) .load({ name: 'ibsheet', baseUrl: '/sheet', locales: ['ko'], plugins: ['dialog', 'common', 'excel'], // dependentUrls: [ // // 추가 의존성 파일이 있다면 여기에 // // ], // license: 'your-license-key-here' license: '1234', }) ``` -------------------------------- ### Handle IBSheet Creation Events Source: https://github.com/ibsheet/loader/blob/master/public/index.html Sets up event listeners for IBSheet creation lifecycle. This includes handling the 'create-sheet' initiation, successful 'created-sheet' event, and 'create-sheet-failed' errors. ```javascript loader.once('create-sheet', evt => { console.log('loader once create-sheet event'); console.log(evt); const { data } = evt console.log('create sheetId:', data.id) }) ``` ```javascript loader.once('created-sheet', evt => { console.log('loader once created-sheet event'); const sheet = evt.target console.log('created sheetId:', sheet.id) }) ``` ```javascript loader.once('create-sheet-failed', evt => { console.log('loader once create-sheet-failed event'); console.log(evt); const { data, error } = evt console.error('Create SHEET_ERROR', data.id, error) }) ``` -------------------------------- ### Create IBSheet Instance Source: https://context7.com/ibsheet/loader/llms.txt Loads IBSheet (if not already loaded) and instantiates a new sheet on the page. The `id` property is auto-generated if omitted; `el` / `elementId` refer to the target container element's DOM id. The `options` / `config` key accepts the full IBSheet options object. Handles creation success or failure via Promises. ```javascript import loader from '@ibsheet/loader' loader.config({ registry: [ { name: 'ibsheet', baseUrl: '/assets/ibsheet', theme: 'default', locales: ['ko'], }, ], }) // Minimal usage — id and el are optional loader .createSheet({ el: 'sheetDiv', // id of target
options: { Cfg: { SearchMode: 2, MergeSheet: 4 }, Def: { Row: { Height: 24 } }, Cols: [ { Header: 'Name', Width: 120 }, { Header: 'Score', Width: 80, Type: 'Int' }, ], }, data: { Row: [ { Name: 'Alice', Score: 95 }, { Name: 'Bob', Score: 87 }, ], }, }) .then((sheet) => { console.log('Sheet created, id:', sheet.id) }) .catch((err) => { console.error('Sheet creation failed:', err) }) // Using an HTMLElement reference directly const el = document.getElementById('myGrid') loader.createSheet({ element: el, options: { Cfg: { SearchMode: 2 } } }) .then((sheet) => console.log('Sheet id:', sheet.id)) ``` -------------------------------- ### Manage Library Registry with loader.registry Source: https://context7.com/ibsheet/loader/llms.txt The `registry` property exposes the `LoaderRegistry` for managing registered library definitions. Use it to add, query, update, or remove items at runtime. ```javascript import loader from '@ibsheet/loader' // Add a single item loader.registry.add({ name: 'ibsheet', baseUrl: '/assets/ibsheet', theme: 'default', locales: ['ko'], plugins: ['excel'], }) // Add multiple items at once loader.registry.addAll([ { name: 'ibsheet', baseUrl: '/assets/ibsheet' }, { name: 'ibchart', baseUrl: '/assets/ibchart' }, ]) // Check existence console.log(loader.registry.exists('ibsheet')) // true / false // Retrieve a registry item const item = loader.registry.get('ibsheet') console.log(item.alias, item.loaded) // "ibsheet", false // Get all items (or filter by name) const allItems = loader.registry.getAll() const sheetItems = loader.registry.getAll('ibsheet') // List all aliases console.log(loader.registry.list()) // ["ibsheet", "ibchart", ...] // Inspect as JSON string console.log(loader.registry.info('ibsheet')) // Update an existing item's URLs / options loader.registry.update('ibsheet', { theme: 'dark', locales: ['en'], }) // Remove an item loader.registry.remove('ibsheet') // Item count console.log(loader.registry.length) ```