@itwin/imodel-components-react 5.0.5 → 5.1.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.
Files changed (72) hide show
  1. package/CHANGELOG.md +10 -3
  2. package/lib/imodel-components-react/color/AlphaSlider.js +2 -2
  3. package/lib/imodel-components-react/color/AlphaSlider.js.map +1 -1
  4. package/lib/imodel-components-react/color/ColorPickerButton.d.ts.map +1 -1
  5. package/lib/imodel-components-react/color/ColorPickerButton.js +2 -3
  6. package/lib/imodel-components-react/color/ColorPickerButton.js.map +1 -1
  7. package/lib/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
  8. package/lib/imodel-components-react/color/ColorPickerPopup.js +1 -1
  9. package/lib/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
  10. package/lib/imodel-components-react/color/HueSlider.js.map +1 -1
  11. package/lib/imodel-components-react/color/SaturationPicker.js.map +1 -1
  12. package/lib/imodel-components-react/color/Swatch.js +1 -1
  13. package/lib/imodel-components-react/color/Swatch.js.map +1 -1
  14. package/lib/imodel-components-react/editors/ColorEditor.d.ts +1 -0
  15. package/lib/imodel-components-react/editors/ColorEditor.d.ts.map +1 -1
  16. package/lib/imodel-components-react/editors/ColorEditor.js +2 -1
  17. package/lib/imodel-components-react/editors/ColorEditor.js.map +1 -1
  18. package/lib/imodel-components-react/editors/WeightEditor.d.ts +1 -0
  19. package/lib/imodel-components-react/editors/WeightEditor.d.ts.map +1 -1
  20. package/lib/imodel-components-react/editors/WeightEditor.js +1 -0
  21. package/lib/imodel-components-react/editors/WeightEditor.js.map +1 -1
  22. package/lib/imodel-components-react/inputs/QuantityInput.js.map +1 -1
  23. package/lib/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
  24. package/lib/imodel-components-react/lineweight/Swatch.js.map +1 -1
  25. package/lib/imodel-components-react/lineweight/WeightPickerButton.d.ts.map +1 -1
  26. package/lib/imodel-components-react/lineweight/WeightPickerButton.js +1 -1
  27. package/lib/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
  28. package/lib/imodel-components-react/navigationaids/Cube.js.map +1 -1
  29. package/lib/imodel-components-react/navigationaids/CubeNavigationAid.js +1 -1
  30. package/lib/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
  31. package/lib/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts.map +1 -1
  32. package/lib/imodel-components-react/navigationaids/DrawingNavigationAid.js +0 -1
  33. package/lib/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
  34. package/lib/imodel-components-react/quantityformat/FormatPanel.js +1 -1
  35. package/lib/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
  36. package/lib/imodel-components-react/quantityformat/FormatPrecision.js +1 -1
  37. package/lib/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
  38. package/lib/imodel-components-react/quantityformat/FormatSample.js +2 -2
  39. package/lib/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
  40. package/lib/imodel-components-react/quantityformat/FormatType.js +1 -1
  41. package/lib/imodel-components-react/quantityformat/FormatType.js.map +1 -1
  42. package/lib/imodel-components-react/quantityformat/FormatUnitLabel.js +1 -1
  43. package/lib/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
  44. package/lib/imodel-components-react/quantityformat/FormatUnits.js +1 -1
  45. package/lib/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
  46. package/lib/imodel-components-react/quantityformat/MiscFormatOptions.js +1 -1
  47. package/lib/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
  48. package/lib/imodel-components-react/quantityformat/QuantityFormatPanel.js +1 -1
  49. package/lib/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
  50. package/lib/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
  51. package/lib/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
  52. package/lib/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
  53. package/lib/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
  54. package/lib/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
  55. package/lib/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
  56. package/lib/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
  57. package/lib/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
  58. package/lib/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
  59. package/lib/imodel-components-react/quantityformat/misc/UnitDescr.js.map +1 -1
  60. package/lib/imodel-components-react/timeline/InlineEdit.js.map +1 -1
  61. package/lib/imodel-components-react/timeline/Scrubber.js.map +1 -1
  62. package/lib/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
  63. package/lib/imodel-components-react/timeline/SpeedTimeline.js.map +1 -1
  64. package/lib/imodel-components-react/timeline/TimelineComponent.js +3 -3
  65. package/lib/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
  66. package/lib/imodel-components-react/viewport/ViewportComponent.js +6 -6
  67. package/lib/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
  68. package/lib/imodel-components-react/viewport/ViewportComponentEvents.js +12 -12
  69. package/lib/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
  70. package/lib/imodel-components-react.js +1 -1
  71. package/lib/imodel-components-react.js.map +1 -1
  72. package/package.json +15 -13
