Skip to content

Commit

Permalink
fix(type): add missing type info required by sn-table (#1193)
Browse files Browse the repository at this point in the history
* fix(type): add missing type info required by `sn-table`

* fix: add default arg for `exitFunction` and `focusSelectionFunction`

* fix: make `blur()` and `focusSelection()` optional like before

* chore: review comments

* chore: rename `api.on(...)` to `api.addListener(...)`

* chore: rebase with upstream
  • Loading branch information
a-m-dev authored May 5, 2023
1 parent 31b2775 commit 53573b6
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 15 deletions.
5 changes: 5 additions & 0 deletions apis/locale/src/translator.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ export default function translator({ initial = 'en-US', fallback = 'en-US' } = {
* @class Translator
*/
const api = /** @lends Translator# */ {
/**
* Returns current locale.
* @param {string=} lang - language Locale to updated the currentLocale value
* @returns {string} current locale.
*/
language: (lang) => {
if (lang) {
currentLocale = lang;
Expand Down
22 changes: 22 additions & 0 deletions apis/nucleus/src/hooks/useObjectSelections.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,28 @@ const createObjectSelections = ({ appSelections, appModal, model }) => {
let isActive = false;
let hasSelected = false;

/**
* Event listener function on instance
*
* @method
* @name ObjectSelections#addListener
* @param {string} eventType event type that function needs to listen
* @param {Function} callback a callback function to run when event emits
* @example
* api.addListener('someEvent', () => {...});
*/

/**
* Remove listener function on instance
*
* @method
* @name ObjectSelections#removeListener
* @param {string} eventType event type that function needs to listen
* @param {Function} callback a callback function to run when event emits
* @example
* api.removeListener('someEvent', () => {...});
*/

/**
* @class
* @alias ObjectSelections
Expand Down
86 changes: 81 additions & 5 deletions apis/stardust/api-spec/spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,46 @@
"params": []
},
"entries": {
"addListener": {
"description": "Event listener function on instance",
"kind": "function",
"params": [
{
"name": "eventType",
"description": "event type that function needs to listen",
"type": "string"
},
{
"name": "callback",
"description": "a callback function to run when event emits",
"kind": "function",
"params": []
}
],
"examples": [
"api.addListener('someEvent', () => {...});"
]
},
"removeListener": {
"description": "Remove listener function on instance",
"kind": "function",
"params": [
{
"name": "eventType",
"description": "event type that function needs to listen",
"type": "string"
},
{
"name": "callback",
"description": "a callback function to run when event emits",
"kind": "function",
"params": []
}
],
"examples": [
"api.removeListener('someEvent', () => {...});"
]
},
"begin": {
"kind": "function",
"params": [
Expand Down Expand Up @@ -2093,22 +2133,30 @@
"type": "boolean"
},
"blur": {
"description": "Function used by the visualization to tell Nebula to it wants to relinquish focus",
"description": "Function used by the visualization to tell Nebula it wants to relinquish focus",
"optional": true,
"kind": "function",
"params": []
"params": [
{
"type": "boolean"
}
]
},
"focus": {
"description": "Function used by the visualization to tell Nebula to it wants focus",
"description": "Function used by the visualization to tell Nebula it wants to focus",
"optional": true,
"kind": "function",
"params": []
},
"focusSelection": {
"description": "Function used by the visualization to tell Nebula to focus the selection toolbar",
"description": "Function used by the visualization to tell Nebula that focus the selection toolbar",
"optional": true,
"kind": "function",
"params": []
"params": [
{
"type": "boolean"
}
]
}
}
},
Expand Down Expand Up @@ -2335,6 +2383,22 @@
"params": []
},
"entries": {
"language": {
"description": "Returns current locale.",
"kind": "function",
"params": [
{
"name": "lang",
"description": "language Locale to updated the currentLocale value",
"optional": true,
"type": "string"
}
],
"returns": {
"description": "current locale.",
"type": "string"
}
},
"add": {
"description": "Registers a string in multiple locales",
"kind": "function",
Expand Down Expand Up @@ -2397,6 +2461,18 @@
"params": []
},
"entries": {
"name": {
"description": "Returns theme name",
"kind": "function",
"params": [],
"returns": {
"description": "Current theme.",
"type": "string"
},
"examples": [
"theme.name();"
]
},
"getDataColorScales": {
"kind": "function",
"params": [],
Expand Down
37 changes: 32 additions & 5 deletions apis/stardust/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,20 @@ declare namespace stardust {
class ObjectSelections {
constructor();

/**
* Event listener function on instance
* @param eventType event type that function needs to listen
* @param callback a callback function to run when event emits
*/
addListener(eventType: string, callback: ()=>void): void;

/**
* Remove listener function on instance
* @param eventType event type that function needs to listen
* @param callback a callback function to run when event emits
*/
removeListener(eventType: string, callback: ()=>void): void;

/**
* @param paths
*/
Expand Down Expand Up @@ -630,17 +644,19 @@ declare namespace stardust {
enabled: boolean;
active: boolean;
/**
* Function used by the visualization to tell Nebula to it wants to relinquish focus
* Function used by the visualization to tell Nebula it wants to relinquish focus
* @param $
*/
blur?(): void;
blur?($: boolean): void;
/**
* Function used by the visualization to tell Nebula to it wants focus
* Function used by the visualization to tell Nebula it wants to focus
*/
focus?(): void;
/**
* Function used by the visualization to tell Nebula to focus the selection toolbar
* Function used by the visualization to tell Nebula that focus the selection toolbar
* @param $
*/
focusSelection?(): void;
focusSelection?($: boolean): void;
}

/**
Expand Down Expand Up @@ -691,6 +707,12 @@ declare namespace stardust {
class Translator {
constructor();

/**
* Returns current locale.
* @param lang language Locale to updated the currentLocale value
*/
language(lang?: string): string;

/**
* Registers a string in multiple locales
* @param item
Expand All @@ -712,6 +734,11 @@ declare namespace stardust {
class Theme {
constructor();

/**
* Returns theme name
*/
name(): string;

getDataColorScales(): stardust.Theme.ScalePalette[];

getDataColorPalettes(): stardust.Theme.DataPalette[];
Expand Down
10 changes: 5 additions & 5 deletions apis/supernova/src/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -1148,9 +1148,9 @@ export function useEmitter() {
* @interface Keyboard
* @property {boolean} enabled Whether or not Nebula handles keyboard navigation or not.
* @property {boolean} active Set to true when the chart is activated, ie a user tabs to the chart and presses Enter or Space.
* @property {function=} blur Function used by the visualization to tell Nebula to it wants to relinquish focus
* @property {function=} focus Function used by the visualization to tell Nebula to it wants focus
* @property {function=} focusSelection Function used by the visualization to tell Nebula to focus the selection toolbar
* @property {function(boolean)=} blur Function used by the visualization to tell Nebula it wants to relinquish focus
* @property {function=} focus Function used by the visualization to tell Nebula it wants to focus
* @property {function(boolean)=} focusSelection Function used by the visualization to tell Nebula that focus the selection toolbar
*/

/**
Expand Down Expand Up @@ -1187,7 +1187,7 @@ export function useKeyboard() {
const focusHandler = useInternalContext('focusHandler');

if (!currentComponent.__hooks.accessibility.exitFunction) {
const exitFunction = function (resetFocus) {
const exitFunction = function (resetFocus = false) {
const acc = this.__hooks.accessibility;
if (acc.enabled && acc.active) {
blur(this);
Expand All @@ -1207,7 +1207,7 @@ export function useKeyboard() {

currentComponent.__hooks.accessibility.focusFunction = focusFunction;

const focusSelectionFunction = function (focusLast) {
const focusSelectionFunction = function (focusLast = false) {
const acc = this.__hooks.accessibility;
if (acc.enabled) {
focusHandler && focusHandler.focusToolbarButton && focusHandler.focusToolbarButton(focusLast);
Expand Down
10 changes: 10 additions & 0 deletions apis/theme/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ export default function theme() {

let contraster;

/**
* Returns theme name
*
* @method
* @name Theme#name
* @returns {string} Current theme.
* @example
* theme.name();
*/

/**
* @class
* @alias Theme
Expand Down

0 comments on commit 53573b6

Please sign in to comment.