@@ -1 +1 @@
1
- {"version":3,"file":"UnitDescr.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/misc/UnitDescr.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAiBrD,KAAK,UAAU,qBAAqB,CAClC,aAA0B,EAC1B,MAAiB,EACjB,aAA4B;IAE5B,MAAM,qBAAqB,GAAG,aAAa,CAAC,GAAG,CAAC,KAAK,EA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CAAC;oBACtB,cAAc,CAAC,OAAO,CAAC,CAAC;oBACxB,cAAc,CAAC,gBAAgB,CAAC,CAAC;gBACnC,CAAC;YACH,CAAC;QACH,CAAC;QACD,KAAK,4BAA4B,EAAE,CAAC;IACtC,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,aAAa,CAAC,CAAC,CAAC;IAExD,MAAM,kBAAkB,GAAG,KAAK,CAAC,WAAW,CAC1C,CAAC,QAAgB,EAAE,EAAE;QACnB,YAAY,IAAI,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAChD,CAAC,EACD,CAAC,KAAK,EAAE,YAAY,CAAC,CACtB,CAAC;IAEF,MAAM,mBAAmB,GAAG,KAAK,CAAC,WAAW,CAC3C,CAAC,CAAsC,EAAE,EAAE;QACzC,CAAC,CAAC,cAAc,EAAE,CAAC;QACnB,aAAa,IAAI,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC,EACD,CAAC,KAAK,EAAE,aAAa,CAAC,CACvB,CAAC;IAEF,OAAO,CACL;QACE,oBAAC,MAAM,IACL,OAAO,EAAE,WAAW,iBACP,QAAQ,WAAW,CAAC,IAAI,EAAE,EACvC,KAAK,EAAE,GAAG,WAAW,CAAC,IAAI,IAAI,WAAW,CAAC,KAAK,EAAE,EACjD,QAAQ,EAAE,kBAAkB,EAC5B,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAC,OAAO,GACZ;QACF,oBAAC,KAAK,mBACS,cAAc,WAAW,CAAC,IAAI,EAAE,EAC7C,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,mBAAmB,EAC7B,IAAI,EAAC,OAAO,GACZ,CACD,CACJ,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module QuantityFormat\n */\n\nimport * as React from \"react\";\nimport type { UnitProps, UnitsProvider } from \"@itwin/core-quantity\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { SelectOption } from \"@itwin/itwinui-react\";\nimport { Input, Select } from \"@itwin/itwinui-react\";\n\n/** Properties of [[UnitDescr]] component.\n * @internal\n */\n// eslint-disable-next-line deprecation/deprecation\nexport interface UnitDescrProps extends CommonProps {\n name: string;\n parentUnitName?: string;\n label: string;\n index: number;\n unitsProvider: UnitsProvider;\n readonly?: boolean;\n onUnitChange: (value: string, index: number) => void;\n onLabelChange: (value: string, index: number) => void;\n}\n\nasync function getUnitConversionData(\n possibleUnits: UnitProps[],\n toUnit: UnitProps,\n unitsProvider: UnitsProvider\n) {\n const unitConversionEntries = possibleUnits.map(async (unit) => {\n const conversion = await unitsProvider.getConversion(unit, toUnit);\n return { conversion, unitProps: unit };\n });\n return unitConversionEntries;\n}\n\nasync function getPossibleUnits(\n parentUnit: UnitProps,\n unitsProvider: UnitsProvider,\n ensureCompatibleComposite: boolean\n) {\n const phenomenon = parentUnit.phenomenon;\n const possibleUnits = await unitsProvider.getUnitsByFamily(phenomenon);\n if (!ensureCompatibleComposite) return possibleUnits;\n\n const conversionPromises = await getUnitConversionData(\n possibleUnits,\n parentUnit,\n unitsProvider\n );\n const conversionEntries = await Promise.all(conversionPromises);\n // sort the entries so the best potential sub unit will be the first one in the array\n return conversionEntries\n .filter(\n (entry) =>\n entry.unitProps.system === parentUnit.system &&\n entry.conversion.factor < 1\n )\n .sort((a, b) => b.conversion.factor - a.conversion.factor)\n .map((value) => value.unitProps);\n}\n\nfunction getUnitName(fullUnitName: string) {\n const nameParts = fullUnitName.split(/[.:]/);\n if (nameParts.length > 0) return nameParts[nameParts.length - 1];\n throw Error(\"Bad unit name encountered\");\n}\n\n/** Component use to display dropdown list of possible units.\n * @internal\n */\nexport function UnitDescr(props: UnitDescrProps) {\n const {\n name,\n label,\n parentUnitName,\n index,\n onUnitChange,\n onLabelChange,\n readonly,\n unitsProvider,\n } = props;\n const [unitOptions, setUnitOptions] = React.useState<SelectOption<string>[]>([\n { value: name, label: getUnitName(name) },\n ]);\n const [currentUnit, setCurrentUnit] = React.useState({ name, label });\n const isMounted = React.useRef(false);\n\n React.useEffect(() => {\n isMounted.current = true;\n return () => {\n isMounted.current = false;\n };\n });\n\n React.useEffect(() => {\n async function fetchAllowableUnitSelections() {\n const currentUnitProps = await unitsProvider.findUnitByName(name);\n const parentUnit = await unitsProvider.findUnitByName(\n parentUnitName ? parentUnitName : name\n );\n if (parentUnit && currentUnitProps) {\n let potentialSubUnit: UnitProps | undefined;\n const potentialUnits = await getPossibleUnits(\n parentUnit,\n unitsProvider,\n index !== 0\n );\n if (index < 3) {\n const potentialSubUnits = await getPossibleUnits(\n currentUnitProps,\n unitsProvider,\n true\n );\n if (potentialSubUnits.length) potentialSubUnit = potentialSubUnits[0];\n }\n\n const options =\n potentialUnits.length > 0\n ? potentialUnits\n .map((unitValue) => {\n return {\n value: `${unitValue.name}:${unitValue.label}`,\n label: getUnitName(unitValue.name),\n };\n })\n .sort((a, b) => a.label.localeCompare(b.label))\n : [\n {\n value: `${currentUnitProps.name}:${currentUnitProps.label}`,\n label: getUnitName(name),\n },\n ];\n\n if (potentialSubUnit) {\n // construct an entry that will provide the name and label of the unit to add\n options.push({\n value: `ADDSUBUNIT:${potentialSubUnit.name}:${potentialSubUnit.label}`,\n label: \"Add sub-unit\",\n }); // NEEDSWORK - i18n\n }\n\n if (index !== 0) options.push({ value: \"REMOVEUNIT\", label: \"Remove\" }); // NEEDSWORK - i18n\n\n if (isMounted.current) {\n setUnitOptions(options);\n setCurrentUnit(currentUnitProps);\n }\n }\n }\n void fetchAllowableUnitSelections();\n }, [index, label, name, parentUnitName, unitsProvider]);\n\n const handleOnUnitChange = React.useCallback(\n (newValue: string) => {\n onUnitChange && onUnitChange(newValue, index);\n },\n [index, onUnitChange]\n );\n\n const handleOnLabelChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n e.preventDefault();\n onLabelChange && onLabelChange(e.target.value, index);\n },\n [index, onLabelChange]\n );\n\n return (\n <>\n <Select\n options={unitOptions}\n data-testid={`unit-${currentUnit.name}`}\n value={`${currentUnit.name}:${currentUnit.label}`}\n onChange={handleOnUnitChange}\n disabled={readonly}\n size=\"small\"\n />\n <Input\n data-testid={`unit-label-${currentUnit.name}`}\n value={label}\n onChange={handleOnLabelChange}\n size=\"small\"\n />\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"UnitDescr.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/misc/UnitDescr.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAiBrD,KAAK,UAAU,qBAAqB,CAClC,aAA0B,EAC1B,MAAiB,EACjB,aAA4B;IAE5B,MAAM,qBAAqB,GAAG,aAAa,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QAC7D,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACnE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACzC,CAAC,CAAC,CAAC;IACH,OAAO,qBAAqB,CAAC;AAC/B,CAAC;AAED,KAAK,UAAU,gBAAgB,CAC7B,UAAqB,EACrB,aAA4B,EAC5B,yBAAkC;IAElC,MAAM,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC;IACzC,MAAM,aAAa,GAAG,MAAM,aAAa,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACvE,IAAI,CAAC,yBAAyB;QAAE,OAAO,aAAa,CAAC;IAErD,MAAM,kBAAkB,GAAG,MAAM,qBAAqB,CACpD,aAAa,EACb,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C,CAAC,cAAc,EAAE,CAAC;QACnB,aAAa,IAAI,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC,EACD,CAAC,KAAK,EAAE,aAAa,CAAC,CACvB,CAAC;IAEF,OAAO,CACL;QACE,oBAAC,MAAM,IACL,OAAO,EAAE,WAAW,iBACP,QAAQ,WAAW,CAAC,IAAI,EAAE,EACvC,KAAK,EAAE,GAAG,WAAW,CAAC,IAAI,IAAI,WAAW,CAAC,KAAK,EAAE,EACjD,QAAQ,EAAE,kBAAkB,EAC5B,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAC,OAAO,GACZ;QACF,oBAAC,KAAK,mBACS,cAAc,WAAW,CAAC,IAAI,EAAE,EAC7C,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,mBAAmB,EAC7B,IAAI,EAAC,OAAO,GACZ,CACD,CACJ,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module QuantityFormat\n */\n\nimport * as React from \"react\";\nimport type { UnitProps, UnitsProvider } from \"@itwin/core-quantity\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { SelectOption } from \"@itwin/itwinui-react\";\nimport { Input, Select } from \"@itwin/itwinui-react\";\n\n/** Properties of [[UnitDescr]] component.\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface UnitDescrProps extends CommonProps {\n name: string;\n parentUnitName?: string;\n label: string;\n index: number;\n unitsProvider: UnitsProvider;\n readonly?: boolean;\n onUnitChange: (value: string, index: number) => void;\n onLabelChange: (value: string, index: number) => void;\n}\n\nasync function getUnitConversionData(\n possibleUnits: UnitProps[],\n toUnit: UnitProps,\n unitsProvider: UnitsProvider\n) {\n const unitConversionEntries = possibleUnits.map(async (unit) => {\n const conversion = await unitsProvider.getConversion(unit, toUnit);\n return { conversion, unitProps: unit };\n });\n return unitConversionEntries;\n}\n\nasync function getPossibleUnits(\n parentUnit: UnitProps,\n unitsProvider: UnitsProvider,\n ensureCompatibleComposite: boolean\n) {\n const phenomenon = parentUnit.phenomenon;\n const possibleUnits = await unitsProvider.getUnitsByFamily(phenomenon);\n if (!ensureCompatibleComposite) return possibleUnits;\n\n const conversionPromises = await getUnitConversionData(\n possibleUnits,\n parentUnit,\n unitsProvider\n );\n const conversionEntries = await Promise.all(conversionPromises);\n // sort the entries so the best potential sub unit will be the first one in the array\n return conversionEntries\n .filter(\n (entry) =>\n entry.unitProps.system === parentUnit.system &&\n entry.conversion.factor < 1\n )\n .sort((a, b) => b.conversion.factor - a.conversion.factor)\n .map((value) => value.unitProps);\n}\n\nfunction getUnitName(fullUnitName: string) {\n const nameParts = fullUnitName.split(/[.:]/);\n if (nameParts.length > 0) return nameParts[nameParts.length - 1];\n throw Error(\"Bad unit name encountered\");\n}\n\n/** Component use to display dropdown list of possible units.\n * @internal\n */\nexport function UnitDescr(props: UnitDescrProps) {\n const {\n name,\n label,\n parentUnitName,\n index,\n onUnitChange,\n onLabelChange,\n readonly,\n unitsProvider,\n } = props;\n const [unitOptions, setUnitOptions] = React.useState<SelectOption<string>[]>([\n { value: name, label: getUnitName(name) },\n ]);\n const [currentUnit, setCurrentUnit] = React.useState({ name, label });\n const isMounted = React.useRef(false);\n\n React.useEffect(() => {\n isMounted.current = true;\n return () => {\n isMounted.current = false;\n };\n });\n\n React.useEffect(() => {\n async function fetchAllowableUnitSelections() {\n const currentUnitProps = await unitsProvider.findUnitByName(name);\n const parentUnit = await unitsProvider.findUnitByName(\n parentUnitName ? parentUnitName : name\n );\n if (parentUnit && currentUnitProps) {\n let potentialSubUnit: UnitProps | undefined;\n const potentialUnits = await getPossibleUnits(\n parentUnit,\n unitsProvider,\n index !== 0\n );\n if (index < 3) {\n const potentialSubUnits = await getPossibleUnits(\n currentUnitProps,\n unitsProvider,\n true\n );\n if (potentialSubUnits.length) potentialSubUnit = potentialSubUnits[0];\n }\n\n const options =\n potentialUnits.length > 0\n ? potentialUnits\n .map((unitValue) => {\n return {\n value: `${unitValue.name}:${unitValue.label}`,\n label: getUnitName(unitValue.name),\n };\n })\n .sort((a, b) => a.label.localeCompare(b.label))\n : [\n {\n value: `${currentUnitProps.name}:${currentUnitProps.label}`,\n label: getUnitName(name),\n },\n ];\n\n if (potentialSubUnit) {\n // construct an entry that will provide the name and label of the unit to add\n options.push({\n value: `ADDSUBUNIT:${potentialSubUnit.name}:${potentialSubUnit.label}`,\n label: \"Add sub-unit\",\n }); // NEEDSWORK - i18n\n }\n\n if (index !== 0) options.push({ value: \"REMOVEUNIT\", label: \"Remove\" }); // NEEDSWORK - i18n\n\n if (isMounted.current) {\n setUnitOptions(options);\n setCurrentUnit(currentUnitProps);\n }\n }\n }\n void fetchAllowableUnitSelections();\n }, [index, label, name, parentUnitName, unitsProvider]);\n\n const handleOnUnitChange = React.useCallback(\n (newValue: string) => {\n onUnitChange && onUnitChange(newValue, index);\n },\n [index, onUnitChange]\n );\n\n const handleOnLabelChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n e.preventDefault();\n onLabelChange && onLabelChange(e.target.value, index);\n },\n [index, onLabelChange]\n );\n\n return (\n <>\n <Select\n options={unitOptions}\n data-testid={`unit-${currentUnit.name}`}\n value={`${currentUnit.name}:${currentUnit.label}`}\n onChange={handleOnUnitChange}\n disabled={readonly}\n size=\"small\"\n />\n <Input\n data-testid={`unit-label-${currentUnit.name}`}\n value={label}\n onChange={handleOnLabelChange}\n size=\"small\"\n />\n </>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"InlineEdit.js","sourceRoot":"","sources":["../../../src/imodel-components-react/timeline/InlineEdit.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,mBAAmB,CAAC;AAC3B,OAAO,UAAU,MAAM,YAAY,CAAC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AzCA,IAAI,CAAC,KAAK,GAAG;YACX,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY;YAC9B,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY;SACvC,CAAC;IACJ,CAAC;IAEe,kBAAkB,CAChC,SAA0B,EAC1B,UAA2B;QAE3B,IAAI,SAAS,CAAC,YAAY,KAAK,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;YACvD,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;gBACzB,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,YAAY,EAAE,aAAa,EAAE,KAAK,CAAC,YAAY,EAAE,CAAC;YAC1E,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IA4BO,WAAW,CAAC,KAAa;QAC/B,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ;YAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtD,CAAC;IAEe,MAAM;QACpB,OAAO,CACL,oBAAC,KAAK,mBACQ,8BAA8B,EAC1C,SAAS,EAAE,UAAU,CAAC,mBAAmB,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAChE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,GAAG,EAAE,IAAI,CAAC,SAAS,EACnB,IAAI,EAAC,MAAM,EACX,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,IAAI,CAAC,QAAQ,EACtB,MAAM,EAAE,IAAI,CAAC,OAAO,EACpB,SAAS,EAAE,IAAI,CAAC,UAAU,EAC1B,QAAQ,EAAE,IAAI,CAAC,SAAS,GACxB,CACH,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\nimport \"./InlineEdit.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Input } from \"@itwin/itwinui-react\";\n\n// eslint-disable-next-line deprecation/deprecation\ninterface InlineEditProps extends CommonProps {\n defaultValue: string;\n onChange?: (value: string) => void;\n}\n\ninterface InlineEditState {\n value: string;\n originalValue: string;\n}\n\n/** Duration Inline Editor\n * @internal\n */\nexport class InlineEdit extends React.Component<\n InlineEditProps,\n InlineEditState\n> {\n private _inputRef = React.createRef<HTMLInputElement>();\n\n constructor(props: InlineEditProps) {\n super(props);\n\n this.state = {\n value: this.props.defaultValue,\n originalValue: this.props.defaultValue,\n };\n }\n\n public override componentDidUpdate(\n prevProps: InlineEditProps,\n _prevState: InlineEditState\n ) {\n if (prevProps.defaultValue !== this.props.defaultValue) {\n this.setState((_, props) => {\n return { value: props.defaultValue, originalValue: props.defaultValue };\n });\n }\n }\n\n private _onBlur = (event: React.ChangeEvent<HTMLInputElement>) => {\n this._sendChange(event.target.value);\n };\n\n private _onFocus = (event: React.ChangeEvent<HTMLInputElement>) => {\n event.target.select();\n };\n\n private _onKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n switch (event.key) {\n case Key.Escape.valueOf():\n this.setState(\n (prevState) => ({ value: prevState.originalValue }),\n () => this._inputRef.current!.select()\n );\n break;\n case Key.Enter.valueOf():\n this._sendChange(this.state.value);\n break;\n }\n };\n\n private _onChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n this.setState({ value: event.target.value });\n };\n\n private _sendChange(value: string) {\n if (this.props.onChange) this.props.onChange(value);\n }\n\n public override render() {\n return (\n <Input\n data-testid=\"timeline-duration-edit-input\"\n className={classnames(\"inline-edit-input\", this.props.className)}\n style={this.props.style}\n ref={this._inputRef}\n type=\"text\"\n value={this.state.value}\n size=\"small\"\n onFocus={this._onFocus}\n onBlur={this._onBlur}\n onKeyDown={this._onKeyDown}\n onChange={this._onChange}\n />\n );\n }\n}\n"]}
1
+ {"version":3,"file":"InlineEdit.js","sourceRoot":"","sources":["../../../src/imodel-components-react/timeline/InlineEdit.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,mBAAmB,CAAC;AAC3B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAa7C;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK,CAAC,SAGrC;IAGC,YAAY,KAAsB;QAChC,KAAK,CAAC,KAAK,CAAC,CAAC;QAHP,cAAS,GAAG,KAAK,CAAC,SAAS,EAAoB,CAAC;QAsBhD,YAAO,GAAG,CAAC,KAA0C,EAAE,EAAE;YAC/D,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvC,CAAC,CAAC;QAEM,aAAQ,GAAG,CAAC,KAA0C,EAAE,EAAE;YAChE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACxB,CAAC,CAAC;QAEM,eAAU,GAAG,CAAC,KAA4C,EAAE,EAAE;YACpE,QAAQ,KAAK,CAAC,GAAG,EAAE,CAAC;gBAClB,KAAK,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE;oBACvB,IAAI,CAAC,QAAQ,CACX,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,aAAa,EAAE,CAAC,EACnD,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,OAAQ,CAAC,MAAM,EAAE,CACvC,CAAC;oBACF,MAAM;gBACR,KAAK,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE;oBACtB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC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C,OAAO,EACpB,SAAS,EAAE,IAAI,CAAC,UAAU,EAC1B,QAAQ,EAAE,IAAI,CAAC,SAAS,GACxB,CACH,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\nimport \"./InlineEdit.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Input } from \"@itwin/itwinui-react\";\n\n// eslint-disable-next-line @typescript-eslint/no-deprecated\ninterface InlineEditProps extends CommonProps {\n defaultValue: string;\n onChange?: (value: string) => void;\n}\n\ninterface InlineEditState {\n value: string;\n originalValue: string;\n}\n\n/** Duration Inline Editor\n * @internal\n */\nexport class InlineEdit extends React.Component<\n InlineEditProps,\n InlineEditState\n> {\n private _inputRef = React.createRef<HTMLInputElement>();\n\n constructor(props: InlineEditProps) {\n super(props);\n\n this.state = {\n value: this.props.defaultValue,\n originalValue: this.props.defaultValue,\n };\n }\n\n public override componentDidUpdate(\n prevProps: InlineEditProps,\n _prevState: InlineEditState\n ) {\n if (prevProps.defaultValue !== this.props.defaultValue) {\n this.setState((_, props) => {\n return { value: props.defaultValue, originalValue: props.defaultValue };\n });\n }\n }\n\n private _onBlur = (event: React.ChangeEvent<HTMLInputElement>) => {\n this._sendChange(event.target.value);\n };\n\n private _onFocus = (event: React.ChangeEvent<HTMLInputElement>) => {\n event.target.select();\n };\n\n private _onKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n switch (event.key) {\n case Key.Escape.valueOf():\n this.setState(\n (prevState) => ({ value: prevState.originalValue }),\n () => this._inputRef.current!.select()\n );\n break;\n case Key.Enter.valueOf():\n this._sendChange(this.state.value);\n break;\n }\n };\n\n private _onChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n this.setState({ value: event.target.value });\n };\n\n private _sendChange(value: string) {\n if (this.props.onChange) this.props.onChange(value);\n }\n\n public override render() {\n return (\n <Input\n data-testid=\"timeline-duration-edit-input\"\n className={classnames(\"inline-edit-input\", this.props.className)}\n style={this.props.style}\n ref={this._inputRef}\n type=\"text\"\n value={this.state.value}\n size=\"small\"\n onFocus={this._onFocus}\n onBlur={this._onBlur}\n onKeyDown={this._onKeyDown}\n onChange={this._onChange}\n />\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Scrubber.js","sourceRoot":"","sources":["../../../src/imodel-components-react/timeline/Scrubber.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,iBAAiB,CAAC;AACzB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGrE,gBAAgB;AAChB,MAAM,UAAU,wBAAwB,CAAC,IAAa,EAAE,OAAe;IACrE,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IACpE,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;AAC7C,CAAC;AAED,MAAM,cAAc,GAAG,CAAC,KAAa,EAAE,EAAE;IACvC,MAAM,OAAO,GAAG,CAAC,CAAS,EAAE,EAAE;QAC5B,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC,CAAC;IAEF,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;IACrC,MAAM,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AC,QAAQ,IAAI,eAAe,IAAI,SAAS,IAAI,OAAO;YACvD,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC;YACnD,CAAC,CAAC,SAAS,CAAC;QAChB,MAAM,WAAW,GAAG,mBAAmB,CACrC,CAAC,CAAC,QAAQ,EACV,OAAO,EACP,CAAC,EACD,aAAa,EACb,SAAS,EACT,OAAO,EACP,cAAc,CACf,CAAC;QACF,OAAO,CACL,oBAAC,WAAW,IACV,WAAW,EAAE,OAAO,EACpB,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,iBAAiB,GAC3B,CACH,CAAC;IACJ,CAAC,EAAE;QACD,SAAS;QACT,eAAe;QACf,eAAe;QACf,aAAa;QACb,cAAc;QACd,SAAS;QACT,OAAO;QACP,cAAc;QACd,QAAQ;QACR,aAAa;QACb,KAAK,CAAC,QAAQ;KACf,CAAC,CAAC;IAEH,OAAO,CACL,oBAAC,MAAM,IACL,GAAG,EAAE,kBAAkB,EACvB,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,CAAC,EACP,GAAG,EAAE,CAAC,EACN,GAAG,EAAE,aAAa,EAClB,QAAQ,EAAC,EAAE,EACX,QAAQ,EAAC,EAAE,EACX,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,CAAC,eAAe,CAAC,EACzB,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;YACjB,QAAQ,EAAE,oBAAC,WAAW,OAAG;YACzB,SAAS,EAAE,2BAA2B;SACvC,CAAC,EACF,UAAU,EAAE,SAAS,EACrB,cAAc,EAAE,kBAAkB,EAClC,aAAa,EAAE,iBAAiB,EAChC,cAAc,EAAE,kBAAkB,EAClC,mBAAmB,EAAE,mBAAmB,GACxC,CACH,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\nimport \"./Scrubber.scss\";\nimport * as React from \"react\";\nimport { Slider } from \"@itwin/itwinui-react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { toDateString, toTimeString } from \"@itwin/components-react\";\nimport type { TimelineDateMarkerProps } from \"./TimelineComponent.js\";\n\n/** @internal */\nexport function getPercentageOfRectangle(rect: DOMRect, pointer: number) {\n const position = Math.min(rect.right, Math.max(rect.left, pointer));\n return (position - rect.left) / rect.width;\n}\n\nconst formatDuration = (value: number) => {\n const addZero = (i: number) => {\n return i < 10 ? `0${i}` : i;\n };\n\n const date = new Date(value);\n const minutes = date.getUTCMinutes();\n const seconds = date.getUTCSeconds();\n return `${addZero(minutes)}:${addZero(seconds)}`;\n};\n\nconst formatDate = (\n startDate: Date,\n endDate: Date,\n fraction: number,\n timeZoneOffset?: number\n) => {\n const delta = (endDate.getTime() - startDate.getTime()) * fraction;\n const date = new Date(startDate.getTime() + delta);\n return toDateString(date, timeZoneOffset);\n};\n\nconst formatTime = (\n startDate: Date,\n endDate: Date,\n fraction: number,\n timeZoneOffset?: number\n) => {\n const delta = (endDate.getTime() - startDate.getTime()) * fraction;\n const date = new Date(startDate.getTime() + delta);\n return ` ${toTimeString(date, timeZoneOffset)}`;\n};\n\nfunction generateToolTipText(\n showTime: boolean,\n percent: number,\n min: number,\n max: number,\n startDate?: Date,\n endDate?: Date,\n timeZoneOffset = 0\n) {\n if (startDate && endDate)\n return `${formatDate(startDate, endDate, percent, timeZoneOffset)}${\n showTime ? formatTime(startDate, endDate, percent, timeZoneOffset) : \"\"\n } `;\n\n const val = Math.round(min + (max - min) * percent);\n return formatDuration(val);\n}\n\nfunction getPercentageFromDate(startDate: Date, endDate: Date, date?: Date) {\n const newDate = date ? date : new Date();\n const startTime = startDate.getTime();\n const totalDuration = endDate.getTime() - startTime;\n return (newDate.getTime() - startTime) / totalDuration;\n}\n\nfunction getDateMarker(\n dateMarkerPropsIn: TimelineDateMarkerProps,\n startDate: Date,\n endDate: Date\n): DateMarkerProps {\n const percentage = getPercentageFromDate(\n startDate,\n endDate,\n dateMarkerPropsIn.date\n );\n const marker = dateMarkerPropsIn.dateMarker ? (\n dateMarkerPropsIn.dateMarker\n ) : (\n <span className=\"date-marker-default\"></span>\n );\n return { datePercentage: percentage, dateMarker: marker };\n}\n\nfunction markDateInTimelineRange(\n dateMarkerProps?: TimelineDateMarkerProps,\n startDate?: Date,\n endDate?: Date\n): boolean {\n if (dateMarkerProps && startDate && endDate) {\n const inDate = dateMarkerProps.date ? dateMarkerProps.date : new Date();\n if (\n inDate.getTime() >= startDate.getTime() &&\n inDate.getTime() <= endDate.getTime()\n )\n return true;\n }\n return false;\n}\n\n/** @internal */\nexport function RailMarkers({\n showToolTip,\n percent,\n tooltipText,\n markDate,\n}: {\n showToolTip: boolean;\n percent: number;\n tooltipText: string;\n markDate?: DateMarkerProps;\n}) {\n return (\n <div className=\"components-timeline-rail-marker-container\">\n {showToolTip && (\n <div\n className=\"components-timeline-tooltip\"\n style={{ left: `${Math.round(percent * 100)}% ` }}\n >\n <span className=\"tooltip-text\">{tooltipText}</span>\n </div>\n )}\n {markDate && (\n <div\n className=\"components-timeline-date-marker\"\n data-testid=\"test-date-marker\"\n style={{ left: `${Math.round(markDate.datePercentage * 100)}% ` }}\n >\n {markDate.dateMarker}\n </div>\n )}\n </div>\n );\n}\n\n/**\n * Custom Timeline Thumb\n * @internal\n */\nexport function CustomThumb() {\n return (\n <div className=\"scrubber-handle\">\n <div />\n <div />\n <div />\n </div>\n );\n}\n\n/**\n * @internal\n */\nexport function useFocusedThumb(sliderContainer: HTMLDivElement | undefined) {\n const [thumbElement, setThumbElement] = React.useState<HTMLDivElement>();\n\n React.useLayoutEffect(() => {\n if (!sliderContainer) return;\n const element = sliderContainer.querySelector(\".components-timeline-thumb\");\n if (!element) return;\n setThumbElement(element as HTMLDivElement);\n }, [sliderContainer, thumbElement]);\n\n const [thumbHasFocus, setThumbHasFocus] = React.useState(false);\n\n React.useEffect(() => {\n const listener = () => {\n setThumbHasFocus(true);\n };\n thumbElement?.addEventListener(\"focus\", listener);\n return () => {\n thumbElement?.removeEventListener(\"focus\", listener);\n };\n }, [thumbElement]);\n React.useEffect(() => {\n const listener = () => {\n setThumbHasFocus(false);\n };\n thumbElement?.addEventListener(\"blur\", listener);\n return () => {\n thumbElement?.removeEventListener(\"blur\", listener);\n };\n }, [thumbElement]);\n return thumbHasFocus;\n}\n\n/** Properties for Scrubber/Slider used on timeline control\n * @internal\n */\n// eslint-disable-next-line deprecation/deprecation\nexport interface ScrubberProps extends CommonProps {\n currentDuration: number;\n totalDuration: number;\n isPlaying: boolean;\n startDate?: Date;\n endDate?: Date;\n showTime?: boolean;\n onChange?: (values: ReadonlyArray<number>) => void;\n onUpdate?: (values: ReadonlyArray<number>) => void;\n timeZoneOffset?: number;\n markDate?: TimelineDateMarkerProps;\n trackContainerProps?: React.ComponentProps<\n typeof Slider\n >[\"trackContainerProps\"];\n}\n\n/** Properties for marking current date in RailMarkers\n * @internal\n */\ninterface DateMarkerProps {\n datePercentage: number;\n dateMarker?: React.ReactNode;\n}\n/** Scrubber/Slider for timeline control\n * @internal\n */\nexport function Scrubber(props: ScrubberProps) {\n const {\n startDate,\n endDate,\n showTime,\n isPlaying,\n totalDuration,\n timeZoneOffset,\n currentDuration,\n className,\n onChange,\n onUpdate,\n trackContainerProps,\n } = props;\n\n const [sliderContainer, setSliderContainer] =\n React.useState<HTMLDivElement | null>(null);\n const [pointerPercent, setPointerPercent] = React.useState(0);\n\n const tooltipProps = React.useCallback(() => {\n return { visible: false };\n }, []);\n\n const [showRailTooltip, setShowRailTooltip] = React.useState(false);\n\n const handlePointerEnter = React.useCallback(() => {\n setShowRailTooltip(true);\n }, []);\n\n const handlePointerLeave = React.useCallback(() => {\n setShowRailTooltip(false);\n }, []);\n\n const handlePointerMove = React.useCallback(\n (event: React.PointerEvent) => {\n sliderContainer &&\n setPointerPercent(\n getPercentageOfRectangle(\n sliderContainer.getBoundingClientRect(),\n event.clientX\n )\n );\n },\n [sliderContainer]\n );\n\n const thumbHasFocus = useFocusedThumb(sliderContainer ?? undefined);\n\n const tickLabel = React.useMemo(() => {\n const showTip = isPlaying || showRailTooltip || thumbHasFocus;\n const percent =\n isPlaying || thumbHasFocus\n ? currentDuration / totalDuration\n : pointerPercent;\n const markDateInRange = markDateInTimelineRange(\n props.markDate,\n startDate,\n endDate\n );\n const currentDateMarker =\n props.markDate && markDateInRange && startDate && endDate\n ? getDateMarker(props.markDate, startDate, endDate)\n : undefined;\n const tooltipText = generateToolTipText(\n !!showTime,\n percent,\n 0,\n totalDuration,\n startDate,\n endDate,\n timeZoneOffset\n );\n return (\n <RailMarkers\n showToolTip={showTip}\n percent={percent}\n tooltipText={tooltipText}\n markDate={currentDateMarker}\n />\n );\n }, [\n isPlaying,\n showRailTooltip,\n currentDuration,\n totalDuration,\n pointerPercent,\n startDate,\n endDate,\n timeZoneOffset,\n showTime,\n thumbHasFocus,\n props.markDate,\n ]);\n\n return (\n <Slider\n ref={setSliderContainer}\n className={className}\n step={1}\n min={0}\n max={totalDuration}\n minLabel=\"\"\n maxLabel=\"\"\n onUpdate={onUpdate}\n onChange={onChange}\n values={[currentDuration]}\n tooltipProps={tooltipProps}\n thumbProps={() => ({\n children: <CustomThumb />,\n className: \"components-timeline-thumb\",\n })}\n tickLabels={tickLabel}\n onPointerEnter={handlePointerEnter}\n onPointerMove={handlePointerMove}\n onPointerLeave={handlePointerLeave}\n trackContainerProps={trackContainerProps}\n />\n );\n}\n"]}
1
+ {"version":3,"file":"Scrubber.js","sourceRoot":"","sources":["../../../src/imodel-components-react/timeline/Scrubber.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,iBAAiB,CAAC;AACzB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,sBA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QACd,SAAS;QACT,OAAO;QACP,cAAc;QACd,QAAQ;QACR,aAAa;QACb,KAAK,CAAC,QAAQ;KACf,CAAC,CAAC;IAEH,OAAO,CACL,oBAAC,MAAM,IACL,GAAG,EAAE,kBAAkB,EACvB,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,CAAC,EACP,GAAG,EAAE,CAAC,EACN,GAAG,EAAE,aAAa,EAClB,QAAQ,EAAC,EAAE,EACX,QAAQ,EAAC,EAAE,EACX,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,CAAC,eAAe,CAAC,EACzB,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;YACjB,QAAQ,EAAE,oBAAC,WAAW,OAAG;YACzB,SAAS,EAAE,2BAA2B;SACvC,CAAC,EACF,UAAU,EAAE,SAAS,EACrB,cAAc,EAAE,kBAAkB,EAClC,aAAa,EAAE,iBAAiB,EAChC,cAAc,EAAE,kBAAkB,EAClC,mBAAmB,EAAE,mBAAmB,GACxC,CACH,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\nimport \"./Scrubber.scss\";\nimport * as React from \"react\";\nimport { Slider } from \"@itwin/itwinui-react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { toDateString, toTimeString } from \"@itwin/components-react\";\nimport type { TimelineDateMarkerProps } from \"./TimelineComponent.js\";\n\n/** @internal */\nexport function getPercentageOfRectangle(rect: DOMRect, pointer: number) {\n const position = Math.min(rect.right, Math.max(rect.left, pointer));\n return (position - rect.left) / rect.width;\n}\n\nconst formatDuration = (value: number) => {\n const addZero = (i: number) => {\n return i < 10 ? `0${i}` : i;\n };\n\n const date = new Date(value);\n const minutes = date.getUTCMinutes();\n const seconds = date.getUTCSeconds();\n return `${addZero(minutes)}:${addZero(seconds)}`;\n};\n\nconst formatDate = (\n startDate: Date,\n endDate: Date,\n fraction: number,\n timeZoneOffset?: number\n) => {\n const delta = (endDate.getTime() - startDate.getTime()) * fraction;\n const date = new Date(startDate.getTime() + delta);\n return toDateString(date, timeZoneOffset);\n};\n\nconst formatTime = (\n startDate: Date,\n endDate: Date,\n fraction: number,\n timeZoneOffset?: number\n) => {\n const delta = (endDate.getTime() - startDate.getTime()) * fraction;\n const date = new Date(startDate.getTime() + delta);\n return ` ${toTimeString(date, timeZoneOffset)}`;\n};\n\nfunction generateToolTipText(\n showTime: boolean,\n percent: number,\n min: number,\n max: number,\n startDate?: Date,\n endDate?: Date,\n timeZoneOffset = 0\n) {\n if (startDate && endDate)\n return `${formatDate(startDate, endDate, percent, timeZoneOffset)}${\n showTime ? formatTime(startDate, endDate, percent, timeZoneOffset) : \"\"\n } `;\n\n const val = Math.round(min + (max - min) * percent);\n return formatDuration(val);\n}\n\nfunction getPercentageFromDate(startDate: Date, endDate: Date, date?: Date) {\n const newDate = date ? date : new Date();\n const startTime = startDate.getTime();\n const totalDuration = endDate.getTime() - startTime;\n return (newDate.getTime() - startTime) / totalDuration;\n}\n\nfunction getDateMarker(\n dateMarkerPropsIn: TimelineDateMarkerProps,\n startDate: Date,\n endDate: Date\n): DateMarkerProps {\n const percentage = getPercentageFromDate(\n startDate,\n endDate,\n dateMarkerPropsIn.date\n );\n const marker = dateMarkerPropsIn.dateMarker ? (\n dateMarkerPropsIn.dateMarker\n ) : (\n <span className=\"date-marker-default\"></span>\n );\n return { datePercentage: percentage, dateMarker: marker };\n}\n\nfunction markDateInTimelineRange(\n dateMarkerProps?: TimelineDateMarkerProps,\n startDate?: Date,\n endDate?: Date\n): boolean {\n if (dateMarkerProps && startDate && endDate) {\n const inDate = dateMarkerProps.date ? dateMarkerProps.date : new Date();\n if (\n inDate.getTime() >= startDate.getTime() &&\n inDate.getTime() <= endDate.getTime()\n )\n return true;\n }\n return false;\n}\n\n/** @internal */\nexport function RailMarkers({\n showToolTip,\n percent,\n tooltipText,\n markDate,\n}: {\n showToolTip: boolean;\n percent: number;\n tooltipText: string;\n markDate?: DateMarkerProps;\n}) {\n return (\n <div className=\"components-timeline-rail-marker-container\">\n {showToolTip && (\n <div\n className=\"components-timeline-tooltip\"\n style={{ left: `${Math.round(percent * 100)}% ` }}\n >\n <span className=\"tooltip-text\">{tooltipText}</span>\n </div>\n )}\n {markDate && (\n <div\n className=\"components-timeline-date-marker\"\n data-testid=\"test-date-marker\"\n style={{ left: `${Math.round(markDate.datePercentage * 100)}% ` }}\n >\n {markDate.dateMarker}\n </div>\n )}\n </div>\n );\n}\n\n/**\n * Custom Timeline Thumb\n * @internal\n */\nexport function CustomThumb() {\n return (\n <div className=\"scrubber-handle\">\n <div />\n <div />\n <div />\n </div>\n );\n}\n\n/**\n * @internal\n */\nexport function useFocusedThumb(sliderContainer: HTMLDivElement | undefined) {\n const [thumbElement, setThumbElement] = React.useState<HTMLDivElement>();\n\n React.useLayoutEffect(() => {\n if (!sliderContainer) return;\n const element = sliderContainer.querySelector(\".components-timeline-thumb\");\n if (!element) return;\n setThumbElement(element as HTMLDivElement);\n }, [sliderContainer, thumbElement]);\n\n const [thumbHasFocus, setThumbHasFocus] = React.useState(false);\n\n React.useEffect(() => {\n const listener = () => {\n setThumbHasFocus(true);\n };\n thumbElement?.addEventListener(\"focus\", listener);\n return () => {\n thumbElement?.removeEventListener(\"focus\", listener);\n };\n }, [thumbElement]);\n React.useEffect(() => {\n const listener = () => {\n setThumbHasFocus(false);\n };\n thumbElement?.addEventListener(\"blur\", listener);\n return () => {\n thumbElement?.removeEventListener(\"blur\", listener);\n };\n }, [thumbElement]);\n return thumbHasFocus;\n}\n\n/** Properties for Scrubber/Slider used on timeline control\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface ScrubberProps extends CommonProps {\n currentDuration: number;\n totalDuration: number;\n isPlaying: boolean;\n startDate?: Date;\n endDate?: Date;\n showTime?: boolean;\n onChange?: (values: ReadonlyArray<number>) => void;\n onUpdate?: (values: ReadonlyArray<number>) => void;\n timeZoneOffset?: number;\n markDate?: TimelineDateMarkerProps;\n trackContainerProps?: React.ComponentProps<\n typeof Slider\n >[\"trackContainerProps\"];\n}\n\n/** Properties for marking current date in RailMarkers\n * @internal\n */\ninterface DateMarkerProps {\n datePercentage: number;\n dateMarker?: React.ReactNode;\n}\n/** Scrubber/Slider for timeline control\n * @internal\n */\nexport function Scrubber(props: ScrubberProps) {\n const {\n startDate,\n endDate,\n showTime,\n isPlaying,\n totalDuration,\n timeZoneOffset,\n currentDuration,\n className,\n onChange,\n onUpdate,\n trackContainerProps,\n } = props;\n\n const [sliderContainer, setSliderContainer] =\n React.useState<HTMLDivElement | null>(null);\n const [pointerPercent, setPointerPercent] = React.useState(0);\n\n const tooltipProps = React.useCallback(() => {\n return { visible: false };\n }, []);\n\n const [showRailTooltip, setShowRailTooltip] = React.useState(false);\n\n const handlePointerEnter = React.useCallback(() => {\n setShowRailTooltip(true);\n }, []);\n\n const handlePointerLeave = React.useCallback(() => {\n setShowRailTooltip(false);\n }, []);\n\n const handlePointerMove = React.useCallback(\n (event: React.PointerEvent) => {\n sliderContainer &&\n setPointerPercent(\n getPercentageOfRectangle(\n sliderContainer.getBoundingClientRect(),\n event.clientX\n )\n );\n },\n [sliderContainer]\n );\n\n const thumbHasFocus = useFocusedThumb(sliderContainer ?? undefined);\n\n const tickLabel = React.useMemo(() => {\n const showTip = isPlaying || showRailTooltip || thumbHasFocus;\n const percent =\n isPlaying || thumbHasFocus\n ? currentDuration / totalDuration\n : pointerPercent;\n const markDateInRange = markDateInTimelineRange(\n props.markDate,\n startDate,\n endDate\n );\n const currentDateMarker =\n props.markDate && markDateInRange && startDate && endDate\n ? getDateMarker(props.markDate, startDate, endDate)\n : undefined;\n const tooltipText = generateToolTipText(\n !!showTime,\n percent,\n 0,\n totalDuration,\n startDate,\n endDate,\n timeZoneOffset\n );\n return (\n <RailMarkers\n showToolTip={showTip}\n percent={percent}\n tooltipText={tooltipText}\n markDate={currentDateMarker}\n />\n );\n }, [\n isPlaying,\n showRailTooltip,\n currentDuration,\n totalDuration,\n pointerPercent,\n startDate,\n endDate,\n timeZoneOffset,\n showTime,\n thumbHasFocus,\n props.markDate,\n ]);\n\n return (\n <Slider\n ref={setSliderContainer}\n className={className}\n step={1}\n min={0}\n max={totalDuration}\n minLabel=\"\"\n maxLabel=\"\"\n onUpdate={onUpdate}\n onChange={onChange}\n values={[currentDuration]}\n tooltipProps={tooltipProps}\n thumbProps={() => ({\n children: <CustomThumb />,\n className: \"components-timeline-thumb\",\n })}\n tickLabels={tickLabel}\n onPointerEnter={handlePointerEnter}\n onPointerMove={handlePointerMove}\n onPointerLeave={handlePointerLeave}\n trackContainerProps={trackContainerProps}\n />\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SolarTimeline.js","sourceRoot":"","sources":["../../../src/imodel-components-react/timeline/SolarTimeline.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,sBAAsB,CAAC;AAC9B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EACL,MAAM,EACN,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,WAAW,EACX,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,UAAU,EACV,KAAK,EACL,OAAO,EACP,MAAM,EACN,MAAM,EACN,IAAI,EACJ,OAAO,EACP,cAAc,GACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,WAAW,EACX,OAAO,EACP,OAAO,EACP,WAAW,EACX,MAAM,GACP,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,kBAAkB,EAA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AAW,OAAG,CACJ,CACL,CACL,CACH,CACP,CAAC;IACJ,CAAC;CACF;AAOD,MAAM,cAAc,GAAG,KAAK,CAAC,UAAU,CACrC,SAAS,cAAc,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,GAAG;IAChD,MAAM,EAAE,SAAS,EAAE,GAAG,cAAc,EAAE,CAAC;IACvC,MAAM,OAAO,GAAG,SAAS,CAAC,wBAAwB,CAAC,CAAC;IAEpD,OAAO,CACL,oBAAC,OAAO,IAAC,OAAO,EAAE,OAAO;QACvB,oBAAC,MAAM,IACL,SAAS,EAAC,YAAY,EACtB,SAAS,EAAE,oBAAC,WAAW,OAAG,iBACd,wBAAwB,EACpC,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,GAAG;YAER,8BAAM,SAAS,EAAC,0BAA0B,IAAE,QAAQ,CAAQ,CACrD,CACD,CACX,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Timeline\n */\n\nimport \"./SolarTimeline.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { ColorByName, ColorDef } from \"@itwin/core-common\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { adjustDateToTimezone, UiComponents } from \"@itwin/components-react\";\nimport {\n Button,\n ColorBuilder,\n ColorInputPanel,\n ColorPalette,\n ColorPicker,\n DatePicker,\n Flex,\n Icon,\n IconButton,\n Label,\n Popover,\n Select,\n Slider,\n Text,\n Tooltip,\n VisuallyHidden,\n} from \"@itwin/itwinui-react\";\nimport {\n SvgCalendar,\n SvgLoop,\n SvgMoon,\n SvgSettings,\n SvgSun,\n} from \"@itwin/itwinui-icons-react\";\nimport type { SolarDataProvider } from \"./interfaces.js\";\nimport { UiIModelComponents } from \"../UiIModelComponents.js\";\nimport { PlayButton } from \"./PlayButton.js\";\nimport { useTranslation } from \"../useTranslation.js\";\n\nconst msPerMinute = 1000 * 60;\nconst msPerHour = msPerMinute * 60;\nconst defaultPlaybackDuration = 40 * 1000;\n\nconst offset = 6;\n\n// eslint-disable-next-line deprecation/deprecation\ninterface TimelineProps extends CommonProps {\n dayStartMs: number;\n sunRiseOffsetMs: number;\n sunSetOffsetMs: number;\n currentTimeOffsetMs: number;\n isPlaying: boolean;\n formatTick?: (ms: number) => string;\n formatTime: (ms: number) => string;\n onChange?: (values: ReadonlyArray<number>) => void;\n onUpdate?: (values: ReadonlyArray<number>) => void;\n}\n\nfunction Timeline(props: TimelineProps) {\n const {\n formatTick,\n formatTime,\n onChange,\n onUpdate,\n dayStartMs,\n sunSetOffsetMs,\n sunRiseOffsetMs,\n currentTimeOffsetMs,\n } = props;\n\n const tooltipContent = formatTime(dayStartMs + currentTimeOffsetMs);\n\n const className = classnames(\n \"solar-timeline\",\n props.className,\n formatTick && \"showticks\"\n );\n const sunRiseStr = formatTime(dayStartMs + sunRiseOffsetMs);\n const sunSetStr = formatTime(dayStartMs + sunSetOffsetMs);\n return (\n <div className={className}>\n <VisuallyHidden>Solar timeline</VisuallyHidden>\n <Slider\n thumbProps={() => ({ \"aria-labelledby\": \"timeline\" })}\n step={msPerMinute}\n min={sunRiseOffsetMs}\n max={sunSetOffsetMs}\n minLabel={\n <Tooltip content={sunRiseStr}>\n <Icon>\n <SvgSun />\n </Icon>\n </Tooltip>\n }\n maxLabel={\n <Tooltip content={sunSetStr}>\n <Icon>\n <SvgMoon />\n </Icon>\n </Tooltip>\n }\n onUpdate={onUpdate}\n onChange={onChange}\n values={[currentTimeOffsetMs]}\n tooltipProps={() => ({\n content: tooltipContent,\n })}\n />\n </div>\n );\n}\n\ninterface SolarTimelineComponentProps {\n dataProvider: SolarDataProvider; // provides date, sunrise, sunset in ms, also contains timezone offset from UTC, and updates the display style to current time.\n onPlayPause?: (playing: boolean) => void; // callback triggered when play/pause button is pressed\n duration?: number; // playback duration in milliseconds\n speed?: number;\n}\n\ninterface SolarTimelineComponentState {\n isPlaying: boolean; // timeline is currently playing or paused\n isDateOpened: boolean; // date picker is opened\n isSettingsOpened: boolean; // settings popup is opened\n dayStartMs: number;\n sunRiseOffsetMs: number;\n sunSetOffsetMs: number;\n sunDeltaMs: number;\n currentTimeOffsetMs: number;\n speed: number;\n loop: boolean;\n shadowColor: ColorDef;\n duration: number; // playback duration in milliseconds\n adjustedDuration: number; // playback duration in milliseconds/ speed\n}\n\n/** Solar Timeline\n * @alpha\n */\nexport class SolarTimeline extends React.PureComponent<\n SolarTimelineComponentProps,\n SolarTimelineComponentState\n> {\n private _requestFrame = 0;\n private _unmounted = false;\n private _timeLastCycle = 0;\n private _totalPlayTime = 0;\n\n private readonly _presetColors = [\n ColorDef.create(ColorByName.grey),\n ColorDef.create(ColorByName.lightGrey),\n ColorDef.create(ColorByName.darkGrey),\n ColorDef.create(ColorByName.lightBlue),\n ColorDef.create(ColorByName.lightGreen),\n ColorDef.create(ColorByName.darkGreen),\n ColorDef.create(ColorByName.tan),\n ColorDef.create(ColorByName.darkBrown),\n ];\n\n private readonly _speeds = [1, 2, 3, 4, 5, 6];\n\n constructor(props: SolarTimelineComponentProps) {\n super(props);\n\n const dayStartMs = this.props.dataProvider.dayStartMs;\n const sunRiseOffsetMs =\n this.props.dataProvider.sunrise.getTime() - dayStartMs;\n const sunSetOffsetMs =\n this.props.dataProvider.sunset.getTime() - dayStartMs;\n const sunDeltaMs = sunSetOffsetMs - sunRiseOffsetMs;\n const sunOffsetMs =\n this.props.dataProvider.timeOfDay.getTime() - dayStartMs;\n const currentTimeOffsetMs = this.ensureRange(\n sunOffsetMs,\n sunRiseOffsetMs,\n sunSetOffsetMs\n );\n const shadowColor = this.props.dataProvider.shadowColor;\n const duration = this.props.duration\n ? this.props.duration\n : defaultPlaybackDuration;\n const speed = this.props.speed ? this.props.speed : 2;\n const adjustedDuration = duration / speed;\n this.setPlaybackTimeBySunTime(\n currentTimeOffsetMs,\n sunRiseOffsetMs,\n sunDeltaMs,\n adjustedDuration\n );\n\n this.state = {\n isDateOpened: false,\n isSettingsOpened: false,\n isPlaying: false,\n dayStartMs,\n sunRiseOffsetMs,\n sunSetOffsetMs,\n sunDeltaMs,\n currentTimeOffsetMs,\n speed,\n loop: false,\n shadowColor,\n duration,\n adjustedDuration,\n };\n }\n\n public override componentWillUnmount() {\n window.cancelAnimationFrame(this._requestFrame);\n this._unmounted = true;\n }\n\n // recursively update the animation until we hit the end or the pause button is clicked\n private _updateAnimation = (_timestamp: number) => {\n if (!this.state.isPlaying || this._unmounted) {\n window.cancelAnimationFrame(this._requestFrame);\n return;\n }\n\n const currentTime = new Date().getTime();\n this._totalPlayTime += currentTime - this._timeLastCycle;\n this._timeLastCycle = currentTime;\n let percentComplete = this._totalPlayTime / this.state.adjustedDuration;\n if (percentComplete > 1) percentComplete = 1;\n\n let newPlayingState = true;\n\n // calculate the next sun time base on the percentage playback complete - should be int value as that is step amount for slider\n let nextSunOffset = Math.floor(\n this.state.sunRiseOffsetMs + percentComplete * this.state.sunDeltaMs\n );\n\n if (percentComplete > 0.99) {\n if (!this.state.loop) {\n newPlayingState = false;\n nextSunOffset = this.state.sunSetOffsetMs;\n window.cancelAnimationFrame(this._requestFrame);\n } else {\n nextSunOffset = this.state.sunRiseOffsetMs;\n this._totalPlayTime = 0;\n }\n }\n\n if (this.props.dataProvider.onTimeChanged) {\n const currentSunTime = new Date(this.state.dayStartMs + nextSunOffset);\n this.props.dataProvider.onTimeChanged(currentSunTime);\n }\n\n this.setState(\n { isPlaying: newPlayingState, currentTimeOffsetMs: nextSunOffset },\n () => {\n if (newPlayingState)\n this._requestFrame = window.requestAnimationFrame(\n this._updateAnimation\n );\n }\n );\n };\n\n private _play(sunTimeMs: number) {\n this._timeLastCycle = new Date().getTime();\n\n // start playing\n this.setState({ isPlaying: true, currentTimeOffsetMs: sunTimeMs }, () => {\n this._requestFrame = window.requestAnimationFrame(this._updateAnimation);\n if (this.props.onPlayPause) this.props.onPlayPause(true);\n });\n }\n\n // user clicked pause button\n private _onPause = () => {\n if (!this.state.isPlaying) return;\n\n const currentTime = new Date().getTime();\n this._totalPlayTime += currentTime - this._timeLastCycle;\n\n // stop requesting frames\n window.cancelAnimationFrame(this._requestFrame);\n\n // stop playing\n this.setState({ isPlaying: false });\n\n if (this.props.onPlayPause) this.props.onPlayPause(false);\n };\n\n // user clicked play button\n private _onPlay = () => {\n if (this.state.isPlaying) return;\n\n if (\n this.state.currentTimeOffsetMs >= this.state.sunSetOffsetMs ||\n this.state.currentTimeOffsetMs <= this.state.sunRiseOffsetMs\n ) {\n this._totalPlayTime = 0;\n this._play(this.state.sunRiseOffsetMs);\n } else {\n this._play(this.state.currentTimeOffsetMs);\n }\n };\n\n private setPlaybackTimeBySunTime(\n sunOffsetMs: number,\n sunRiseOffsetMs: number,\n sunDeltaMs: number,\n adjustedDuration?: number\n ) {\n this._totalPlayTime =\n ((sunOffsetMs - sunRiseOffsetMs) / sunDeltaMs) *\n (adjustedDuration ? adjustedDuration : this.state.adjustedDuration);\n }\n\n private _onDateChange = (newDate: Date) => {\n this.props.dataProvider.setDateAndTime(newDate);\n\n const dayStartMs = this.props.dataProvider.dayStartMs;\n const sunRiseOffsetMs =\n this.props.dataProvider.sunrise.getTime() - dayStartMs;\n const sunSetOffsetMs =\n this.props.dataProvider.sunset.getTime() - dayStartMs;\n const sunDeltaMs = sunSetOffsetMs - sunRiseOffsetMs;\n\n /** call dataProvider to update display style */\n // this.props.dataProvider.onTimeChanged?.(this.props.dataProvider.timeOfDay);\n\n // Update time\n const newHours = newDate.getHours();\n const newMinutes = newDate.getMinutes();\n const newSunTime = newHours * msPerHour + newMinutes * msPerMinute;\n const dateWithNewTime = new Date(dayStartMs + newSunTime);\n // this.props.dataProvider.setDateAndTime(dateWithNewTime, true);\n\n const currentTimeOffsetMs = this.ensureRange(\n newSunTime,\n sunRiseOffsetMs,\n sunSetOffsetMs\n );\n this.setPlaybackTimeBySunTime(\n currentTimeOffsetMs,\n sunRiseOffsetMs,\n sunDeltaMs\n );\n this._timeLastCycle = new Date().getTime();\n\n this.props.dataProvider.onTimeChanged?.(dateWithNewTime);\n this.setState({\n dayStartMs,\n sunRiseOffsetMs,\n sunSetOffsetMs,\n currentTimeOffsetMs,\n sunDeltaMs,\n isDateOpened: false,\n });\n };\n\n private _onCloseSettingsPopup = () => {\n this.setState({ isSettingsOpened: false });\n };\n\n private _onOpenSettingsPopup = () => {\n this.setState((prevState) => ({\n isSettingsOpened: !prevState.isSettingsOpened,\n }));\n };\n\n private ensureRange(value: number, min: number, max: number): number {\n return Math.max(Math.min(value, max), min);\n }\n\n private processSunTimeChange(sunTime: number) {\n if (sunTime === this.state.currentTimeOffsetMs) return;\n\n const currentTimeOffsetMs = this.ensureRange(\n sunTime,\n this.state.sunRiseOffsetMs,\n this.state.sunSetOffsetMs\n );\n\n if (this.props.dataProvider.onTimeChanged) {\n const currentSunTime = new Date(\n this.state.dayStartMs + currentTimeOffsetMs\n );\n this.props.dataProvider.onTimeChanged(currentSunTime);\n }\n\n this.setState({ currentTimeOffsetMs }, () => {\n const currentTime = new Date().getTime();\n this._timeLastCycle = currentTime;\n const percentComplete =\n (currentTimeOffsetMs - this.state.sunRiseOffsetMs) /\n this.state.sunDeltaMs;\n this._totalPlayTime = percentComplete * this.state.adjustedDuration;\n });\n }\n\n private _onUpdate = (values: ReadonlyArray<number>) => {\n if (!this.state.isPlaying) this.processSunTimeChange(values[0]);\n };\n\n private _onChange = (values: ReadonlyArray<number>) => {\n if (!this.state.isPlaying) this.processSunTimeChange(values[0]);\n };\n\n private _onSpeedChange = (value: number) => {\n const adjustedDuration = this.state.duration / value;\n this.setState({ speed: value, adjustedDuration });\n };\n\n private _onToggleLoop = () => {\n this.setState((prevState) => ({ loop: !prevState.loop }));\n };\n\n private _formatTime = (ms: number) => {\n const date = new Date(ms);\n const amLabel = UiComponents.translate(\"time.am\");\n const pmLabel = UiComponents.translate(\"time.pm\");\n // convert project date to browser locale date\n const localTime = adjustDateToTimezone(\n date,\n this.props.dataProvider.timeZoneOffset * 60\n );\n let hours = localTime.getHours();\n const minutes = date.getMinutes();\n const abbrev = hours < 12 ? amLabel : hours === 24 ? amLabel : pmLabel;\n hours = hours > 12 ? hours - 12 : hours;\n const hoursStr = hours.toLocaleString(undefined, {\n minimumIntegerDigits: 2,\n });\n const minutesStr = minutes.toLocaleString(undefined, {\n minimumIntegerDigits: 2,\n });\n return `${hoursStr}:${minutesStr} ${abbrev}`;\n };\n\n public getLocalTime(ticks: number): Date {\n const projectTime = new Date(ticks);\n // convert project date to browser locale date\n return adjustDateToTimezone(\n projectTime,\n this.props.dataProvider.timeZoneOffset * 60\n );\n }\n\n public override render() {\n const { dataProvider } = this.props;\n const {\n speed: currentSpeed,\n loop,\n currentTimeOffsetMs,\n sunRiseOffsetMs,\n sunSetOffsetMs,\n } = this.state;\n const months = [\n UiComponents.translate(\"month.short.january\"),\n UiComponents.translate(\"month.short.february\"),\n UiComponents.translate(\"month.short.march\"),\n UiComponents.translate(\"month.short.april\"),\n UiComponents.translate(\"month.short.may\"),\n UiComponents.translate(\"month.short.june\"),\n UiComponents.translate(\"month.short.july\"),\n UiComponents.translate(\"month.short.august\"),\n UiComponents.translate(\"month.short.september\"),\n UiComponents.translate(\"month.short.october\"),\n UiComponents.translate(\"month.short.november\"),\n UiComponents.translate(\"month.short.december\"),\n ];\n\n const localTime = this.getLocalTime(\n this.state.dayStartMs + this.state.currentTimeOffsetMs\n );\n const formattedTime = this._formatTime(\n dataProvider.dayStartMs + currentTimeOffsetMs\n );\n const formattedDate = `${\n months[localTime.getMonth()]\n }, ${localTime.getDate()}`;\n\n return (\n <div className=\"solar-timeline-wrapper\">\n <Flex flexWrap=\"wrap\" gap=\"none\" className=\"solar-timeline-start\">\n <PlayButton\n isPlaying={this.state.isPlaying}\n onPlay={this._onPlay}\n onPause={this._onPause}\n />\n <Popover\n content={\n <DatePicker\n date={localTime}\n onChange={this._onDateChange}\n showTime\n use12Hours\n />\n }\n visible={this.state.isDateOpened}\n onVisibleChange={(isDateOpened) => {\n this.setState({ isDateOpened });\n }}\n placement=\"top\"\n middleware={{\n offset,\n }}\n >\n <CalendarButton\n onClick={() => {\n const isDateOpened = !this.state.isDateOpened;\n this.setState({ isDateOpened });\n }}\n >\n {formattedDate} @ {formattedTime}\n </CalendarButton>\n </Popover>\n </Flex>\n\n <Timeline\n dayStartMs={dataProvider.dayStartMs}\n sunSetOffsetMs={sunSetOffsetMs}\n sunRiseOffsetMs={sunRiseOffsetMs}\n currentTimeOffsetMs={currentTimeOffsetMs}\n onChange={this._onChange}\n onUpdate={this._onUpdate}\n formatTime={this._formatTime}\n isPlaying={this.state.isPlaying}\n />\n\n <Flex\n justifyContent=\"flex-end\"\n flexWrap=\"wrap\"\n gap=\"none\"\n className=\"solar-timeline-end\"\n >\n <VisuallyHidden>\n <Label htmlFor=\"speed\">Timeline speed</Label>\n </VisuallyHidden>\n <Tooltip\n content={UiIModelComponents.translate(\"solartimeline.speed\")}\n >\n <Select\n native\n styleType=\"borderless\"\n triggerProps={{\n name: \"speed\",\n }}\n onChange={(newValue) => this._onSpeedChange(Number(newValue))}\n value={currentSpeed.toString()}\n options={this._speeds.map((speed) => ({\n value: speed.toString(),\n label: `${speed}x`,\n }))}\n />\n </Tooltip>\n\n <IconButton\n styleType=\"borderless\"\n label={UiIModelComponents.translate(\"timeline.repeat\")}\n onClick={this._onToggleLoop}\n isActive={loop}\n >\n <SvgLoop />\n </IconButton>\n\n <Popover\n content={\n <ColorPicker\n selectedColor={this.state.shadowColor.colors}\n onChangeComplete={(color) => {\n const colorDef = ColorDef.create(color.toTbgr());\n this.setState(\n { shadowColor: colorDef },\n () => (this.props.dataProvider.shadowColor = colorDef)\n );\n }}\n >\n <Text variant=\"title\" as=\"h2\" style={{ textAlign: \"center\" }}>\n {UiIModelComponents.translate(\"solarsettings.shadowcolor\")}\n </Text>\n <ColorBuilder />\n <ColorInputPanel defaultColorFormat=\"hsl\" />\n <ColorPalette\n colors={this._presetColors.map((color) => color.colors)}\n />\n </ColorPicker>\n }\n placement=\"top\"\n middleware={{\n offset,\n }}\n >\n <IconButton\n styleType=\"borderless\"\n data-testid=\"shadow-settings-button\"\n label={UiIModelComponents.translate(\"timeline.settings\")}\n onClick={this._onOpenSettingsPopup}\n >\n <SvgSettings />\n </IconButton>\n </Popover>\n </Flex>\n </div>\n );\n }\n}\n\ninterface CalendarButtonProps {\n children?: React.ReactNode;\n onClick?: () => void;\n}\n\nconst CalendarButton = React.forwardRef<HTMLButtonElement, CalendarButtonProps>(\n function CalendarButton({ children, onClick }, ref) {\n const { translate } = useTranslation();\n const tooltip = translate(\"solartimeline.dateTime\");\n\n return (\n <Tooltip content={tooltip}>\n <Button\n styleType=\"borderless\"\n startIcon={<SvgCalendar />}\n data-testid=\"solar-date-time-button\"\n title={tooltip}\n onClick={onClick}\n ref={ref}\n >\n <span className=\"solar-timeline-date-time\">{children}</span>\n </Button>\n </Tooltip>\n );\n }\n);\n"]}
1
+ {"version":3,"file":"SolarTimeline.js","sourceRoot":"","sources":["../../../src/imodel-components-react/timeline/SolarTimeline.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,sBAAsB,CAAC;AAC9B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EACL,MAAM,EACN,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,WAAW,EACX,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,UAAU,EACV,KAAK,EACL,OAAO,EACP,MAAM,EACN,MAAM,EACN,IAAI,EACJ,OAAO,EACP,cAAc,GACf,MAAM,sBAAsB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AY,iBACV,wBAAwB,EACpC,KAAK,EAAE,kBAAkB,CAAC,SAAS,CAAC,mBAAmB,CAAC,EACxD,OAAO,EAAE,IAAI,CAAC,oBAAoB;wBAElC,oBAAC,WAAW,OAAG,CACJ,CACL,CACL,CACH,CACP,CAAC;IACJ,CAAC;CACF;AAOD,MAAM,cAAc,GAAG,KAAK,CAAC,UAAU,CACrC,SAAS,cAAc,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,GAAG;IAChD,MAAM,EAAE,SAAS,EAAE,GAAG,cAAc,EAAE,CAAC;IACvC,MAAM,OAAO,GAAG,SAAS,CAAC,wBAAwB,CAAC,CAAC;IAEpD,OAAO,CACL,oBAAC,OAAO,IAAC,OAAO,EAAE,OAAO;QACvB,oBAAC,MAAM,IACL,SAAS,EAAC,YAAY,EACtB,SAAS,EAAE,oBAAC,WAAW,OAAG,iBACd,wBAAwB,EACpC,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,GAAG;YAER,8BAAM,SAAS,EAAC,0BAA0B,IAAE,QAAQ,CAAQ,CACrD,CACD,CACX,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Timeline\n */\n\nimport \"./SolarTimeline.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { ColorByName, ColorDef } from \"@itwin/core-common\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { adjustDateToTimezone, UiComponents } from \"@itwin/components-react\";\nimport {\n Button,\n ColorBuilder,\n ColorInputPanel,\n ColorPalette,\n ColorPicker,\n DatePicker,\n Flex,\n Icon,\n IconButton,\n Label,\n Popover,\n Select,\n Slider,\n Text,\n Tooltip,\n VisuallyHidden,\n} from \"@itwin/itwinui-react\";\nimport {\n SvgCalendar,\n SvgLoop,\n SvgMoon,\n SvgSettings,\n SvgSun,\n} from \"@itwin/itwinui-icons-react\";\nimport type { SolarDataProvider } from \"./interfaces.js\";\nimport { UiIModelComponents } from \"../UiIModelComponents.js\";\nimport { PlayButton } from \"./PlayButton.js\";\nimport { useTranslation } from \"../useTranslation.js\";\n\nconst msPerMinute = 1000 * 60;\nconst msPerHour = msPerMinute * 60;\nconst defaultPlaybackDuration = 40 * 1000;\n\nconst offset = 6;\n\n// eslint-disable-next-line @typescript-eslint/no-deprecated\ninterface TimelineProps extends CommonProps {\n dayStartMs: number;\n sunRiseOffsetMs: number;\n sunSetOffsetMs: number;\n currentTimeOffsetMs: number;\n isPlaying: boolean;\n formatTick?: (ms: number) => string;\n formatTime: (ms: number) => string;\n onChange?: (values: ReadonlyArray<number>) => void;\n onUpdate?: (values: ReadonlyArray<number>) => void;\n}\n\nfunction Timeline(props: TimelineProps) {\n const {\n formatTick,\n formatTime,\n onChange,\n onUpdate,\n dayStartMs,\n sunSetOffsetMs,\n sunRiseOffsetMs,\n currentTimeOffsetMs,\n } = props;\n\n const tooltipContent = formatTime(dayStartMs + currentTimeOffsetMs);\n\n const className = classnames(\n \"solar-timeline\",\n props.className,\n formatTick && \"showticks\"\n );\n const sunRiseStr = formatTime(dayStartMs + sunRiseOffsetMs);\n const sunSetStr = formatTime(dayStartMs + sunSetOffsetMs);\n return (\n <div className={className}>\n <VisuallyHidden>Solar timeline</VisuallyHidden>\n <Slider\n thumbProps={() => ({ \"aria-labelledby\": \"timeline\" })}\n step={msPerMinute}\n min={sunRiseOffsetMs}\n max={sunSetOffsetMs}\n minLabel={\n <Tooltip content={sunRiseStr}>\n <Icon>\n <SvgSun />\n </Icon>\n </Tooltip>\n }\n maxLabel={\n <Tooltip content={sunSetStr}>\n <Icon>\n <SvgMoon />\n </Icon>\n </Tooltip>\n }\n onUpdate={onUpdate}\n onChange={onChange}\n values={[currentTimeOffsetMs]}\n tooltipProps={() => ({\n content: tooltipContent,\n })}\n />\n </div>\n );\n}\n\ninterface SolarTimelineComponentProps {\n dataProvider: SolarDataProvider; // provides date, sunrise, sunset in ms, also contains timezone offset from UTC, and updates the display style to current time.\n onPlayPause?: (playing: boolean) => void; // callback triggered when play/pause button is pressed\n duration?: number; // playback duration in milliseconds\n speed?: number;\n}\n\ninterface SolarTimelineComponentState {\n isPlaying: boolean; // timeline is currently playing or paused\n isDateOpened: boolean; // date picker is opened\n isSettingsOpened: boolean; // settings popup is opened\n dayStartMs: number;\n sunRiseOffsetMs: number;\n sunSetOffsetMs: number;\n sunDeltaMs: number;\n currentTimeOffsetMs: number;\n speed: number;\n loop: boolean;\n shadowColor: ColorDef;\n duration: number; // playback duration in milliseconds\n adjustedDuration: number; // playback duration in milliseconds/ speed\n}\n\n/** Solar Timeline\n * @alpha\n */\nexport class SolarTimeline extends React.PureComponent<\n SolarTimelineComponentProps,\n SolarTimelineComponentState\n> {\n private _requestFrame = 0;\n private _unmounted = false;\n private _timeLastCycle = 0;\n private _totalPlayTime = 0;\n\n private readonly _presetColors = [\n ColorDef.create(ColorByName.grey),\n ColorDef.create(ColorByName.lightGrey),\n ColorDef.create(ColorByName.darkGrey),\n ColorDef.create(ColorByName.lightBlue),\n ColorDef.create(ColorByName.lightGreen),\n ColorDef.create(ColorByName.darkGreen),\n ColorDef.create(ColorByName.tan),\n ColorDef.create(ColorByName.darkBrown),\n ];\n\n private readonly _speeds = [1, 2, 3, 4, 5, 6];\n\n constructor(props: SolarTimelineComponentProps) {\n super(props);\n\n const dayStartMs = this.props.dataProvider.dayStartMs;\n const sunRiseOffsetMs =\n this.props.dataProvider.sunrise.getTime() - dayStartMs;\n const sunSetOffsetMs =\n this.props.dataProvider.sunset.getTime() - dayStartMs;\n const sunDeltaMs = sunSetOffsetMs - sunRiseOffsetMs;\n const sunOffsetMs =\n this.props.dataProvider.timeOfDay.getTime() - dayStartMs;\n const currentTimeOffsetMs = this.ensureRange(\n sunOffsetMs,\n sunRiseOffsetMs,\n sunSetOffsetMs\n );\n const shadowColor = this.props.dataProvider.shadowColor;\n const duration = this.props.duration\n ? this.props.duration\n : defaultPlaybackDuration;\n const speed = this.props.speed ? this.props.speed : 2;\n const adjustedDuration = duration / speed;\n this.setPlaybackTimeBySunTime(\n currentTimeOffsetMs,\n sunRiseOffsetMs,\n sunDeltaMs,\n adjustedDuration\n );\n\n this.state = {\n isDateOpened: false,\n isSettingsOpened: false,\n isPlaying: false,\n dayStartMs,\n sunRiseOffsetMs,\n sunSetOffsetMs,\n sunDeltaMs,\n currentTimeOffsetMs,\n speed,\n loop: false,\n shadowColor,\n duration,\n adjustedDuration,\n };\n }\n\n public override componentWillUnmount() {\n window.cancelAnimationFrame(this._requestFrame);\n this._unmounted = true;\n }\n\n // recursively update the animation until we hit the end or the pause button is clicked\n private _updateAnimation = (_timestamp: number) => {\n if (!this.state.isPlaying || this._unmounted) {\n window.cancelAnimationFrame(this._requestFrame);\n return;\n }\n\n const currentTime = new Date().getTime();\n this._totalPlayTime += currentTime - this._timeLastCycle;\n this._timeLastCycle = currentTime;\n let percentComplete = this._totalPlayTime / this.state.adjustedDuration;\n if (percentComplete > 1) percentComplete = 1;\n\n let newPlayingState = true;\n\n // calculate the next sun time base on the percentage playback complete - should be int value as that is step amount for slider\n let nextSunOffset = Math.floor(\n this.state.sunRiseOffsetMs + percentComplete * this.state.sunDeltaMs\n );\n\n if (percentComplete > 0.99) {\n if (!this.state.loop) {\n newPlayingState = false;\n nextSunOffset = this.state.sunSetOffsetMs;\n window.cancelAnimationFrame(this._requestFrame);\n } else {\n nextSunOffset = this.state.sunRiseOffsetMs;\n this._totalPlayTime = 0;\n }\n }\n\n if (this.props.dataProvider.onTimeChanged) {\n const currentSunTime = new Date(this.state.dayStartMs + nextSunOffset);\n this.props.dataProvider.onTimeChanged(currentSunTime);\n }\n\n this.setState(\n { isPlaying: newPlayingState, currentTimeOffsetMs: nextSunOffset },\n () => {\n if (newPlayingState)\n this._requestFrame = window.requestAnimationFrame(\n this._updateAnimation\n );\n }\n );\n };\n\n private _play(sunTimeMs: number) {\n this._timeLastCycle = new Date().getTime();\n\n // start playing\n this.setState({ isPlaying: true, currentTimeOffsetMs: sunTimeMs }, () => {\n this._requestFrame = window.requestAnimationFrame(this._updateAnimation);\n if (this.props.onPlayPause) this.props.onPlayPause(true);\n });\n }\n\n // user clicked pause button\n private _onPause = () => {\n if (!this.state.isPlaying) return;\n\n const currentTime = new Date().getTime();\n this._totalPlayTime += currentTime - this._timeLastCycle;\n\n // stop requesting frames\n window.cancelAnimationFrame(this._requestFrame);\n\n // stop playing\n this.setState({ isPlaying: false });\n\n if (this.props.onPlayPause) this.props.onPlayPause(false);\n };\n\n // user clicked play button\n private _onPlay = () => {\n if (this.state.isPlaying) return;\n\n if (\n this.state.currentTimeOffsetMs >= this.state.sunSetOffsetMs ||\n this.state.currentTimeOffsetMs <= this.state.sunRiseOffsetMs\n ) {\n this._totalPlayTime = 0;\n this._play(this.state.sunRiseOffsetMs);\n } else {\n this._play(this.state.currentTimeOffsetMs);\n }\n };\n\n private setPlaybackTimeBySunTime(\n sunOffsetMs: number,\n sunRiseOffsetMs: number,\n sunDeltaMs: number,\n adjustedDuration?: number\n ) {\n this._totalPlayTime =\n ((sunOffsetMs - sunRiseOffsetMs) / sunDeltaMs) *\n (adjustedDuration ? adjustedDuration : this.state.adjustedDuration);\n }\n\n private _onDateChange = (newDate: Date) => {\n this.props.dataProvider.setDateAndTime(newDate);\n\n const dayStartMs = this.props.dataProvider.dayStartMs;\n const sunRiseOffsetMs =\n this.props.dataProvider.sunrise.getTime() - dayStartMs;\n const sunSetOffsetMs =\n this.props.dataProvider.sunset.getTime() - dayStartMs;\n const sunDeltaMs = sunSetOffsetMs - sunRiseOffsetMs;\n\n /** call dataProvider to update display style */\n // this.props.dataProvider.onTimeChanged?.(this.props.dataProvider.timeOfDay);\n\n // Update time\n const newHours = newDate.getHours();\n const newMinutes = newDate.getMinutes();\n const newSunTime = newHours * msPerHour + newMinutes * msPerMinute;\n const dateWithNewTime = new Date(dayStartMs + newSunTime);\n // this.props.dataProvider.setDateAndTime(dateWithNewTime, true);\n\n const currentTimeOffsetMs = this.ensureRange(\n newSunTime,\n sunRiseOffsetMs,\n sunSetOffsetMs\n );\n this.setPlaybackTimeBySunTime(\n currentTimeOffsetMs,\n sunRiseOffsetMs,\n sunDeltaMs\n );\n this._timeLastCycle = new Date().getTime();\n\n this.props.dataProvider.onTimeChanged?.(dateWithNewTime);\n this.setState({\n dayStartMs,\n sunRiseOffsetMs,\n sunSetOffsetMs,\n currentTimeOffsetMs,\n sunDeltaMs,\n isDateOpened: false,\n });\n };\n\n private _onCloseSettingsPopup = () => {\n this.setState({ isSettingsOpened: false });\n };\n\n private _onOpenSettingsPopup = () => {\n this.setState((prevState) => ({\n isSettingsOpened: !prevState.isSettingsOpened,\n }));\n };\n\n private ensureRange(value: number, min: number, max: number): number {\n return Math.max(Math.min(value, max), min);\n }\n\n private processSunTimeChange(sunTime: number) {\n if (sunTime === this.state.currentTimeOffsetMs) return;\n\n const currentTimeOffsetMs = this.ensureRange(\n sunTime,\n this.state.sunRiseOffsetMs,\n this.state.sunSetOffsetMs\n );\n\n if (this.props.dataProvider.onTimeChanged) {\n const currentSunTime = new Date(\n this.state.dayStartMs + currentTimeOffsetMs\n );\n this.props.dataProvider.onTimeChanged(currentSunTime);\n }\n\n this.setState({ currentTimeOffsetMs }, () => {\n const currentTime = new Date().getTime();\n this._timeLastCycle = currentTime;\n const percentComplete =\n (currentTimeOffsetMs - this.state.sunRiseOffsetMs) /\n this.state.sunDeltaMs;\n this._totalPlayTime = percentComplete * this.state.adjustedDuration;\n });\n }\n\n private _onUpdate = (values: ReadonlyArray<number>) => {\n if (!this.state.isPlaying) this.processSunTimeChange(values[0]);\n };\n\n private _onChange = (values: ReadonlyArray<number>) => {\n if (!this.state.isPlaying) this.processSunTimeChange(values[0]);\n };\n\n private _onSpeedChange = (value: number) => {\n const adjustedDuration = this.state.duration / value;\n this.setState({ speed: value, adjustedDuration });\n };\n\n private _onToggleLoop = () => {\n this.setState((prevState) => ({ loop: !prevState.loop }));\n };\n\n private _formatTime = (ms: number) => {\n const date = new Date(ms);\n const amLabel = UiComponents.translate(\"time.am\");\n const pmLabel = UiComponents.translate(\"time.pm\");\n // convert project date to browser locale date\n const localTime = adjustDateToTimezone(\n date,\n this.props.dataProvider.timeZoneOffset * 60\n );\n let hours = localTime.getHours();\n const minutes = date.getMinutes();\n const abbrev = hours < 12 ? amLabel : hours === 24 ? amLabel : pmLabel;\n hours = hours > 12 ? hours - 12 : hours;\n const hoursStr = hours.toLocaleString(undefined, {\n minimumIntegerDigits: 2,\n });\n const minutesStr = minutes.toLocaleString(undefined, {\n minimumIntegerDigits: 2,\n });\n return `${hoursStr}:${minutesStr} ${abbrev}`;\n };\n\n public getLocalTime(ticks: number): Date {\n const projectTime = new Date(ticks);\n // convert project date to browser locale date\n return adjustDateToTimezone(\n projectTime,\n this.props.dataProvider.timeZoneOffset * 60\n );\n }\n\n public override render() {\n const { dataProvider } = this.props;\n const {\n speed: currentSpeed,\n loop,\n currentTimeOffsetMs,\n sunRiseOffsetMs,\n sunSetOffsetMs,\n } = this.state;\n const months = [\n UiComponents.translate(\"month.short.january\"),\n UiComponents.translate(\"month.short.february\"),\n UiComponents.translate(\"month.short.march\"),\n UiComponents.translate(\"month.short.april\"),\n UiComponents.translate(\"month.short.may\"),\n UiComponents.translate(\"month.short.june\"),\n UiComponents.translate(\"month.short.july\"),\n UiComponents.translate(\"month.short.august\"),\n UiComponents.translate(\"month.short.september\"),\n UiComponents.translate(\"month.short.october\"),\n UiComponents.translate(\"month.short.november\"),\n UiComponents.translate(\"month.short.december\"),\n ];\n\n const localTime = this.getLocalTime(\n this.state.dayStartMs + this.state.currentTimeOffsetMs\n );\n const formattedTime = this._formatTime(\n dataProvider.dayStartMs + currentTimeOffsetMs\n );\n const formattedDate = `${\n months[localTime.getMonth()]\n }, ${localTime.getDate()}`;\n\n return (\n <div className=\"solar-timeline-wrapper\">\n <Flex flexWrap=\"wrap\" gap=\"none\" className=\"solar-timeline-start\">\n <PlayButton\n isPlaying={this.state.isPlaying}\n onPlay={this._onPlay}\n onPause={this._onPause}\n />\n <Popover\n content={\n <DatePicker\n date={localTime}\n onChange={this._onDateChange}\n showTime\n use12Hours\n />\n }\n visible={this.state.isDateOpened}\n onVisibleChange={(isDateOpened) => {\n this.setState({ isDateOpened });\n }}\n placement=\"top\"\n middleware={{\n offset,\n }}\n >\n <CalendarButton\n onClick={() => {\n const isDateOpened = !this.state.isDateOpened;\n this.setState({ isDateOpened });\n }}\n >\n {formattedDate} @ {formattedTime}\n </CalendarButton>\n </Popover>\n </Flex>\n\n <Timeline\n dayStartMs={dataProvider.dayStartMs}\n sunSetOffsetMs={sunSetOffsetMs}\n sunRiseOffsetMs={sunRiseOffsetMs}\n currentTimeOffsetMs={currentTimeOffsetMs}\n onChange={this._onChange}\n onUpdate={this._onUpdate}\n formatTime={this._formatTime}\n isPlaying={this.state.isPlaying}\n />\n\n <Flex\n justifyContent=\"flex-end\"\n flexWrap=\"wrap\"\n gap=\"none\"\n className=\"solar-timeline-end\"\n >\n <VisuallyHidden>\n <Label htmlFor=\"speed\">Timeline speed</Label>\n </VisuallyHidden>\n <Tooltip\n content={UiIModelComponents.translate(\"solartimeline.speed\")}\n >\n <Select\n native\n styleType=\"borderless\"\n triggerProps={{\n name: \"speed\",\n }}\n onChange={(newValue) => this._onSpeedChange(Number(newValue))}\n value={currentSpeed.toString()}\n options={this._speeds.map((speed) => ({\n value: speed.toString(),\n label: `${speed}x`,\n }))}\n />\n </Tooltip>\n\n <IconButton\n styleType=\"borderless\"\n label={UiIModelComponents.translate(\"timeline.repeat\")}\n onClick={this._onToggleLoop}\n isActive={loop}\n >\n <SvgLoop />\n </IconButton>\n\n <Popover\n content={\n <ColorPicker\n selectedColor={this.state.shadowColor.colors}\n onChangeComplete={(color) => {\n const colorDef = ColorDef.create(color.toTbgr());\n this.setState(\n { shadowColor: colorDef },\n () => (this.props.dataProvider.shadowColor = colorDef)\n );\n }}\n >\n <Text variant=\"title\" as=\"h2\" style={{ textAlign: \"center\" }}>\n {UiIModelComponents.translate(\"solarsettings.shadowcolor\")}\n </Text>\n <ColorBuilder />\n <ColorInputPanel defaultColorFormat=\"hsl\" />\n <ColorPalette\n colors={this._presetColors.map((color) => color.colors)}\n />\n </ColorPicker>\n }\n placement=\"top\"\n middleware={{\n offset,\n }}\n >\n <IconButton\n styleType=\"borderless\"\n data-testid=\"shadow-settings-button\"\n label={UiIModelComponents.translate(\"timeline.settings\")}\n onClick={this._onOpenSettingsPopup}\n >\n <SvgSettings />\n </IconButton>\n </Popover>\n </Flex>\n </div>\n );\n }\n}\n\ninterface CalendarButtonProps {\n children?: React.ReactNode;\n onClick?: () => void;\n}\n\nconst CalendarButton = React.forwardRef<HTMLButtonElement, CalendarButtonProps>(\n function CalendarButton({ children, onClick }, ref) {\n const { translate } = useTranslation();\n const tooltip = translate(\"solartimeline.dateTime\");\n\n return (\n <Tooltip content={tooltip}>\n <Button\n styleType=\"borderless\"\n startIcon={<SvgCalendar />}\n data-testid=\"solar-date-time-button\"\n title={tooltip}\n onClick={onClick}\n ref={ref}\n >\n <span className=\"solar-timeline-date-time\">{children}</span>\n </Button>\n </Tooltip>\n );\n }\n);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SpeedTimeline.js","sourceRoot":"","sources":["../../../src/imodel-components-react/timeline/SpeedTimeline.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,sBAAsB,CAAC;AAC9B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAW9C;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,KAAiB;IAC7C,MAAM,QAAQ,GAAG,CAAC,MAA6B,EAAE,EAAE;QACjD,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACxB,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC;YAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxE,CAAC,CAAC;IAEF,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QAC1C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,6BAAK,SAAS,EAAE,UAAU,CAAC,gBAAgB,EAAE,KAAK,CAAC,SAAS,CAAC;QAC3D,oBAAC,MAAM,IACL,IAAI,EAAE,CAAC,EACP,GAAG,EAAE,CAAC,EACN,GAAG,EAAE,CAAC,EACN,QAAQ,EAAC,EAAE,EACX,QAAQ,EAAC,EAAE,EACX,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EACrB,gBAAgB,EAAC,MAAM,EACvB,YAAY,EAAE,YAAY,GAC1B,CACE,CACP,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Timeline\n */\n\nimport \"./SpeedTimeline.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Slider } from \"@itwin/itwinui-react\";\nimport type { CommonProps } from \"@itwin/core-react\";\n\n// component is in alpha state - it may change after usability testing - test coverage not complete\n\n// eslint-disable-next-line deprecation/deprecation\ninterface SpeedProps extends CommonProps {\n speed: number;\n onChange?: (value: number) => void;\n}\n\n/** Speed Timeline used in Solar Timeline component\n * @internal\n */\nexport function SpeedTimeline(props: SpeedProps) {\n const onChange = (values: ReadonlyArray<number>) => {\n const value = values[0];\n if (props.onChange && value >= 1 && value <= 6) props.onChange(value);\n };\n\n const tooltipProps = React.useCallback(() => {\n return { visible: false };\n }, []);\n\n return (\n <div className={classnames(\"speed-timeline\", props.className)}>\n <Slider\n step={1}\n min={1}\n max={6}\n minLabel=\"\"\n maxLabel=\"\"\n onUpdate={onChange}\n onChange={onChange}\n values={[props.speed]}\n trackDisplayMode=\"none\"\n tooltipProps={tooltipProps}\n />\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"SpeedTimeline.js","sourceRoot":"","sources":["../../../src/imodel-components-react/timeline/SpeedTimeline.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,sBAAsB,CAAC;AAC9B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAW9C;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,KAAiB;IAC7C,MAAM,QAAQ,GAAG,CAAC,MAA6B,EAAE,EAAE;QACjD,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACxB,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC;YAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxE,CAAC,CAAC;IAEF,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QAC1C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,6BAAK,SAAS,EAAE,UAAU,CAAC,gBAAgB,EAAE,KAAK,CAAC,SAAS,CAAC;QAC3D,oBAAC,MAAM,IACL,IAAI,EAAE,CAAC,EACP,GAAG,EAAE,CAAC,EACN,GAAG,EAAE,CAAC,EACN,QAAQ,EAAC,EAAE,EACX,QAAQ,EAAC,EAAE,EACX,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EACrB,gBAAgB,EAAC,MAAM,EACvB,YAAY,EAAE,YAAY,GAC1B,CACE,CACP,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Timeline\n */\n\nimport \"./SpeedTimeline.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Slider } from \"@itwin/itwinui-react\";\nimport type { CommonProps } from \"@itwin/core-react\";\n\n// component is in alpha state - it may change after usability testing - test coverage not complete\n\n// eslint-disable-next-line @typescript-eslint/no-deprecated\ninterface SpeedProps extends CommonProps {\n speed: number;\n onChange?: (value: number) => void;\n}\n\n/** Speed Timeline used in Solar Timeline component\n * @internal\n */\nexport function SpeedTimeline(props: SpeedProps) {\n const onChange = (values: ReadonlyArray<number>) => {\n const value = values[0];\n if (props.onChange && value >= 1 && value <= 6) props.onChange(value);\n };\n\n const tooltipProps = React.useCallback(() => {\n return { visible: false };\n }, []);\n\n return (\n <div className={classnames(\"speed-timeline\", props.className)}>\n <Slider\n step={1}\n min={1}\n max={6}\n minLabel=\"\"\n maxLabel=\"\"\n onUpdate={onChange}\n onChange={onChange}\n values={[props.speed]}\n trackDisplayMode=\"none\"\n tooltipProps={tooltipProps}\n />\n </div>\n );\n}\n"]}
@@ -83,13 +83,13 @@ export function TimelineComponent(props) {
83
83
  updateRepeat(props.repeat ?? repeat);
84
84
  }
85
85
  React.useEffect(() => {
86
- // eslint-disable-next-line deprecation/deprecation
86
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
87
87
  if (!props.componentId)
88
88
  return;
89
89
  return UiAdmin.onGenericUiEvent.addListener((args) => {
90
90
  const timelineArgs = args;
91
91
  if (!timelineArgs ||
92
- // eslint-disable-next-line deprecation/deprecation
92
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
93
93
  props.componentId !== timelineArgs.uiComponentId ||
94
94
  timelineArgs.timelineAction === undefined)
95
95
  return;
@@ -110,7 +110,7 @@ export function TimelineComponent(props) {
110
110
  break;
111
111
  }
112
112
  });
113
- // eslint-disable-next-line deprecation/deprecation
113
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
114
114
  }, [isPlaying, pause, playOrReplay, props.componentId]);
115
115
  useAnimation(({ delta }) => {
116
116
  const duration = currentDuration + delta;
@@ -1 +1 @@
1
- {"version":3,"file":"TimelineComponent.js","sourceRoot":"","sources":["../../../src/imodel-components-react/timeline/TimelineComponent.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AACH,OAAO,0BAA0B,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE3E,OAAO,EACL,YAAY,EACZ,UAAU,EACV,WAAW,EACX,QAAQ,GACT,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,SAAS,GAAG,EAAE,GAAG,IAAI,CAAC;AAC5B,MAAM,WAAW,GAAG,EAAE,GAAG,IAAI,CAAC;AAC9B,MAAM,SAAS,GAAG,EAAE,GAAG,IAAI,CAAC;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AAG,SAAS,CAAC;YAChC,MAAM,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;QACtC,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AAChB,CAAC;AAED,SAAS,QAAQ,CAAC,IAAY;IAC5B,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QAC7B,OAAO,CACL,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CACtE,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC7B,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,EAAU;IAC/B,MAAM,OAAO,GAAG,CAAC,CAAS,EAAE,EAAE;QAC5B,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC,CAAC;IAEF,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,EAAE,CAAC,CAAC;IAC1B,oCAAoC;IACpC,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;IACrC,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;IACrC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;AACnD,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Timeline\n */\nimport \"./TimelineComponent.scss\";\nimport * as React from \"react\";\nimport { UiAdmin } from \"@itwin/appui-abstract\";\nimport type { DateFormatOptions } from \"@itwin/components-react\";\nimport { toDateString, toTimeString } from \"@itwin/components-react\";\nimport { SvgCheckmark, SvgMoreVertical } from \"@itwin/itwinui-icons-react\";\nimport type { Slider } from \"@itwin/itwinui-react\";\nimport {\n DropdownMenu,\n IconButton,\n MenuDivider,\n MenuItem,\n} from \"@itwin/itwinui-react\";\nimport { InlineEdit } from \"./InlineEdit.js\";\nimport type { PlaybackSettings, TimelinePausePlayArgs } from \"./interfaces.js\";\nimport { TimelinePausePlayAction } from \"./interfaces.js\";\nimport { PlayButton } from \"./PlayButton.js\";\nimport { Scrubber } from \"./Scrubber.js\";\nimport { useTranslation } from \"../useTranslation.js\";\n\nconst slowSpeed = 60 * 1000;\nconst mediumSpeed = 20 * 1000;\nconst fastSpeed = 10 * 1000;\n\n/** [[TimelineMenuItemOption]]: specifies how the app wants the timeline speeds to be installed on the TimelineComponent's ContextMenu\n * \"replace\" : use the app-supplied items in place of the standard items\n * \"append\" : add the app-supplied items following the standard items\n * \"prefix\" : add the app-supplied items before the standard items\n *\n * @public\n */\nexport type TimelineMenuItemOption = \"replace\" | \"append\" | \"prefix\";\n\n/** [[TimelineMenuItemProps]] specifies playback speed entries in the Timeline's ContextMenu\n * @public\n */\nexport interface TimelineMenuItemProps {\n /** localized label for menu item */\n label: string;\n\n /** duration for the entire timeline to play */\n timelineDuration: number;\n}\n\n/** TimelineDateMarkerProps: Mark a date on the timeline with an indicator\n * @public\n */\nexport interface TimelineDateMarkerProps {\n /** Date to mark. If undefined, today's date will be used. */\n date?: Date;\n /** ReactNode to use as the marker on the timeline. If undefined, a short vertical bar will mark the date. */\n dateMarker?: React.ReactNode;\n}\n\n/** [[TimelineComponentProps]] configure the timeline\n * @public\n */\nexport interface TimelineComponentProps {\n /** Start date: beginning of the date range of a date-based timeline. */\n startDate?: Date;\n /** End date: end of the date range of a date-based timeline. */\n endDate?: Date;\n /** Total duration: range of the timeline in milliseconds.\n * @note This can be changed by user interaction. See {@link TimelineComponentProps.appMenuItems}.\n */\n totalDuration: number;\n /** Initial value for the current duration (the location of the thumb) in milliseconds */\n initialDuration?: number;\n /** Show in minimized mode (For future use. This prop will always be treated as true.)\n * @deprecated in 4.10.0. Has no effect.\n */\n minimized?: boolean;\n /** When playing, repeat indefinitely. Defaults to `false`.\n * @note This can be changed by user interaction. See {@link TimelineComponentProps.includeRepeat}.\n */\n repeat?: boolean;\n /** Show duration instead of time */\n showDuration?: boolean;\n /** Callback with current duration value (as a fraction) */\n onChange?: (duration: number) => void;\n /** Callback triggered when play/pause button is pressed */\n onPlayPause?: (playing: boolean) => void;\n /** Callback triggered when backward/forward buttons are pressed.\n * @deprecated in 4.10.0. Has no effect.\n */\n onJump?: (forward: boolean) => void;\n /** Callback triggered when a setting is changed */\n onSettingsChange?: (arg: PlaybackSettings) => void;\n /** Always display in miniMode with no expand menu (For future use. This prop will always be treated as true)\n * @deprecated in 4.10.0. Has no effect.\n */\n alwaysMinimized?: boolean;\n /** ComponentId -- must be set to use TimelineComponentEvents\n * @deprecated in 4.11.0. Use the isPlaying prop instead.\n */\n componentId?: string;\n /** Include the repeat option on the Timeline Context Menu. Defaults to `true`. */\n includeRepeat?: boolean;\n /** App-supplied speed entries in the Timeline Context Menu. Defaults to `[Slow, Medium, Fast]` items. */\n appMenuItems?: TimelineMenuItemProps[];\n /** How to include the supplied app menu items in the Timeline Context Menu (prefix, append or replace). Defaults to `replace`. */\n appMenuItemOption?: TimelineMenuItemOption;\n /** Display date and time offset by the number of minutes specified. When undefined - local timezone will be used */\n timeZoneOffset?: number;\n /** Display a marker on the timeline rail to indicate current date - will only work if starDate and endDate are defined */\n markDate?: TimelineDateMarkerProps;\n /** Options used to format date string. If not defined it will user browser default locale settings. */\n dateFormatOptions?: DateFormatOptions;\n /** Options used to format time string. If not defined it will user browser default locale settings. */\n timeFormatOptions?: DateFormatOptions;\n /** Used to control the play/pause state of the Timeline.*/\n isPlaying?: boolean;\n /** Props for a container that holds the slider thumbs and tracks. */\n trackContainerProps?: React.ComponentProps<\n typeof Slider\n >[\"trackContainerProps\"];\n}\n\n/** [[TimelineComponent]] is used to playback timeline data\n * @public\n */\nexport function TimelineComponent(props: TimelineComponentProps) {\n const {\n appMenuItemOption = \"replace\",\n startDate,\n endDate,\n showDuration,\n timeZoneOffset,\n dateFormatOptions,\n timeFormatOptions,\n includeRepeat = true,\n onSettingsChange,\n onChange,\n onPlayPause,\n } = props;\n const [isPlaying, setIsPlaying] = React.useState(!!props.isPlaying);\n const [currentDuration, setCurrentDuration] = React.useState(\n props.initialDuration ?? 0\n );\n const [totalDuration, setTotalDuration] = React.useState(props.totalDuration);\n const [repeat, setRepeat] = React.useState(props.repeat ?? false);\n\n const playOrReplay = React.useCallback(() => {\n if (isPlaying) return;\n\n if (currentDuration >= totalDuration) {\n setCurrentDuration(0);\n }\n\n setIsPlaying(true);\n onPlayPause?.(true);\n }, [isPlaying, onPlayPause, currentDuration, totalDuration]);\n const pause = React.useCallback(() => {\n if (!isPlaying) return;\n setIsPlaying(false);\n onPlayPause?.(false);\n }, [isPlaying, onPlayPause]);\n const updateTotalDuration = (newTotalDuration: number) => {\n if (newTotalDuration === totalDuration) return;\n\n const fraction = currentDuration / totalDuration;\n const newCurrentDuration = fraction * newTotalDuration;\n\n setTotalDuration(newTotalDuration);\n setCurrentDuration(newCurrentDuration);\n onSettingsChange?.({ duration: newTotalDuration });\n };\n const updateDuration = (\n newDuration: number,\n currentTotalDuration = totalDuration\n ) => {\n newDuration = Math.max(newDuration, 0);\n newDuration = Math.min(newDuration, currentTotalDuration);\n\n if (newDuration === currentDuration) return;\n setCurrentDuration(newDuration);\n\n const fraction = newDuration / currentTotalDuration;\n onChange?.(fraction);\n };\n const updateRepeat = (newRepeat: boolean) => {\n if (newRepeat === repeat) return;\n\n setRepeat(newRepeat);\n onSettingsChange?.({ loop: newRepeat });\n };\n\n const [prevTotalDuration, setPrevTotalDuration] = React.useState(\n props.totalDuration\n );\n if (prevTotalDuration !== props.totalDuration) {\n setPrevTotalDuration(props.totalDuration);\n updateTotalDuration(props.totalDuration);\n }\n\n const [prevInitialDuration, setPrevInitialDuration] = React.useState(\n props.initialDuration\n );\n if (prevInitialDuration !== props.initialDuration) {\n setPrevInitialDuration(props.initialDuration);\n updateDuration(props.initialDuration ?? 0, props.totalDuration);\n }\n\n const [prevRepeat, setPrevRepeat] = React.useState(props.repeat);\n if (prevRepeat !== props.repeat) {\n setPrevRepeat(props.repeat);\n updateRepeat(props.repeat ?? repeat);\n }\n\n React.useEffect(() => {\n // eslint-disable-next-line deprecation/deprecation\n if (!props.componentId) return;\n return UiAdmin.onGenericUiEvent.addListener((args) => {\n const timelineArgs = args as TimelinePausePlayArgs;\n if (\n !timelineArgs ||\n // eslint-disable-next-line deprecation/deprecation\n props.componentId !== timelineArgs.uiComponentId ||\n timelineArgs.timelineAction === undefined\n )\n return;\n\n switch (timelineArgs.timelineAction) {\n case TimelinePausePlayAction.Play:\n playOrReplay();\n break;\n case TimelinePausePlayAction.Pause:\n pause();\n break;\n case TimelinePausePlayAction.Toggle:\n if (isPlaying) {\n pause();\n } else {\n playOrReplay();\n }\n break;\n }\n });\n // eslint-disable-next-line deprecation/deprecation\n }, [isPlaying, pause, playOrReplay, props.componentId]);\n useAnimation(({ delta }) => {\n const duration = currentDuration + delta;\n updateDuration(duration);\n\n if (duration >= totalDuration) {\n if (repeat) {\n setCurrentDuration(0);\n return;\n }\n\n pause();\n }\n }, isPlaying);\n\n React.useEffect(() => {\n if (props.isPlaying) playOrReplay();\n\n if (props.isPlaying === false) pause();\n }, [props.isPlaying, playOrReplay, pause]);\n\n const onTimelineChange = (values: ReadonlyArray<number>) => {\n const newDuration = values[0];\n updateDuration(newDuration);\n };\n\n const currentDurationStr = toDisplayTime(currentDuration);\n const totalDurationStr = toDisplayTime(totalDuration);\n const hasDates = !!startDate && !!endDate;\n return (\n <div data-testid=\"timeline-component\" className=\"timeline-component\">\n <PlayButton isPlaying={isPlaying} onPlay={playOrReplay} onPause={pause} />\n <div className=\"time-container\">\n {hasDates && (\n <span data-testid=\"test-start-date\" className=\"timeline-date\">\n {toDateString(startDate, timeZoneOffset, dateFormatOptions)}\n </span>\n )}\n {hasDates && !showDuration && (\n <span data-testid=\"test-start-time\" className=\"timeline-time\">\n {toTimeString(startDate, timeZoneOffset, timeFormatOptions)}\n </span>\n )}\n {showDuration && (\n <span className=\"timeline-duration-time\">{currentDurationStr}</span>\n )}\n </div>\n <Scrubber\n className=\"slider\"\n currentDuration={currentDuration}\n totalDuration={totalDuration}\n startDate={startDate}\n endDate={endDate}\n isPlaying={isPlaying}\n showTime={!showDuration}\n onChange={onTimelineChange}\n onUpdate={onTimelineChange}\n timeZoneOffset={props.timeZoneOffset}\n markDate={props.markDate}\n trackContainerProps={props.trackContainerProps}\n />\n <div className=\"time-container\">\n {hasDates && (\n <span data-testid=\"test-end-date\" className=\"timeline-date\">\n {toDateString(endDate, timeZoneOffset)}\n </span>\n )}\n {hasDates && !showDuration && (\n <span className=\"timeline-time\">\n {toTimeString(endDate, timeZoneOffset, timeFormatOptions)}\n </span>\n )}\n {showDuration && (\n <InlineEdit\n className=\"timeline-duration-time\"\n defaultValue={totalDurationStr}\n onChange={(value) => {\n const newTotalDuration = timeToMs(value);\n updateTotalDuration(newTotalDuration);\n }}\n />\n )}\n </div>\n <SettingsMenu\n appMenuItems={props.appMenuItems}\n appMenuItemOption={appMenuItemOption}\n includeRepeat={includeRepeat}\n repeat={repeat}\n totalDuration={totalDuration}\n onRepeatClick={() => {\n updateRepeat(!repeat);\n }}\n onTotalDurationChange={(newTotalDuration) => {\n updateTotalDuration(newTotalDuration);\n }}\n />\n </div>\n );\n}\n\ntype SettingsMenuProps = Pick<\n TimelineComponentProps,\n \"appMenuItems\" | \"totalDuration\"\n> &\n Pick<\n Required<TimelineComponentProps>,\n \"appMenuItemOption\" | \"includeRepeat\" | \"repeat\"\n > & {\n onRepeatClick: () => void;\n onTotalDurationChange: (totalDuration: number) => void;\n };\n\nfunction SettingsMenu({\n appMenuItems,\n appMenuItemOption,\n includeRepeat,\n repeat,\n totalDuration,\n onRepeatClick,\n onTotalDurationChange,\n}: SettingsMenuProps) {\n const { translate } = useTranslation();\n\n const menuItems = React.useMemo(() => {\n const standardItems: TimelineMenuItemProps[] = [\n {\n label: translate(\"timeline.slow\"),\n timelineDuration: slowSpeed,\n },\n {\n label: translate(\"timeline.medium\"),\n timelineDuration: mediumSpeed,\n },\n {\n label: translate(\"timeline.fast\"),\n timelineDuration: fastSpeed,\n },\n ];\n\n if (!appMenuItems) {\n return standardItems;\n }\n\n if (appMenuItemOption === \"append\") {\n return [...standardItems, ...appMenuItems];\n }\n if (appMenuItemOption === \"prefix\") {\n return [...appMenuItems, ...standardItems];\n }\n // Replace\n return appMenuItems;\n }, [appMenuItemOption, appMenuItems, translate]);\n\n return (\n <DropdownMenu\n menuItems={(close) => {\n return [\n ...(includeRepeat\n ? [\n <MenuItem\n key=\"repeat\"\n onClick={() => {\n onRepeatClick();\n close();\n }}\n startIcon={repeat ? <SvgCheckmark /> : <></>}\n >\n {translate(\"timeline.repeat\")}\n </MenuItem>,\n <MenuDivider key=\"divider\" />,\n ]\n : []),\n ...menuItems.map((item, index) => {\n const checked = totalDuration === item.timelineDuration;\n return (\n <MenuItem\n key={index}\n startIcon={checked ? <SvgCheckmark /> : <></>}\n onClick={() => {\n onTotalDurationChange(item.timelineDuration);\n close();\n }}\n >\n {item.label}\n </MenuItem>\n );\n }),\n ];\n }}\n placement=\"top-start\"\n >\n <IconButton\n data-testid=\"timeline-settings\"\n label={translate(\"timeline.settings\")}\n styleType=\"borderless\"\n >\n <SvgMoreVertical />\n </IconButton>\n </DropdownMenu>\n );\n}\n\nfunction useAnimation(\n onAnimate: (args: { delta: number }) => void,\n playing = true\n) {\n const onAnimateRef = React.useRef(onAnimate);\n onAnimateRef.current = onAnimate;\n\n const lastTimeRef = React.useRef<number | undefined>();\n\n React.useEffect(() => {\n if (!playing) return;\n\n let handle = 0;\n let didCancel = false;\n\n const animate = (time: number) => {\n if (lastTimeRef.current === undefined) {\n lastTimeRef.current = time;\n }\n\n const delta = time - lastTimeRef.current;\n lastTimeRef.current = time;\n\n onAnimateRef.current({\n delta,\n });\n\n if (didCancel) return;\n\n handle = window.requestAnimationFrame(animate);\n };\n\n handle = window.requestAnimationFrame(animate);\n return () => {\n didCancel = true;\n lastTimeRef.current = undefined;\n window.cancelAnimationFrame(handle);\n };\n }, [playing]);\n}\n\nfunction timeToMs(time: string) {\n if (time.indexOf(\":\") !== -1) {\n return (\n (Number(time.split(\":\")[0]) * 60 + Number(time.split(\":\")[1])) * 1000\n );\n } else {\n return Number(time) * 1000;\n }\n}\n\nfunction toDisplayTime(ms: number) {\n const addZero = (i: number) => {\n return i < 10 ? `0${i}` : i;\n };\n\n const date = new Date(ms);\n // const hours = date.getUTCHours();\n const minutes = date.getUTCMinutes();\n const seconds = date.getUTCSeconds();\n return `${addZero(minutes)}:${addZero(seconds)}`;\n}\n"]}
1
+ {"version":3,"file":"TimelineComponent.js","sourceRoot":"","sources":["../../../src/imodel-components-react/timeline/TimelineComponent.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AACH,OAAO,0BAA0B,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE3E,OAAO,EACL,YAAY,EACZ,UAAU,EACV,WAAW,EACX,QAAQ,GACT,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,i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AG,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;AACnD,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Timeline\n */\nimport \"./TimelineComponent.scss\";\nimport * as React from \"react\";\nimport { UiAdmin } from \"@itwin/appui-abstract\";\nimport type { DateFormatOptions } from \"@itwin/components-react\";\nimport { toDateString, toTimeString } from \"@itwin/components-react\";\nimport { SvgCheckmark, SvgMoreVertical } from \"@itwin/itwinui-icons-react\";\nimport type { Slider } from \"@itwin/itwinui-react\";\nimport {\n DropdownMenu,\n IconButton,\n MenuDivider,\n MenuItem,\n} from \"@itwin/itwinui-react\";\nimport { InlineEdit } from \"./InlineEdit.js\";\nimport type { PlaybackSettings, TimelinePausePlayArgs } from \"./interfaces.js\";\nimport { TimelinePausePlayAction } from \"./interfaces.js\";\nimport { PlayButton } from \"./PlayButton.js\";\nimport { Scrubber } from \"./Scrubber.js\";\nimport { useTranslation } from \"../useTranslation.js\";\n\nconst slowSpeed = 60 * 1000;\nconst mediumSpeed = 20 * 1000;\nconst fastSpeed = 10 * 1000;\n\n/** [[TimelineMenuItemOption]]: specifies how the app wants the timeline speeds to be installed on the TimelineComponent's ContextMenu\n * \"replace\" : use the app-supplied items in place of the standard items\n * \"append\" : add the app-supplied items following the standard items\n * \"prefix\" : add the app-supplied items before the standard items\n *\n * @public\n */\nexport type TimelineMenuItemOption = \"replace\" | \"append\" | \"prefix\";\n\n/** [[TimelineMenuItemProps]] specifies playback speed entries in the Timeline's ContextMenu\n * @public\n */\nexport interface TimelineMenuItemProps {\n /** localized label for menu item */\n label: string;\n\n /** duration for the entire timeline to play */\n timelineDuration: number;\n}\n\n/** TimelineDateMarkerProps: Mark a date on the timeline with an indicator\n * @public\n */\nexport interface TimelineDateMarkerProps {\n /** Date to mark. If undefined, today's date will be used. */\n date?: Date;\n /** ReactNode to use as the marker on the timeline. If undefined, a short vertical bar will mark the date. */\n dateMarker?: React.ReactNode;\n}\n\n/** [[TimelineComponentProps]] configure the timeline\n * @public\n */\nexport interface TimelineComponentProps {\n /** Start date: beginning of the date range of a date-based timeline. */\n startDate?: Date;\n /** End date: end of the date range of a date-based timeline. */\n endDate?: Date;\n /** Total duration: range of the timeline in milliseconds.\n * @note This can be changed by user interaction. See {@link TimelineComponentProps.appMenuItems}.\n */\n totalDuration: number;\n /** Initial value for the current duration (the location of the thumb) in milliseconds */\n initialDuration?: number;\n /** Show in minimized mode (For future use. This prop will always be treated as true.)\n * @deprecated in 4.10.0. Has no effect.\n */\n minimized?: boolean;\n /** When playing, repeat indefinitely. Defaults to `false`.\n * @note This can be changed by user interaction. See {@link TimelineComponentProps.includeRepeat}.\n */\n repeat?: boolean;\n /** Show duration instead of time */\n showDuration?: boolean;\n /** Callback with current duration value (as a fraction) */\n onChange?: (duration: number) => void;\n /** Callback triggered when play/pause button is pressed */\n onPlayPause?: (playing: boolean) => void;\n /** Callback triggered when backward/forward buttons are pressed.\n * @deprecated in 4.10.0. Has no effect.\n */\n onJump?: (forward: boolean) => void;\n /** Callback triggered when a setting is changed */\n onSettingsChange?: (arg: PlaybackSettings) => void;\n /** Always display in miniMode with no expand menu (For future use. This prop will always be treated as true)\n * @deprecated in 4.10.0. Has no effect.\n */\n alwaysMinimized?: boolean;\n /** ComponentId -- must be set to use TimelineComponentEvents\n * @deprecated in 4.11.0. Use the isPlaying prop instead.\n */\n componentId?: string;\n /** Include the repeat option on the Timeline Context Menu. Defaults to `true`. */\n includeRepeat?: boolean;\n /** App-supplied speed entries in the Timeline Context Menu. Defaults to `[Slow, Medium, Fast]` items. */\n appMenuItems?: TimelineMenuItemProps[];\n /** How to include the supplied app menu items in the Timeline Context Menu (prefix, append or replace). Defaults to `replace`. */\n appMenuItemOption?: TimelineMenuItemOption;\n /** Display date and time offset by the number of minutes specified. When undefined - local timezone will be used */\n timeZoneOffset?: number;\n /** Display a marker on the timeline rail to indicate current date - will only work if starDate and endDate are defined */\n markDate?: TimelineDateMarkerProps;\n /** Options used to format date string. If not defined it will user browser default locale settings. */\n dateFormatOptions?: DateFormatOptions;\n /** Options used to format time string. If not defined it will user browser default locale settings. */\n timeFormatOptions?: DateFormatOptions;\n /** Used to control the play/pause state of the Timeline.*/\n isPlaying?: boolean;\n /** Props for a container that holds the slider thumbs and tracks. */\n trackContainerProps?: React.ComponentProps<\n typeof Slider\n >[\"trackContainerProps\"];\n}\n\n/** [[TimelineComponent]] is used to playback timeline data\n * @public\n */\nexport function TimelineComponent(props: TimelineComponentProps) {\n const {\n appMenuItemOption = \"replace\",\n startDate,\n endDate,\n showDuration,\n timeZoneOffset,\n dateFormatOptions,\n timeFormatOptions,\n includeRepeat = true,\n onSettingsChange,\n onChange,\n onPlayPause,\n } = props;\n const [isPlaying, setIsPlaying] = React.useState(!!props.isPlaying);\n const [currentDuration, setCurrentDuration] = React.useState(\n props.initialDuration ?? 0\n );\n const [totalDuration, setTotalDuration] = React.useState(props.totalDuration);\n const [repeat, setRepeat] = React.useState(props.repeat ?? false);\n\n const playOrReplay = React.useCallback(() => {\n if (isPlaying) return;\n\n if (currentDuration >= totalDuration) {\n setCurrentDuration(0);\n }\n\n setIsPlaying(true);\n onPlayPause?.(true);\n }, [isPlaying, onPlayPause, currentDuration, totalDuration]);\n const pause = React.useCallback(() => {\n if (!isPlaying) return;\n setIsPlaying(false);\n onPlayPause?.(false);\n }, [isPlaying, onPlayPause]);\n const updateTotalDuration = (newTotalDuration: number) => {\n if (newTotalDuration === totalDuration) return;\n\n const fraction = currentDuration / totalDuration;\n const newCurrentDuration = fraction * newTotalDuration;\n\n setTotalDuration(newTotalDuration);\n setCurrentDuration(newCurrentDuration);\n onSettingsChange?.({ duration: newTotalDuration });\n };\n const updateDuration = (\n newDuration: number,\n currentTotalDuration = totalDuration\n ) => {\n newDuration = Math.max(newDuration, 0);\n newDuration = Math.min(newDuration, currentTotalDuration);\n\n if (newDuration === currentDuration) return;\n setCurrentDuration(newDuration);\n\n const fraction = newDuration / currentTotalDuration;\n onChange?.(fraction);\n };\n const updateRepeat = (newRepeat: boolean) => {\n if (newRepeat === repeat) return;\n\n setRepeat(newRepeat);\n onSettingsChange?.({ loop: newRepeat });\n };\n\n const [prevTotalDuration, setPrevTotalDuration] = React.useState(\n props.totalDuration\n );\n if (prevTotalDuration !== props.totalDuration) {\n setPrevTotalDuration(props.totalDuration);\n updateTotalDuration(props.totalDuration);\n }\n\n const [prevInitialDuration, setPrevInitialDuration] = React.useState(\n props.initialDuration\n );\n if (prevInitialDuration !== props.initialDuration) {\n setPrevInitialDuration(props.initialDuration);\n updateDuration(props.initialDuration ?? 0, props.totalDuration);\n }\n\n const [prevRepeat, setPrevRepeat] = React.useState(props.repeat);\n if (prevRepeat !== props.repeat) {\n setPrevRepeat(props.repeat);\n updateRepeat(props.repeat ?? repeat);\n }\n\n React.useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n if (!props.componentId) return;\n return UiAdmin.onGenericUiEvent.addListener((args) => {\n const timelineArgs = args as TimelinePausePlayArgs;\n if (\n !timelineArgs ||\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n props.componentId !== timelineArgs.uiComponentId ||\n timelineArgs.timelineAction === undefined\n )\n return;\n\n switch (timelineArgs.timelineAction) {\n case TimelinePausePlayAction.Play:\n playOrReplay();\n break;\n case TimelinePausePlayAction.Pause:\n pause();\n break;\n case TimelinePausePlayAction.Toggle:\n if (isPlaying) {\n pause();\n } else {\n playOrReplay();\n }\n break;\n }\n });\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n }, [isPlaying, pause, playOrReplay, props.componentId]);\n useAnimation(({ delta }) => {\n const duration = currentDuration + delta;\n updateDuration(duration);\n\n if (duration >= totalDuration) {\n if (repeat) {\n setCurrentDuration(0);\n return;\n }\n\n pause();\n }\n }, isPlaying);\n\n React.useEffect(() => {\n if (props.isPlaying) playOrReplay();\n\n if (props.isPlaying === false) pause();\n }, [props.isPlaying, playOrReplay, pause]);\n\n const onTimelineChange = (values: ReadonlyArray<number>) => {\n const newDuration = values[0];\n updateDuration(newDuration);\n };\n\n const currentDurationStr = toDisplayTime(currentDuration);\n const totalDurationStr = toDisplayTime(totalDuration);\n const hasDates = !!startDate && !!endDate;\n return (\n <div data-testid=\"timeline-component\" className=\"timeline-component\">\n <PlayButton isPlaying={isPlaying} onPlay={playOrReplay} onPause={pause} />\n <div className=\"time-container\">\n {hasDates && (\n <span data-testid=\"test-start-date\" className=\"timeline-date\">\n {toDateString(startDate, timeZoneOffset, dateFormatOptions)}\n </span>\n )}\n {hasDates && !showDuration && (\n <span data-testid=\"test-start-time\" className=\"timeline-time\">\n {toTimeString(startDate, timeZoneOffset, timeFormatOptions)}\n </span>\n )}\n {showDuration && (\n <span className=\"timeline-duration-time\">{currentDurationStr}</span>\n )}\n </div>\n <Scrubber\n className=\"slider\"\n currentDuration={currentDuration}\n totalDuration={totalDuration}\n startDate={startDate}\n endDate={endDate}\n isPlaying={isPlaying}\n showTime={!showDuration}\n onChange={onTimelineChange}\n onUpdate={onTimelineChange}\n timeZoneOffset={props.timeZoneOffset}\n markDate={props.markDate}\n trackContainerProps={props.trackContainerProps}\n />\n <div className=\"time-container\">\n {hasDates && (\n <span data-testid=\"test-end-date\" className=\"timeline-date\">\n {toDateString(endDate, timeZoneOffset)}\n </span>\n )}\n {hasDates && !showDuration && (\n <span className=\"timeline-time\">\n {toTimeString(endDate, timeZoneOffset, timeFormatOptions)}\n </span>\n )}\n {showDuration && (\n <InlineEdit\n className=\"timeline-duration-time\"\n defaultValue={totalDurationStr}\n onChange={(value) => {\n const newTotalDuration = timeToMs(value);\n updateTotalDuration(newTotalDuration);\n }}\n />\n )}\n </div>\n <SettingsMenu\n appMenuItems={props.appMenuItems}\n appMenuItemOption={appMenuItemOption}\n includeRepeat={includeRepeat}\n repeat={repeat}\n totalDuration={totalDuration}\n onRepeatClick={() => {\n updateRepeat(!repeat);\n }}\n onTotalDurationChange={(newTotalDuration) => {\n updateTotalDuration(newTotalDuration);\n }}\n />\n </div>\n );\n}\n\ntype SettingsMenuProps = Pick<\n TimelineComponentProps,\n \"appMenuItems\" | \"totalDuration\"\n> &\n Pick<\n Required<TimelineComponentProps>,\n \"appMenuItemOption\" | \"includeRepeat\" | \"repeat\"\n > & {\n onRepeatClick: () => void;\n onTotalDurationChange: (totalDuration: number) => void;\n };\n\nfunction SettingsMenu({\n appMenuItems,\n appMenuItemOption,\n includeRepeat,\n repeat,\n totalDuration,\n onRepeatClick,\n onTotalDurationChange,\n}: SettingsMenuProps) {\n const { translate } = useTranslation();\n\n const menuItems = React.useMemo(() => {\n const standardItems: TimelineMenuItemProps[] = [\n {\n label: translate(\"timeline.slow\"),\n timelineDuration: slowSpeed,\n },\n {\n label: translate(\"timeline.medium\"),\n timelineDuration: mediumSpeed,\n },\n {\n label: translate(\"timeline.fast\"),\n timelineDuration: fastSpeed,\n },\n ];\n\n if (!appMenuItems) {\n return standardItems;\n }\n\n if (appMenuItemOption === \"append\") {\n return [...standardItems, ...appMenuItems];\n }\n if (appMenuItemOption === \"prefix\") {\n return [...appMenuItems, ...standardItems];\n }\n // Replace\n return appMenuItems;\n }, [appMenuItemOption, appMenuItems, translate]);\n\n return (\n <DropdownMenu\n menuItems={(close) => {\n return [\n ...(includeRepeat\n ? [\n <MenuItem\n key=\"repeat\"\n onClick={() => {\n onRepeatClick();\n close();\n }}\n startIcon={repeat ? <SvgCheckmark /> : <></>}\n >\n {translate(\"timeline.repeat\")}\n </MenuItem>,\n <MenuDivider key=\"divider\" />,\n ]\n : []),\n ...menuItems.map((item, index) => {\n const checked = totalDuration === item.timelineDuration;\n return (\n <MenuItem\n key={index}\n startIcon={checked ? <SvgCheckmark /> : <></>}\n onClick={() => {\n onTotalDurationChange(item.timelineDuration);\n close();\n }}\n >\n {item.label}\n </MenuItem>\n );\n }),\n ];\n }}\n placement=\"top-start\"\n >\n <IconButton\n data-testid=\"timeline-settings\"\n label={translate(\"timeline.settings\")}\n styleType=\"borderless\"\n >\n <SvgMoreVertical />\n </IconButton>\n </DropdownMenu>\n );\n}\n\nfunction useAnimation(\n onAnimate: (args: { delta: number }) => void,\n playing = true\n) {\n const onAnimateRef = React.useRef(onAnimate);\n onAnimateRef.current = onAnimate;\n\n const lastTimeRef = React.useRef<number | undefined>();\n\n React.useEffect(() => {\n if (!playing) return;\n\n let handle = 0;\n let didCancel = false;\n\n const animate = (time: number) => {\n if (lastTimeRef.current === undefined) {\n lastTimeRef.current = time;\n }\n\n const delta = time - lastTimeRef.current;\n lastTimeRef.current = time;\n\n onAnimateRef.current({\n delta,\n });\n\n if (didCancel) return;\n\n handle = window.requestAnimationFrame(animate);\n };\n\n handle = window.requestAnimationFrame(animate);\n return () => {\n didCancel = true;\n lastTimeRef.current = undefined;\n window.cancelAnimationFrame(handle);\n };\n }, [playing]);\n}\n\nfunction timeToMs(time: string) {\n if (time.indexOf(\":\") !== -1) {\n return (\n (Number(time.split(\":\")[0]) * 60 + Number(time.split(\":\")[1])) * 1000\n );\n } else {\n return Number(time) * 1000;\n }\n}\n\nfunction toDisplayTime(ms: number) {\n const addZero = (i: number) => {\n return i < 10 ? `0${i}` : i;\n };\n\n const date = new Date(ms);\n // const hours = date.getUTCHours();\n const minutes = date.getUTCMinutes();\n const seconds = date.getUTCSeconds();\n return `${addZero(minutes)}:${addZero(seconds)}`;\n}\n"]}
@@ -164,7 +164,7 @@ export function ViewportComponent(props) {
164
164
  setInitialViewState(undefined);
165
165
  }, [viewDefinitionId, viewState]);
166
166
  React.useEffect(() => {
167
- async function fetchInitialViewstate() {
167
+ async function fetchInitialViewState() {
168
168
  let currentViewState;
169
169
  if (viewState) {
170
170
  if (typeof viewState === "function")
@@ -176,15 +176,15 @@ export function ViewportComponent(props) {
176
176
  try {
177
177
  currentViewState = await imodel.views.load(viewDefinitionId);
178
178
  if (!currentViewState) {
179
- Logger.logError("ViewportComponent", `Viewstate failed to load`);
179
+ Logger.logError("ViewportComponent", `ViewState failed to load`);
180
180
  }
181
181
  }
182
- catch (_e) {
183
- Logger.logError("ViewportComponent", `Viewstate failed to load`);
182
+ catch {
183
+ Logger.logError("ViewportComponent", `ViewState failed to load`);
184
184
  }
185
185
  }
186
186
  else {
187
- Logger.logError("ViewportComponent", `A Viewstate or a viewId and imodel must be provided`);
187
+ Logger.logError("ViewportComponent", `A ViewState or a viewId and imodel must be provided`);
188
188
  }
189
189
  if (isMounted.current &&
190
190
  (currentViewState?.iModel.isOpen || currentViewState?.iModel.isBlank)) {
@@ -192,7 +192,7 @@ export function ViewportComponent(props) {
192
192
  }
193
193
  }
194
194
  if (undefined === initialViewState)
195
- void fetchInitialViewstate();
195
+ void fetchInitialViewState();
196
196
  }, [imodel, initialViewState, viewDefinitionId, viewState]);
197
197
  const [viewOverlay, setViewOverlay] = React.useState(null);
198
198
  // This useEffect connects to ViewManger as soon as initialViewState is available once component is mounted.